#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007LL
#define MXN 10005
#define INF 1e9
#define EPS 1e-8
#define endl '\n'
#define lowbit(x) (x&-x)
using namespace std;

mt19937 gen(time(0));

ll n;
bool isprime[MXN];
bool v[MXN];
ll ans[MXN];
ll factor[] = {6,10,15};
vector<ll> prime;

void sieve(){
    for(ll i=2;i<=10000;i++){
        if(isprime[i])  continue;
        prime.push_back(i);
        for(ll j=i*i;j<=10000;j+=i){
            isprime[j]=1;
        }
    }
}

bool isfactor(ll x){
    for(int i=0;i<3;i++)    if(x%factor[i]==0)  return 1;
    return 0;
}

bool check(){
    ll gcd=ans[0];
    for(int i=0;i<n;i++){
        gcd=__gcd(gcd,ans[i]);
        if(ans[i]>10000)    return 0;
        if(ans[i]<=0)   return 0;
        if(v[ans[i]])   return 0;
        v[ans[i]]=1;
    }
    return gcd==1;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    sieve();
    // cout<<prime.size()<<endl;
    // for(auto i:prime)   cout<<i<<" ";
    // cout<<endl;
    cin>>n;

    ans[0] = 6;
    ans[1] = 10;
    ans[2] = 15;
    ans[3] = 12;

    for(int i=4,j=16;i<n;i++,j++){
        while(!isfactor(j)){ j++; }
        ans[i]=j;
    }

    assert(check());
    for(int i=0;i<n;i++)    cout<<ans[i]<<" ";
    cout<<endl;

    return 0;
}

/*

*/

#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define ll long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define all(a) a.begin(),a.end()
// #define mod 1000000007
#define pi 3.141592653589
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod) ;
int power(int x, int y) ;
int gcd(int a, int b) ;

int power(int x, int y) {
    int res = 1 ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x) ;
    }
    return res ;
}

int gcd(int a,int b) {
    if(a==0) return b;
    return gcd(b%a,a);
}

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
// template<typename T>
// using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
//(*****FOR USING ORDERED SET CHANGE INT*******)

// struct chash {
//     const int RANDOM = (long long)(make_unique<char>().get()) ^ chrono::high_resolution_clock::now().time_since_epoch().count();
//     static unsigned long long hash_f(unsigned long long x) {
//         x += 0x9e3779b97f4a7c15;
//         x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//         x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//         return x ^ (x >> 31);
//     }
//     static unsigned hash_combine(unsigned a, unsigned b) { return a * 31 + b; }
//     int operator()(int x) const { return hash_f(x)^RANDOM; }
// };

signed main() {
    quickie
    int n ;
    cin >> n ;
    int a[n] ;
    rep(i, 0, n) {
        cin >> a[i] ;
    }
    int ans = 0 ;
    int curs = 0 ;
    int curel = 0 ;
    int curmax = 0 ;
    rep(i, 0, n) {
        curs += a[i] ;
        curmax = max(curmax, curs) ;
        ans = max(ans, curel+curmax) ;
        curel += curs ;
    }
    cout << ans << "\n" ;
}


#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<sstream>
#include<cstring>
#include<cstdio>
#include<string>
#include<deque>
#include<cmath>
#include<queue>
#include<set>
#include<map>

using namespace std;

const long long MOD = 998244353;

int n;
long long a[200010];

long long base[200010];

void init() {
	base[0] = 1;
	for (int i = 1 ; i < 200010 ; i++) {
		base[i] = (base[i - 1] * 2) % MOD;
	}
}

int main(void)
{
	init();

	scanf("%d", &n);
	for (int i = 0 ; i < n ; i++)
		scanf("%lld", &(a[i]));

	if (n == 1) {
		long long ans = (a[0] * a[0]) % MOD;
		printf("%lld\n", ans);
		return 0;
	}

	sort(a, a + n);

	long long sum = 0;
	long long item = 0;
	item = a[n - 1];
	sum = (sum + a[n - 1] * item) % MOD;
	item = a[n - 1] + a[n - 2];
	sum = (sum + a[n - 2] * item) % MOD;

	//item4 = a[n-4] + a[n-3] + 2*a[n-2] + 4*a[n-1]
	//item3 =          a[n-3] +   a[n-2] + 2*a[n-1]
	//item2 =                     a[n-2] +   a[n-1]
	for (int i = n - 3 ; i >= 0 ; i--) {
		item = item - a[i + 1];
		if (item < 0) item = item + MOD;

		item = (item * 2) % MOD;
		item = (item + a[i + 1] + a[i]) % MOD;

		long long curN = (a[i] * item) % MOD;
		sum = (sum + curN) % MOD;
	}

	printf("%lld\n", sum);

	return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower)
#define upper_string(s) transform(all(s),s.begin(),::toupper)
#define len(s) (int)s.size()
#define F first
#define S second
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
const int MOD=998244353;
void solve()
{
int n;
cin>>n;
int a[n];
for(auto &x:a)
cin>>x;
sort(a,a+n);
ll ans=0;
for(auto &x:a)
ans=(ans+(x*x)%MOD)%MOD;
ll p=a[0];
for(int i=1;i<n;i++)
{
	ans=(ans+(a[i]*p)%MOD)%MOD;
	p=(p*2+a[i])%MOD;
}
cout<<ans;
}
signed main()
{
//code
fastio
int t=1;
//cin>>t;
while(t--)
{
solve();
cout<<endl;
}
}


/**
        Bismilla- hir rahma-nir rahi-m
    @uthor Md Hasibur Rahman (Evan)
                JKKNIU
*/

#include<bits/stdc++.h>
#define         ll              long long
#define         FI              freopen("input.txt","r",stdin)
#define         FO              freopen("output.txt","w",stdout)
#define         PrintCase(i)    printf("Case %d: ",i)
#define         sc(a)           scanf("%d",&a)
#define         scl(a)          scanf("%lld",&a)
#define         rep(i,n)        for(int i=0;i<n;i++)
#define         pb              push_back
#define         MAX             1000000
#define         fast            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define         endl            "\n"

using namespace std;

bool isPrime(ll a)
{
    for(ll i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}

bool isPowerOfTwo(ll a)
{
    if(a==1)
        return true;
    if(a&1)
        return false;
    while(a)
    {
        a/=2;
        if(a!=1 && a&1)
            return false;
        if(a==1)
            return true;
    }
    return true;
}

void Swap(ll &a, ll &b)
{

    a^=b;
    b^=a;
    a^=b;
}

ll gcd(ll a, ll b)
{
    if(a<0 || b<0)
    {
        a = abs(a);
        b = abs(b);
    }
    if(a<b)
        Swap(a,b);
    if(b==0)
        return a;
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a,b);
}

ll power(ll base, ll exponent)
{
    ll ans = 1;
    for(ll i=1;i<=exponent;i++)
        ans*=base;
    return ans;
}

bool isPowerOfX(ll x, ll value)
{
    if(value==1)
        return true;
    while(value)
    {
        value/=x;
        if(value%x && value!=1)
            return false;
    }
    return true;
}

bool isPrefectSquare(ll value)
{
    return (ll)sqrtl(value)*(ll)sqrtl(value)==value;
}

ll fact(ll value)
{
	if(value==0 || value==1)
		return 1;
	return value*fact(value-1);
}

int main()
{
	string s,tmp1,tmp2;
	cin>>s;
	int i=0,j=s.size()-1;
	while(s[i]=='0')i++;
	while(s[j]=='0')j--;
	for(int k=i;k<=j;k++)tmp1+=s[k];
	tmp2 = tmp1;
	reverse(tmp2.begin(),tmp2.end());
	tmp1==tmp2?cout<<"Yes\n":cout<<"No\n";
    return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main(){
    string n;
    cin >> n;
    int zero_counter = 0;
    for(int i = 0;i < n.size();i++){
        if(n[n.size()-1-i] == '0'){
            zero_counter += 1;
        }else{
            break;
        }
    }
    for(int i = 0;i < zero_counter;i++){
        n = string("0") + n;
    }
    int size_n = n.size();
    for(int i = 0;i < size_n/2;i++){
        if(n[i]!=n[size_n-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long a [4] , ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    long long n , m;
    cin >> n >> m;
    for ( int i = 0 ; i < n ; i ++ )
    {
        string s;
        cin >> s;
        int num = 0;
        for ( int j = 0 ; j < s . size () ; j ++ )
        {
            if ( s [j] == '1' ) num ++;
        }
        num %= 2;
        ans += a [ !num ];
        a [num] ++;
    }
    cout << ans;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
using graph = vector<VI>;
template<class T = ll> using w_graph = vector<vector<pair<int, T>>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#ifdef _DEBUG
#define line cout << "-----------------------------\n"
#define stop system("pause")
#endif
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }
template<class T>inline T sum(const vector<T>& a, int l, int r) { return a[r] - (l == 0 ? 0 : a[l - 1]); }
template<class T>inline void END(T s) { print(s); exit(0); }
void END() { exit(0); }

int main() {
    init();

    int n, m; cin >> n >> m;
    VL cnt(1 << m);
    FOR(i, 0, n) {
        string s; cin >> s;
        int num = 0;
        FOR(i, 0, m) {
            num = num * 2 + (s[i] - '0');
        }
        ++cnt[num];
    }

    ll e = 0, o = 0;
    FOR(bit, 0, 1 << m) {
        int k = 0;
        FOR(i, 0, m)if (bit >> i & 1)++k;
        if (k & 1)o += cnt[bit];
        else e += cnt[bit];
    }

    print(ll(n)* (n - 1) / 2 - e * (e - 1) / 2 - o * (o - 1) / 2);

    return 0;
}


#include <bits/stdc++.h>

#define int long long
#define ll long long
#define endl "\n"
using namespace std;
const int maxn = 1e5;

signed main() {
    int x, y;
    cin >> x >> y;
    if (x == y)
        cout << x << endl;
    else {
        cout << 3 - x - y << endl;
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll mod = 1e9 + 7;
const ll N = 1e5 + 8;

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    ll n, k;
    cin >> n >> k;
    ll res = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= k; j++) {
            res += 100 * i + j;
        }
    }
    cout << res;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  int k=10*10*10*10*10*10;
  vector<long long> yakusuu(2*k);
  for(int i=1;i<k+1;i++){
    if(n%i==0){
      yakusuu[i-1]=i;
      yakusuu[2*k-i]=n/i;
    }
  }
  sort(yakusuu.begin(),yakusuu.end());
  yakusuu.erase(unique(yakusuu.begin(),yakusuu.end()),yakusuu.end());
  for(int i=1;i<yakusuu.size();i++) cout<<yakusuu[i]<<endl;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
    long n;
    cin>>n;
    set<long> ans;
    for(long d=1;d*d<=n;d++) {
        if(n%d==0) {
            ans.insert(d);
            ans.insert(n/d);
        }
    }
    for(auto x:ans) cout<<x<<endl;
}


#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

template<class T>
vector<T> make_vec(size_t a){
	return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
	return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//-------------------------------------------------
//--Union Find tree
//-------------------------------------------------
class UnionFind
{
private:
    vector<int> par;
    vector<int> rank;
    vector<int> sz;
public:
    UnionFind(int n):par(n),rank(n),sz(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx==ry) return;
        if (rank[rx]<rank[ry]){
            par[rx] = par[ry];
            sz[ry] += sz[rx];
        }else{
            par[ry] = par[rx];
            sz[rx] += sz[ry];
            if (rank[rx]==rank[ry]) rank[rx]++;
        }
    }
    int size(int x){
        return sz[root(x)];
    }
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vi a(N);
    rep(i,N) cin>>a[i], a[i]--;

    UnionFind uf(200000);
    rep(i,N/2){
        if (a[i]==a[N-i-1]) continue;
        uf.unite(a[i],a[N-i-1]);
    }

    set<int> se;
    rep(i,200000){
        se.ins(uf.root(i));
    }

    int ans=0;
    for(auto e:se){
        ans+=uf.size(e)-1;
    }

    cout<<ans<<"\n";
    return 0;
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
//#define int long long
const int N = 1e6;
int n,m;
bool pd[N];
inline int read()
{
	int X=0;bool flag=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')flag=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){X=(X<<1)+(X<<3)+ch-'0';ch=getchar();}
	if(flag)return X;
	return ~(X-1);
}

inline void write(int X)
{
	if(X<0){X=~(X-1);putchar('-');}
	if(X>9){write(X/10);}
	putchar(X%10+'0');
}

signed main()
{
	n=read(),m=read();
	int temp;
	for(int i=1;i<=n;i++)temp=read(),pd[temp]^=1;
	for(int i=1;i<=m;i++)temp=read(),pd[temp]^=1;
	for(int i=1;i<=1000;i++)if(pd[i])printf("%d ",i);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define deb(x) cout << #x << " " << x << endl;
#define mod 1000000007
#define fast std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
const ll INF = 1e18;
const ll NEGINF = -1 * INF;

void solve()
{
    int n;
    cin >> n;
    ll x, t;
    ll a = 0;
    ll b = INT_MIN;
    ll c = INT_MAX;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> t;
        if (t == 1)
        {
            a += x;
            b += x;
            c += x;
        }
        else if (t == 2)
        {
            b = max(b, x);
            c = max(c, x);
        }
        else
        {
            b = min(b, x);
            c = min(c, x);
        }
    }
    // deb(a);
    // deb(b);
    // deb(c);
    int q;
    cin >> q;
    while (q--)
    {
        cin >> x;
        cout << min(c, max(b, a + x)) << endl;
    }
}

int main()
{
    fast;
#ifndef ONLINE_JUDGE
    freopen("/home/kalit/Desktop/Data Structures-Algo-Competitive/src/codeforces/input.txt", "r", stdin);
    freopen("/home/kalit/Desktop/Data Structures-Algo-Competitive/src/codeforces/output.txt", "w", stdout);
#endif
    int T = 1;
    while (T--)
    {
        solve();
    }
    //cout<< "Done in " << clock() / CLOCKS_PER_SEC <<"sec"<< endl;
    return 0;
}

//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define all(v) v.begin(),v.end()
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> pii;
typedef pair<ll, ll> LL;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int setBit(int mask, int pos){return mask = mask | (1<<pos);}
bool checkBit(int mask, int pos){return (bool)(mask & (1<<pos));}

int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47 };
int arr[60];
set<int> s[60];
int vis[60];

void solve()
{
    int n;

    cin>>n;

    REP(i, n) {
        cin>>arr[i];
        for(int j = 0; j < 15; j++) {
            if(arr[i] % primes[j] == 0) {
                while(arr[i] % primes[j] == 0) {
                    arr[i] /= primes[j];
                }
                s[i].insert(primes[j]);
            }
        }
        if(arr[i] != 1) {
            s[i].insert(arr[i]);
        }
    }

    ll ans = 1e18;

    for(int i = 0; i < (1<<15); i++) {
        ll res = 1;
        for(int j = 0; j < n; j++)
            vis[j] = 0;
        for(int j = 0; j < 15; j++) {
            if(checkBit(i, j)) {
                res = (1LL * res * primes[j]);
                for(int k = 0; k < n; k++) {
                    if(!vis[k]) {
                        if(s[k].count(primes[j])) {
                            vis[k] = 1;
                            continue;
                        }
                    }
                }
            }
        }
        bool flag = true;
        for(int j = 0; j < n; j++) {
            if(!vis[j]) {
                flag = false;
                break;
            }
        }

        if(flag) {
            ans = min(ans, res);
        }
    }

    cout<<ans<<endl;

    return;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int test = 1;

    //cin>>test;

    while(test--) {
        solve();
    }

    return 0;
}


#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    bool isUpper = false;

    char s;
    cin >> s;
    if (s == 'Y') {
        isUpper = true;
    }

    char t;
    cin >> t;
    if (isUpper) {
        t = toupper(t);
    } else {
        t = tolower(t);
    }

    cout << t << '\n';

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;
  vll a((1<<n));
  REP(i,(1<<n))cin>>a[i];

  vll v;
  REP(i,(1<<n))v.push_back(i);

  for(ll i=1; i<n; i++){
    vll q;
    for(ll j=1; j<=(1<<(n-i)); j++){
      if(a[v[2*j-2]]>a[v[2*j-1]])
        q.push_back(v[2*j-2]);
      else
        q.push_back(v[2*j-1]);
    }

    sort(ALL(q));
    swap(v,q);
  }

  ll ans;
  if(a[v[0]]>a[v[1]])
    ans=v[1];
  else
    ans=v[0];

  cout<<ans+1<<endl;
}


#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using GrafPair=vector<vector<P>>;
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    vector<ll> num(4);
    cin >> num[0] >> num[1] >> num[2] >> num[3];
    ll sum=0;

    int n=4;

    rep(i,4)sum+=num[i];

    for (int bit = 0; bit < (1<<n); ++bit)
    {
        /* bit で表される集合の処理を書く */

        ll tmp=0;
        /* きちんとできていることを確認してみる */
        // bit の表す集合を求める
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
            }
        }

        // bit の表す集合の出力

        if(S.size()>=1)
        for (int i = 0; i < (int)S.size()-1; ++i) {
            tmp+=num[S[i]];
        }
        if(tmp==sum-tmp){
            Yes;return 0;
        }
    }
    No;

}

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()

int main(){
	VI a(4); REP(i,4) cin >> a[i];
	ll sum=0;
	REP(i,4) sum+=a[i];
	bool yes=0;
	REP(i,1<<4){
		if(i==0)
			continue;
		ll s=0;
		REP(j,4){
			if(i>>j&1)
				s+=a[j];
		}
		if(s*2==sum)
			yes=1;
	}
	if(yes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


#include <iostream>
#include <math.h>
#include <iomanip>
#include <bits/stdc++.h>
#include <string.h>
#include <string>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << (#x) << " = " << x << endl;
#define debug2(i,j) cout << (#i) << "=" << i << " , " << (#j) << "=" << j << endl;

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

/* nCr % mod
ll fact[6*N];
ll inv[6*N],invfac[6*N];
ll mod = 998244353;

void factorial()
{
    fact[0] = invfac[0] = fact[1] = invfac[1] = 1;
    inv[1] = 1;
    for(int i=2;i<=5*N + 10;i++)
    {
        fact[i] = (fact[i-1]*i)%mod;
        inv[i] = (inv[mod%i]*(mod - mod/i))%mod;
        invfac[i] = (invfac[i-1]*inv[i])%mod;
    }
}*/

vector<ll> primes;
vector<bool> prime;

void Sieve(int n)
{
    prime = vector<bool> (n+1,true);
    //vector<bool> prime(n+1,true);
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.push_back(p);
}

ll modInverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

const int Nmax = 2e5 + 6;
const int N = 105;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    char s;
    char t;
    cin >> s >> t;
    if(s=='Y')
    {
        if(t>=65 && t <= 90)
            cout << t << '\n';
        else
        {
            t-=32;
            cout << t << '\n';
        }
    }
    else
        cout << t << "\n";
}

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <bitset>
#include <queue>
using namespace std;
using ll = long long int;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
const ll INF = 1LL << 60;
ll mod = 1000000007;

int main() {
    char s,t;
    cin >> s >> t;
    if(s == 'Y') {
        t = t - 'a' + 'A';
        cout << t << endl;
    }else if(s == 'N') {
        cout << t << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define fin(a) cout << a << endl; return 0
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using ld = long double;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
template<class T> using priq     = priority_queue<T>;
template<class T> using priq_inv = priority_queue<T, vector<T>, greater<T>>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; }
struct INF { template<class T> operator T() { return numeric_limits<T>::max() / 2; } } INF;

template<class T, class U> istream& operator>>(istream &in, pair<T,U> &p) {
    return in >> p.first >> p.second;
}
template<class T, class U> ostream& operator<<(ostream &out, const pair<T,U> &p) {
    return out << '{' << p.first << ',' << p.second << '}';
}
template<class T, class U> pair<T,U> operator+(const pair<T,U> &l, const pair<T,U> &r) {
    return make_pair(l.first+r.first, l.second+r.second);
}
template<class T, class U> pair<T,U> operator-(const pair<T,U> &l, const pair<T,U> &r) {
    return make_pair(l.first-r.first, l.second-r.second);
}
template<class T, class U> pair<T,U> operator*(const pair<T,U> &l, const pair<T,U> &r) {
    return make_pair(l.first*r.first, l.second*r.second);
}
template<class T, class U> pair<T,U> operator/(const pair<T,U> &l, const pair<T,U> &r) {
    return make_pair(l.first/r.first, l.second/r.second);
}
template<class T, class U> pair<T,U>& operator+=(pair<T,U> &l, const pair<T,U> &r) { return l = l+r; }
template<class T, class U> pair<T,U>& operator-=(pair<T,U> &l, const pair<T,U> &r) { return l = l-r; }
template<class T, class U> pair<T,U>& operator*=(pair<T,U> &l, const pair<T,U> &r) { return l = l*r; }
template<class T, class U> pair<T,U>& operator/=(pair<T,U> &l, const pair<T,U> &r) { return l = l/r; }

template<class T>
istream& operator>>(istream &in, vector<T> &v) {
    for(auto &e : v) in >> e;
    return in;
}
template<class T>
ostream& operator<<(ostream &out, const vector<T> &v) {
    for(const auto &e : v) out << e << ' ';
    return out;
}

/*----------------------------------------------------------------------------------------------------*/

int main(){
    int n, m, t;
    cin >> n >> m >> t;
    V<P> v(m);
    cin >> v;
    int b = n;
    bool ok = true;
    rep(i,m) {
        if(i == 0) b -= v[i].fi;
        else b -= (v[i].fi - v[i-1].se);
        ok &= (b > 0);
        b = min(n, b + v[i].se-v[i].fi);
    }
    b -= (t - v[m-1].se);
    ok &= (b > 0);
    YesorNo(ok);
}

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
const int INF = 1e9;
const int TMX = 1 << 18;
const long long llINF = 2e18;
const long long mod = 1e9+7;
const long long hashmod = 100003;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
typedef vector <pi> vecpi;
typedef long long ll;
int n;
ll t,t2,st;
pi a[1005];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> t >> n >> t2;
	st = t;
	for(int i = 1;i <= n;i++) {
		cin >> a[i].x >> a[i].y;
		t -= a[i].x-a[i-1].y;
		if(t <= 0) {
			cout << "No";
			return 0;
		}
		t += a[i].y-a[i].x;
		t = min(t,st);
	}
	if(t2-a[n].y < t) cout << "Yes";
	else cout << "No";
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define vi vector <int>
#define vl vector <ll>
#define vii vector < pair <int,int> >
#define vll vector < pair <ll,ll> >
#define mii map<int,int>
#define mll map<ll,ll>
#define si set <int>
#define sl set <ll>
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll binomialCoeff(ll n, ll k)
{
    ll res = 1;

    // Since C(n, k) = C(n, n-k)
    if (k > n - k)
        k = n - k;

    // Calculate value of
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
    for (ll i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
struct MyComp
{
    bool operator()(const pair<int,int>& x, const pair<int,int>& y) const
    {
        return x.second > y.second || (x.second == y.second && x.first > y.first);
    }
};
ll M=1e9+7;
ll mods(ll a,ll b){
    a=a%M;
    b=b%M;
    return (a+b)%M;
}
ll modp(ll a,ll b){
    a=a%M;
    b=b%M;
    return (a*b)%M;

}

int main(){
    fastio

        int n;cin>>n;
        cout<<100-(n%100)<<endl;

}
//n = unique(a, a + n) - a;

/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long int
typedef vector<int> vi;
typedef vector<pair<int, int>> vpi;
typedef vector<vi> vvi;
const int mod = 1e9 + 7;

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define EB emplace_back
#define ALL(v) v.begin(), v.end()
#define size(v) (int)v.size()
#define endl '\n'
#define UMO unordered_map
#define USO unordered_set
#define TC int t; cin >> t; while (t--)

void Panda() {
    int x;
    cin >> x;
    cout << (x % 100 == 0 ? 100 : ((x - (x % 100) + 100)) - x) << endl;
}

int32_t main() {

    FAST;

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    Panda();

    return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_K = 200005;
ll cnt[MAX_K];

int main()
{
	ll K;
	cin >> K;
	for (int i = 1; i <= K; ++i)
	{
		for (int j = 1; j*j <= i; ++j)
		{
			if (i % j == 0)
			{
				cnt[i]++;
				if (i/j != j) cnt[i]++;
			}
		}
	}

	/*
	rep(i,K+1)
	{
		cout << cnt[i] << endl;
	}
	*/

	rep(i,K)
	{
		cnt[i+1] += cnt[i];
	}

	ll ans = 0;
	for (int i = 1; i <= K; ++i)
	{
		ans += cnt[K/i];
		//cout << cnt[K/i] << " ";
	}
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define rep(i,b,e) for(int i=b;i<e;i++)
#define per(i,e,b) for(int i=e;i>b;i--)
const int maxn = 5e5+5;

void solve() {
	int x;
	cin >> x;
	if (x >= 0) cout << x << '\n';
	else cout << "0\n";
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("/home/l4wenwen/data/in", "r", stdin);
	//freopen("~/out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
		solve();
	return 0;
}


#pragma GCC optimize("Ofast,unroll-loops")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef int ll;
typedef long double ld;
typedef pair <ll, ll> pll;

#ifdef SINA
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << std::endl; }
template <typename Arg1, typename... Args> void __f (const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); }
#define dbg2(x, j, n) cout<< #x << " : "; output((j), (n), x, 1); cout.flush();
#else
#define dbg(...) 0
#define dbg2(x, j, n) 0
#endif
#define SZ(x) ((ll)((x).size()))
#define File(s, t) freopen(s ".txt", "r", stdin); freopen(t ".txt", "w", stdout);
#define input(j, n, a) for (int _i = (j); _i < (n)+(j); _i++) cin>> a[_i];
#define output(j, n, a, t) for (int _i = (j); _i < (n)+(j); _i++) cout<< a[_i] << (((t) && _i != (n)+(j)-1)? ' ' : '\n');
#define kill(x) return cout<< (x) << endl, 0
#define cl const ll
#define fr first
#define sc second
#define lc (v << 1)
#define rc (lc | 1)
#define mid ((l + r) >> 1)
#define All(x) (x).begin(), (x).end()

cl inf = sizeof(ll) == 4 ? (1e9 + 10) : (3e18), mod = 1e9 + 7, MOD = 998244353;

template <class A,class B> ostream& operator << (ostream& out,const pair<A,B>&a){return out<<'('<<a.first<<", "<<a.second<<')';}
template <class A> ostream& operator << (ostream& out, const vector<A> &a) {
	out<< '['; for (int i = -1; ++i < int(a.size());) out<< a[i] << (i + 1 < int(a.size()) ? ", " : ""); return out<<']'; }
template <class T, typename _t = less <T> > using Tree = tree <T, null_type, _t, rb_tree_tag, tree_order_statistics_node_update>;

cl N = 5e2 + 7;

ll a [N], b [N], n;
vector <ll> ans;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

bool check () {
	for (ll i = 1; i < n; i++) if (a[i] > a[i + 1]) return false;
	return true;
}

void solve () {

	cin>> n;
	input(1, n, b);

	do {

	for (ll i = 1; i <= n; i++) a[i] = b[i];

	ans.clear();
	// bool f [2]; f[0] = f[1] = true;
	for (ll o = 1; ; o = 1 - o) {
		bool fnd = false;

		for (ll i = 2 - o; i < n; i += 2) if (a[i] > a[i + 1]) {
			swap(a[i], a[i + 1]);
			ans.push_back(i);
			// dbg(i, a[i]);
			fnd = true;
			break;
		}

		if (!fnd) {
			if (check()) break;

			ll x = rng() % n;

			if (!x) x++;

			if ((x & 1) != o) {
				if (x > 1) x--;
				else x++;
			}

			swap(a[x], a[x + 1]);
			ans.push_back(x);
		}
	}

	} while (SZ(ans) > n * n);
	// dbg(ans);
	cout<< SZ(ans) << '\n';
	output(0, SZ(ans), ans, 1);
}

int main ()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	ll tst;
	for (cin>> tst; tst--;) solve();

	cerr<< "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

	return 0;
}
/*
1
4
1 4 2 3

1 4 2 3
1 4 3 2
1 3 4 2
1 3 2 4
1 2 3 4

1
4
1 4 3 2

1 4 3 2
1 4 2 3
1 2 4 3
1 2 3 4

*/

#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int X; scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
#define loop(I, A, B) for (int I = (A); I <= (B); ++I)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int SIZE = 2e5+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

int p[100009];
int pp[100009];

int main(){
    CASET{
        DRI(n);
        REP(i,n){
            RI(p[i]);
            pp[i]=p[i];
        }
        if(n==2){
            if(p[0]==1)puts("0");
            else printf("1\n1\n");
            continue;
        }
        vector<int> ans;
        REP(i,n-3){//try and find value 0...i-1 positions are all ok. Avoid flipping <i i+1;
            while(1){
                int sp=0;//move this to position i
                REP(j,n){
                    if(p[j]==i+1){
                        sp=j;
                        break;
                    }
                }
                if(sp==i)break;//good position
                if(sp%2!=SZ(ans)%2){//bingo!
                    while(sp>i){
                        sp--;
                        swap(p[sp],p[sp+1]);
                        ans.PB(sp);
                    }
                    break;
                }
                else{//avoid if possible
                    int nx = i;
                    if(nx%2!= SZ(ans)%2){
                        nx++;
                    }
                    for(int j=nx;j<n-1;j+=2){
                        if(j!=sp&&j+1!=sp){
                            nx=j;break;
                        }
                    }
                    swap(p[nx],p[nx+1]);
                    ans.PB(nx);
                }
            }
        }
        REP(it,10){
            bool good = 1;
            REPP(i,n-3,n){
                good&=p[i]==i+1;
            }
            if(good)break;
            int x = n-2;
            if(x%2!=SZ(ans)%2){
                x--;
            }
            swap(p[x],p[x+1]);
            ans.PB(x);
        }
        /*for(int i:ans){
            swap(pp[i],pp[i+1]);
            REP(j,n){
                printf("%d ",pp[j]);
            }puts("");
        }*/
        printf("%d\n",SZ(ans));
        REP(i,SZ(ans)){
            if(i)printf(" ");
            printf("%d",ans[i]+1);
        }puts("");case_n++;
    }
}


#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

ll dp[100][2];

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll X; cin >> X;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> x(N);
    for(int i = N-1; i >= 0; i--){
        x[i] = X/A[i];
        X %= A[i];
    }

    dp[0][0] = 1;
    for(int i = 0; i < N; i++){
        ll kuri = (i == N-1) ? LLINF : A[i+1]/A[i];
        for(int j = 0; j <= 1; j++){
            if((x[i]+j) % kuri == 0){
                //y == 0 <=> z == 0
                int nj = (x[i]+j)/kuri;
                dp[i+1][nj] += dp[i][j];
            }
            else{
                dp[i+1][0] += dp[i][j];
                dp[i+1][1] += dp[i][j];
            }
        }
    }

    cout << dp[N][0] << endl;
    return 0;
}

/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */
#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

using ld=long double;
const ld PI = acos((ld)-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) ld d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<ld, ld>;
using vd= vector<ld>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

int isqrt(int i) {
    return (int)sqrt(i);
}

/* Its some kind of dijkstra.
 * But we cannot iterate all possible waiting times on all edges :/
 * But, the earliest time to pass an edge seems to be sqrt(D[i])
 * after begin, so it never makes sense to wait longer.
 * So we need to iterate only that edges where t is smaller
 * than sqrt(D[i]).
 *
 * How to get rid of TLE?
 */
const int INF=1e18;
void solve() {
    cini(n);
    cini(m);

    vector<vector<pii>> adj(n);
    vi C(m);
    vi D(m);
    for(int i=0; i<m; i++) {
        cini(a); a--;
        cini(b); b--;
        adj[a].emplace_back(b,i);
        adj[b].emplace_back(a,i);
        cin>>C[i];
        cin>>D[i];
    }

    vi dp(n, INF);          /* dp[i]=min time possible arriving at vertex i */
    priority_queue<pii> q;  /* <-mintime,vertex> */
    q.emplace(0, 0);
    dp[0]=0;
    while(q.size()) {
        auto [t,v]=q.top();
        q.pop();
        if(-t!=dp[v])
            continue;

        for(pii chl : adj[v]) {
            /* without waiting */
            int mii=dp[v]+C[chl.second]+D[chl.second]/(dp[v]+1);

            int optWait=max(dp[v], isqrt(D[chl.second])-1);
            mii=min(mii, optWait+C[chl.second]+D[chl.second]/(optWait+1));
            optWait++;
            mii=min(mii, optWait+C[chl.second]+D[chl.second]/(optWait+1));

            if(mii<dp[chl.first]) {
                dp[chl.first]=mii;
                q.emplace(-mii, chl.first);
            }
        }
    }

    if(dp[n-1]==INF)
        dp[n-1]=-1;
    cout<<dp[n-1]<<endl;
}

signed main() {
    solve();
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define reps(i,s,n) for(int i=s; i<n; i++)
#define per(i,n) for(int i=n-1; i>=0; i--)
#define pers(i,n,s) for(int i=n-1; i>=s; i--)
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define lb(v,n) lower_bound(all(v),n)
#define lbi(v,n) int(lower_bound(all(v),n) - v.begin())
#define ub(v,n) upper_bound(all(v),n)
#define ubi(v,n) int(upper_bound(all(v),n) - v.begin())

#define mod 1000000007
#define infi 1010000000
#define infl 1100000000000000000

#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define IN(n,m,v) rep(i,n) rep(j,m){cin >> v[i][j];}
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define cYES cout << "YES" << endl
#define cNO cout << "NO" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){
        d = extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else x=1,y=0;
    return d;
}

template <typename T> T mod_pow(T m, T n) {
    if(n == 0) return 1;
    T res = mod_pow(m*m%mod, n/2);
    if(n & 1) res *= m;
    return res%mod;
}

template <typename T> T mod_inv(T n) {
    T m = mod;
    T x,y;
    extgcd(n,m,x,y);
    return (m+x%m)%m;
}

void solve(){

    int N,M,K;
    cin >> N >> M >> K;
    vl A(N);
    in(N,A);

    vvl P(N,vl(N,0));
    rep(i,N) P[i][i] = 1;
    ll mm = mod_inv<ll>((ll)(M*2));
    rep(i,M){
        int x,y;
        cin >> x >> y;
        x--,y--;
        P[x][x] += mod;
        P[y][y] += mod;
        (P[x][x] -= mm) %= mod;
        (P[x][y] += mm) %= mod;
        (P[y][x] += mm) %= mod;
        (P[y][y] -= mm) %= mod;
    }

    ve<vvl> vP;
    vP.pb(P);
    rep(i,30){
        vvl p = vP.back();
        vvl pp(N,vl(N,0));
        rep(i,N) rep(j,N) rep(k,N) (pp[i][j] += p[i][k]*p[k][j]%mod) %= mod;
        vP.pb(pp);
    }

    vl ans = A;
    int id = 0;
    while (K > 0) {
        if(K & 1){
            A = ans;
            ans.assign(N,0);
            rep(i,N) rep(j,N) (ans[i] += vP[id][i][j]*A[j]%mod) %= mod;
        }
        id++;
        K = K >> 1;
    }

    rep(i,N) cout << ans[i] << endl;

}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();

    return 0;
}

#include <iostream>

using namespace std;
using LL = long long;

const int kMaxN = 101;
const LL kMod = 1e9 + 7;

int n, m, k;
LL d[kMaxN], a[kMaxN], r[kMaxN][kMaxN], p_n = 1, b[kMaxN][kMaxN], c[kMaxN][kMaxN];
bool l[kMaxN][kMaxN];

LL PM(LL x) {
  LL s = 1;
  for (LL i = kMod, b = x; i; i >>= 1, b = b * b % kMod) {
    if (i & 1) {
      s = s * b % kMod;
    }
  }
  return s;
}

void M(LL a[kMaxN][kMaxN], LL b[kMaxN][kMaxN]) {
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      c[i][j] = 0;
      for (int k = 1; k <= n; ++k) {
        c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % kMod;
      }
    }
  }
}

int main() {
  cin >> n >> m >> k;
  for (LL i = kMod - 2, b = 2 * m; i; i >>= 1, b = b * b % kMod) {
    if (i & 1) {
      p_n = p_n * b % kMod;
    }
  }
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1, x, y; i <= m; ++i) {
    cin >> x >> y;
    l[x][y] = l[y][x] = 1;
    ++d[x], ++d[y];
  }
  for (int i = 1; i <= n; ++i) {
    b[i][i] = 1;
    for (int j = 1; j <= n; ++j) {
      if (i == j) {
        r[i][j] = (2 * m - d[i]) * p_n % kMod;
      } else if (l[i][j]) {
        r[i][j] = p_n;
      }
    }
  }
  for (int i = k; i; i >>= 1) {
    if (i & 1) {
      M(r, b);
      copy(&c[1][1], &c[n][n] + 1, &b[1][1]);
    }
    M(r, r);
    copy(&c[1][1], &c[n][n] + 1, &r[1][1]);
  }
  for (int i = 1; i <= n; ++i) {
    LL s = 0;
    for (int j = 1; j <= n; ++j) {
      s = (s + a[j] * b[j][i]) % kMod;
    }
    cout << s << endl;
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<long long> A(N);
    for (auto& x : A) {
        cin >> x;
    }
    vector<long long> low(N);
    for (int i = 0; i < N; ++i) {
        low[i] = A[i] - (i + 1);
    }
    while (Q--) {
        long long K;
        cin >> K;
        const int idx = lower_bound(low.begin(), low.end(), K) - low.begin();
        if (idx == N) {
            cout << A[N - 1] + (K - low[N - 1]) << '\n';
        } else {
            cout << A[idx] - (low[idx] - K + 1) << '\n';
        }
    }
    return 0;
}

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using IntPair = pair<int, int>;
using ULLPair = pair<ULL, ULL>;

#define scast static_cast
#define repeat( itr, init, count ) \
for ( LL itr = ( init ); itr < ( count ); ++itr )
#define repeatu( itr, init, count ) \
for ( ULL itr = ( init ); itr < ( count ); ++itr )

ULL CountOverNums( const vector<ULL> *A, ULL key )
{
	auto itr = upper_bound( A->begin(), A->end(), key );
	if ( itr == A->end() )
	{
		return scast<ULL>( A->size() );
	}
	// else

	size_t pos = distance( A->begin(), itr );

	ULL count = scast<ULL>( pos );
	if ( *itr == key ) { count++; }
	return count;
}

int main()
{
	int N, Q;
	cin >> N >> Q;

	// 1, 2, 3, ...
	vector<ULL> A;
	A.resize( N );

	ULL startNum = 0;
	{
		ULL tmp;
		ULL sliceLeft = 0;
		repeatu( i, 0, N )
		{
			cin >> tmp;

			if ( startNum+1 == tmp )
			{
				startNum++;
			}

			A[i] = tmp - sliceLeft;
			sliceLeft++;
		}
	}

	vector<ULL> K;
	K.resize( Q );
	{
		ULL tmp;
		repeatu( i, 0, Q )
		{
			cin >> tmp;
			// K[i] = startNum + tmp + CountOverNums( &A, tmp );
			K[i] = tmp + CountOverNums( &A, tmp );
		}
	}

	repeatu( i, 0, Q )
	{
		cout << K[i] << endl;
	}

	//int _pause_thread_ = 0; cin >> _pause_thread_;
	return 0;
}


    #include <bits/stdc++.h>

    #define IOS         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    typedef long long      ll;
    #define rep(i,n)     for(int i=0;i<n;i++)
    #define gcd(a,b)       __gcd(a,b)
    #define lcm(a,b)	(a*b)/gcd(a,b)
    #define mem1(a)        memset(a,-1,sizeof(a))
	#define mem0(a)        memset(a,0,sizeof(a))
    #define vint        vector<int>
    #define pb            push_back
    #define pf            push_front
    #define ppb         pop_back
    #define all(v)      v.begin(),v.end()
    #define pii         pair<int,int>
    #define pic         pair<int,char>
    #define fr            first
    #define sc         second
    #define mp         make_pair
    #define inarr(a,n)	for(ll i=0;i<n;i++)cin>>a[i];
    #define PI   		3.1415926535897
    #define time_passed	1.0 * clock() / CLOCKS_PER_SEC
    using namespace std;

    double power(double a,int b) {if(b==0){return 1;}else if(b%2==0){return power(a*a,b/2);}else if(b%2==1){return a*power(a*a,(b-1)/2);}}
	//bool cmp(a[l] , a[r]){return b[1][l]<b[1][r];}
	template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
	template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
	template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
	template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}

 	double f(double x,double Nu,double k){return power(x,k)-Nu;}
	double fd(double x,double Nu,double k){return k*pow(x,k-1);}
	double root(int Nu,int k){double ans=9;for(int i=1;i<20;i++){ans=ans-f(ans,Nu,k)/fd(ans,Nu,k);cout<<ans<<" ";}return ans;}

	const ll mod=power(2,32);
	const int N=3e5+5;
	const ll inf=1e9+7;
 	int dy[]={-1,0,1,0};
 	int dx[]={0,1,0,-1};
 	vector <int >adj[N];
 	//int vis[201][201];
 	//int  dist[N];

    void love_for_infinity()
    {
    	float a,b,c,d;
    	cin>>a>>b>>c>>d;
    	cout<<fixed<<(b*(c-a)/(d+b))+a<<setprecision(9);

	}

    int main()
    {    IOS
    	//freopen("input.txt", "r", stdin);
	    //freopen("output.txt", "w", stdout);
	    #ifdef SIEVE
	    sieve();
	    #endif
	    #ifdef NCR
	    init();
	    #endif
        ll t;t=1;//cin>>t;
        while(t--){love_for_infinity();cout<<endl;}
        return 0;
    }

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,x,n) for(int i = x;i <= n;++i)
#define forr(i,x,n) for(int i = n;i >= x;--i)
#define Angel_Dust ios::sync_with_stdio(0);cin.tie(0)

int main()
{
    int a,b;scanf("%d%d",&a,&b);
    printf("%.18lf\n",a * b / 100.0);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin>>n; vector<int> a(n), b(n); for(int& x: a) cin>>x; for(int&x : b) cin>>x; int res = 0; for(int i = 0; i < n; i++) res += a[i] * b[i]; cout<<(res == 0 ? "Yes\n" : "No\n");
}

#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define REP(i,a,b) for (auto i = a; i != b; i++)
#define maxheap priority_queue < ll, std::vector<ll>, std::less<ll> >
#define minheap priority_queue < ll, std::vector<ll>, std::greater<ll> >   // mxheap.push(), mxheap.top(), mxheap.pop()
#define ll long long int
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pb push_back
#define SQ(a) (a)*(a)

using namespace std;
// using namespace FastIO;
void read(int n,vector<int>& x)
{
    x.clear();
    x.resize(n);
    for(int i = 0;i<n;i++)
    {
        cin>>x[i];
    }

}
void read(int n,int m,vector<vector<int>>& x)
{
    x.clear();
    x.resize(n,vector<int>(m));
    for(int i = 0;i<n;i++)
    {
        for(int j = 0 ;j<m;j++)
            cin>>x[i][j];
    }
}
void read(int n,vector<vector<int>>& x)
{
    x.clear();
    x.resize(n+1);
    for(int i = 0;i<n-1;i++)
    {
         int a,b;
         cin>>a>>b;
         x[a].pb(b);
         x[b].pb(a);
    }
}
void read(int n,vector<vector<int>>& x,int m)
{
    x.clear();
    x.resize(n+1);
    for(int i = 0;i<m;i++)
    {
         int a,b;
         cin>>a>>b;
         x[a].pb(b);
         x[b].pb(a);
    }
}
void read(int n,vector<ll>& x)
{
    x.clear();
    x.resize(n);
    for(int i = 0;i<n;i++)
    {
        cin>>x[i];
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    int T = 1;
    // freopen("mixmilk.in", "r", stdin);
    // freopen("mixmilk.out", "w", stdout);
    //cin>>T;
    for(int t = 1;t<=T;t++)
    {
        // cout<<"Case #"<<t<<": ";
        int n,m;
        cin>>n;
        vector<int> a;
        vector<int> b;
        read(n,a);
        read(n,b);
        ll sum = 0;
        for(int  i = 0;i<n;i++){
            sum += a[i] * b[i];
        }
        if(sum == 0){
            cout<<"Yes"<<endl;
        }
        else
            cout<<"No"<<endl;

    }

    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define pb push_back

#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>

#define all(a) a.begin(), a.end()
#define sz(a) a.size()

const int mod=998244353;
using namespace std;

void solve()
{
    int n;
    cin >> n;
    vi w(n + 1);
    int summ = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> w[i];
        summ += w[i];
    }

    if (summ % 2==1)
        cout << 0;
    else
    {
        summ /= 2;
        vi fact(n + 1);
        fact[0] = 1, fact[1] = 1;

        for (int i = 2; i <= n; i++)
        {
            fact[i] = i * fact[i - 1];
            fact[i] %= mod;
        }

        int ans = 0, curr;

        viii dp(n + 1, vii(summ + 1, vi(n + 1, 0)));

        dp[0][0][0] = 1;
        for (int i = 1; i <= n; i++)
        {
            for (int j = 0; j <= summ; j++)
            {
                for (int k = 0; k <= i; k++)
                {
                    dp[i][j][k] = dp[i - 1][j][k];
                    dp[i][j][k] %= mod;
                    if (w[i] <= j && k > 0)
                    {
                        dp[i][j][k] += dp[i - 1][j - w[i]][k - 1];
                        dp[i][j][k] %= mod;
                    }
                    if (i == n && j == summ)
                    {
                        curr = dp[i][j][k] * fact[k];
                        curr %= mod;
                        curr = curr * fact[n - k];
                        curr %= mod;
                        ans += curr;
                        ans %= mod;
                    }
                }
            }
        }
        cout << ans;
    }
}

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using std::sort;
using std::cout;
using std::endl;
using std::max;
using std::min;

inline int read(){
	int h=0;char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')h=(h<<1)+(h<<3)+c-'0',c=getchar();
	return h;
}

const int p=998244353;
inline int add(int x,int y){return x+y>=p?x+y-p:x+y;}
//long long ksm()/
const int MAXN=110;
int n;
int f[2][110][11111];
int nw=0,lst=1;
//前i个物品，A有j个，B有i-j个，A-B为w的方案数。

int id(int x){return x+5001;}
int a[MAXN];
long long jc[MAXN];
//int jcn[MAXN];

int main(){
	jc[0]=1;for(int i=1;i<=100;i++)jc[i]=jc[i-1]*i%p;
	n=read();for(int i=1;i<=n;i++)a[i]=read();
	f[0][0][id(0)]=1;
	for(int i=1;i<=n;i++){
		std::swap(nw,lst);
		memset(f[nw],0,sizeof(f[nw]));
		for(int j=0;j<=i;j++){
			for(int d=-5000;d<=5000;d++){
				if(d+a[i]<=5000)f[nw][j+1][id(d+a[i])]=add(f[nw][j+1][id(d+a[i])],f[lst][j][id(d)]);
				if(d-a[i]>=-5000)f[nw][j][id(d-a[i])]=add(f[nw][j][id(d-a[i])],f[lst][j][id(d)]);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++){
		ans=(ans+f[nw][i][id(0)]*jc[i]%p*jc[n-i])%p;
	}
	printf("%d\n",ans);
	return 0;
}


    # include <bits/stdc++.h>
    #define rep(i,l,r)for(int i=(l);i<(r);i++)
    # define rrep(i,r,l) for(int i=(r); i>=l; --i)
    # define ALL(x) (x).begin(), (x).end()
    # define SZ(x) ((int)(x).size())
    # define pb push_back
    # define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
    using namespace std;
    typedef long long lint;
    template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    #define INF ((1LL<<62)-(1LL<<31)) /*オーバーフローしない程度に大きい数*/
    #define MOD 1000000007
    lint gcd(lint a,lint b){
        if(!b)return a;
        return gcd(b,a%b);
    }

    lint lcm(lint a,lint b){
        return a*b/gcd(a,b);
    }
    struct node{
        int parent,cost;
    };

    bool comp(pair<lint,lint> p,pair<lint,lint> q){
        return p.first-p.second > q.first - q.second;
    }

    void solve() {
        lint N;
        cin >> N;
        vector<pair<lint,lint>> A(N);
        lint tmp =0;
        rep(i,0,N){
            lint a,b;
            cin >> a >> b;
            A[i].first=a+b;
            A[i].second=-a;
            tmp+=A[i].second;
        }

        sort(A.begin(),A.end(),comp);
        lint ans=0;
        int i=0;
        while(tmp<=0){
            tmp+=A[i].first-A[i].second;
            i++;
            ans++;
        }

        cout << ans << endl;
    }

    signed main() {

        solve();

        return 0;
    }

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
  return 2 * a.first + a.second > 2 * b.first + b.second;
}

int main() {
  int N;
  ll a, b, sumA = 0, sumB = 0;
  vector<pair<ll, ll>> C;

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a >> b;
    sumA += a;
    C.emplace_back(a, b);
  }
  sort(C.begin(), C.end(), comp);

  int ans = 0;
  for (auto[a, b]: C) {
    if (sumB > sumA) break;
    sumB += a + b;
    sumA -= a;
    ans++;
  }

  cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<21-a-b-c;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mem(a,val) memset(a,(val),sizeof((a)))
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define decimal(n)  cout << fixed ; cout << setprecision((n));
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define all(v) v.begin(), v.end()
#define endl "\n"
#define lcm(m,n) (m)*((n)/__gcd((m),(n)))
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(ll (i)=1;(i)<(n);(i)++)
#define repa(i,n,a) for(ll (i)=(a);(i)<(n);(i)++)
#define repr(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define pll pair<ll,ll>
#define pii pair<int, int>
#define mll map<ll,ll>
#define vll vector<ll>
#define sz(x) (ll)x.size()
#define ub upper_bound
#define lb lower_bound
#define pcnt(x) __builtin_popcountll(x)
const long long N=1e9;
const long long NN=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;
template<typename T,typename T1>T maxn(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T minn(T &a,T1 b){if(b<a)a=b;return a;}

void solve()
{
  //code begins from here//
  ll a,b,c;
  cin>>a>>b>>c;
  ll ans=21-a-b-c;
  cout<<ans;
}

signed main()
{
FAST
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int testcase=1;
//cin>>testcase;
while(testcase--) solve();
return 0;
}


//~ author      : Sumit Prajapati
#include <bits/stdc++.h>
using namespace std;

#define ull                 unsigned long long
#define ll                  long long
#define int                 long long
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pb                  push_back
#define mk                  make_pair
#define ff                  first
#define ss                  second
#define all(a)              a.begin(),a.end()
#define trav(x,v)           for(auto &x:v)
#define rep(i,n)            for(int i=0;i<n;i++)
#define repe(i,n)           for(int i=1;i<=n;i++)
#define read(a,n)           rep(i,n)cin>>a[i]
#define reade(a,n)          repe(i,n)cin>>a[i]
#define FOR(i,a,b)          for(int i=a;i<=b;i++)
#define printar(a,s,e)      FOR(i,s,e)cout<<a[i]<<" ";cout<<'\n'
#define curtime             chrono::high_resolution_clock::now()
#define timedif(start,end)  chrono::duration_cast<chrono::nanoseconds>(end - start).count()

auto time0 = curtime;
const int MD=1e9+7;
const int MDL=998244353;
const int INF=1e9;
const int MX=1e6+2;

int LPF[MX];
int mobius[MX];
int ffR[MX];
int ffL[MX];
int l,r;

void init(){
   for (int i = 2; i < MX; i++)

        // If it is a prime number
        if (!LPF[i])

            for (int j = i; j < MX; j += i)

                // For all multiples which are not
                // visited yet.
                if (!LPF[j])
                    LPF[j] = i;

    mobius[1]=1LL;
    for (int i = 2LL; i < MX; i++) {
        if (LPF[i / LPF[i]] == LPF[i])
            mobius[i] = 0;
        else
            mobius[i] = -1LL * mobius[i / LPF[i]];

    }
    for(int i=1LL;i<MX;i++)
        for(int j=i;j<MX;j+=i){
            ffR[j]+=(mobius[i]*(r/i));
            ffL[j]+=(mobius[i]*((j-1)/i));
        }

}

int count(int x){
    int divis=r/x;
    // cout<<divis<<" "
    // 7-(1+1)
    // 7 8 9 10 5-(5+())
    return (r-x+1LL)-(divis+ffR[x]-ffL[x]);
}

void solve(){

    int ans=0;
    cin>>l>>r;
    init();
    for(int x=max(2LL,l);x<=r;x++){
        // cout<<x<<" -> "<<ffL[x]<<" "<<ffR[x]<<" "<<count(x)<<'\n';
        ans+=count(x);
    }
    ans<<=1LL;
    cout<<ans<<'\n';

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    time0 = curtime;
    srand(time(NULL));
    int t=1;
    // cin>>t;
    repe(tt,t){
        // cout<<"Case #"<<tt<<": ";
        solve();
    }

    cerr<<"Execution Time: "<<timedif(time0,curtime)*1e-9<<" sec\n";
    return 0;

}

#include <cstdio>
#include <algorithm>
#define int long long
const int N = 1000005;
int l, r, f[N], ans;
signed main() {
    scanf("%lld%lld", &l, &r);
    for(int i = r; i >= 1; i--) {
        int an = r/i - (l-1)/i;
        f[i] = an * an;
        for(int j = i+i; j <= r; j += i) f[i] -= f[j];
    }
    for(int i = 2; i <= r; i++) {
        ans += f[i];
        if(i >= l) ans -= 2*(r/i - (l-1)/i) - 1;
    }
    printf("%lld", ans);
    return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define irep(i,a,b) for(int i=int(a);i<(int)b;++i)
#define rrep(i,a,b) for(int i=int(a);i>=(int)b;--i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll,ll>>>
#define vpl vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define pb push_back
#define se second
#define fi first
#define all(v) v.begin(),v.end()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>

using namespace std;

template<typename T> istream& operator>>(istream&i,v(T)&v){rep(j,v.size())i>>v[j];return i;}
template<typename T> string join(const v(T)&v){stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T> ostream& operator<<(ostream&o,const v(T)&v){if(v.size())o<<join(v);return o;}

using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

const ll mod = 1e9 + 7; //998244353;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll modpow(ll a,ll b){
    if(b == 0){
        return 1;
    }
    if(b%2 == 0){
        ll tmp = modpow(a,b/2);
        return tmp*tmp%mod;
    }else{
        return modpow(a,b-1)*a%mod;
    }

}

vvl g;
vl a;
bool done[1000000];
ll dp[1000000];
ll dfs(ll x){
    if(done[x])return dp[x];
    done[x] = true;
    ll num = -INF;
    for(ll k : g[x]){
        ll tmp = max(a[k],dfs(k));
        chmax(num,tmp);
    }
    return dp[x] = num;
}

int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    g.resize(n);
    a.resize(n);
    cin >> a;
    rep(i,m){
        int x,y;
        cin >> x >> y;
        --x;--y;
        g[x].pb(y);
    }
    ll ans = -INF;
    rep(i,n){
        ll benefit = dfs(i)-a[i];
        chmax(ans,benefit);
    }

    cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using Graph = vector<vector<int>>;
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 998244353;
int main() {
    //cout << std::fixed << std::setprecision(15) ;
    bool frg = false;
    vector<int> data(4);
    for(int i=0;i<4;i++){
        cin >> data[i];
    }
    // vector で取り込めばsortを使用できるので圧倒的にこちらの解答の方が楽
    sort(data.begin(),data.end());
    // sort するのでif文だけでできる
    if(data[0]+data[3]==data[2]+data[1]||data[0]+data[2]==data[1]+data[3]||data[3]==data[0]+data[1]+data[2]) frg = true;

    if(frg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <vector>
#include <list>
#include <cmath>
#include <deque>
#include <utility>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <string>
#include <stack>
#include <set>
#include <functional>
#include <iterator>
#include <algorithm>

using namespace std;

typedef long long ll;

class UnionFind {
private:
    vector<int> f;
    int _components;
public:
    explicit UnionFind(int sz): f(sz), _components(sz) {
        for (int i = 0; i < sz; i++) {
            f[i] = i;
        }
    }

    int find(int x) {
        if (x == f[x]) return x;
        int fa = f[x];
        return f[x] = find(fa);
    }

    void add(int x, int y) {
        int fx = find(x), fy = find(y);
        if (fx != fy) {
            _components--;
        }
        f[fx] = fy;
    }
    int components() const {
        return _components;
    }
};

ll gcd(ll a, ll b) {
    if (b == 0)return a;
    else return gcd(b, a%b);
}

int main(int argc, char *argv[]) {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    ll n;
    cin >> n;
    vector<int> digits;
    while (n > 0) {
        digits.push_back(n % 10);
        n/=10;
    }
    reverse(digits.begin(), digits.end());

    int r = digits.size() - 1;
    while (r >= 0 && digits[r] == 0) {
        r--;
    }

    bool flag = true;
    int l = 0;
    while (l < r) {
        if (digits[l] != digits[r]) {
            flag = false;
            break;
        } else {
            l++;
            r--;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;

#define debug(x) cout << #x << " is " << x << endl
typedef long long ll;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;

int n, ans;
string S, T;
vector<int> a, b;

int main()
{
	cin >> n;
	cin >> S >> T;
	for (int i = 0; i < n; ++i) {
		if (S[i] == '0') a.push_back(i);
		if (T[i] == '0') b.push_back(i);
	}
	if (a.size() != b.size()) { puts("-1"); return 0; }
	for (int i = 0; i < (int)a.size(); ++i) {
		if (a[i] == b[i]) continue;
		if (a[i] < b[i]) {
			ans++;
		}
		else if (a[i] > b[i]) {
			ans++;
		}
	}
	printf("%d\n", ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define irreps(i, m, n) for (int i = ((int)(n)-1); i > (int)(m); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) (int)(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;
using ld = long double;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

const ll INF = 1e9+10;
// const ll MOD = 1e9+7;
const ll MOD = 998244353;
const ll LINF = 1e18;

// 以下の操作が行える時、SをTに一致させられるか
// 011..1 :0が連続している区間から始めて登場する1とswap
// 11..10 :逆
// まずこの操作によってある0（1でもよい）は任意の場所に移動できると気付く
// 正確には、0001100みたいに先頭から0が3個、1が2個、0が2個みたいな情報が与えられたとき、0，1の個数が一致するなら必ずそれが作れるということ
// 以下は0，1の個数が一致する場合
// s,tの0のindexをリスト化する(a,bとする)
// a[i]!=b[i]なら、明らかにs[a[i]]はいずれかの1とswapする必要があるが、この時aの他の要素が変化することはない（swapするのは1なので）
// 上記から、少なくともa[i]!=b[i]の個数だけ操作する必要があるとわかる
// どのような場合でも最適に操作すれば、上の個数回だけの操作で一致させられるか？ => 可能
// 今いくつかa[i]!=b[i]であるようなiが存在するとする
// 今移動させられるiとswapできるs[x]==1 && s[x]!=t[x]なるindex xが存在するはずで、これを適切な組合せと順序でswapしていけば（端から処理するイメージ）よい
// s=10111001
// t=01011011
// 上の例なら、今a[0]=1を見ているなら、x=0(前方)となる
// a[i]!=b[i]なるiが存在していて、1手で操作できる範囲にxが存在しないということは有り得ない
// s=101
// t=?1?
// （a,bの長さが一致するなら、0,2のいずれかは0である）tの0,2いずれを0にするとしても必ず s,tは1手で一致させられる

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );

  int n; cin>>n;
  string s,t; cin>>s>>t;

  vc<int> a,b;
  rep(i,n) {
    if(s[i]=='0') a.push_back(i);
    if(t[i]=='0') b.push_back(i);
  }

  if(a.size()!=b.size()) {
    cout<<-1<<endl;
    return 0;
  }

  int ans=0;
  rep(i,a.size()) if(a[i]!=b[i]) ans++;
  cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
template<typename T = int, T mod = 1'000'000'007, typename U = long long>
struct umod{
    T val;
    umod(): val(0){}
    umod(U x){ x %= mod; if(x < 0) x += mod; val = x;}
    umod& operator += (umod oth){ val += oth.val; if(val >= mod) val -= mod; return *this; }
    umod& operator -= (umod oth){ val -= oth.val; if(val < 0) val += mod; return *this; }
    umod& operator *= (umod oth){ val = ((U)val) * oth.val % mod; return *this; }
    umod& operator /= (umod oth){ return *this *= oth.inverse(); }
    umod& operator ^= (U oth){ return *this = pwr(*this, oth); }
    umod operator + (umod oth) const { return umod(*this) += oth; }
    umod operator - (umod oth) const { return umod(*this) -= oth; }
    umod operator * (umod oth) const { return umod(*this) *= oth; }
    umod operator / (umod oth) const { return umod(*this) /= oth; }
    umod operator ^ (long long oth) const { return umod(*this) ^= oth; }
    bool operator < (umod oth) const { return val < oth.val; }
    bool operator > (umod oth) const { return val > oth.val; }
    bool operator <= (umod oth) const { return val <= oth.val; }
    bool operator >= (umod oth) const { return val >= oth.val; }
    bool operator == (umod oth) const { return val == oth.val; }
    bool operator != (umod oth) const { return val != oth.val; }
    umod pwr(umod a, U b) const { umod r = 1; for(; b; a *= a, b >>= 1) if(b&1) r *= a; return r; }
    umod inverse() const {
        U a = val, b = mod, u = 1, v = 0;
        while(b){
            U t = a/b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        if(u < 0)
            u += mod;
        return u;
    }
};
using U = umod<int, 998244353>;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	if(max(n, m) == 1){
		cout << k << '\n';
		return 0;
	}
	if(min(n, m) == 1){
		cout << (U(k) ^ (max(n, m))).val << '\n';
		return 0;
	}
	if(n > m) swap(n, m);
	vector<U> ways_n(k + 1);
	for(int i = 1; i <= k; i++){
		ways_n[i] = (U(i) ^ n) - (U(i - 1) ^ n);
	}
	vector<U> fat(m + 1), ifat(m + 1);
	fat[0] = 1;
	for(int i = 1; i <= m; i++){
		fat[i] = fat[i - 1] * i;
	}
	for(int i = 0; i <= m; i++){
		ifat[i] = U(1) / fat[i];
	}
	auto ncr = [&](int n, int r){
		if(n < r) return U(0);
		if(n == r || r == 0) return U(1);
		return fat[n] * ifat[r] * ifat[n - r];
	};
	U ans = 0;
	for(int i = 1; i <= k; i++){
		// cout << i << ' ' << ways_n[i].val << ' ' << (U((k - i + 1)) ^ m).val << '\n';
		ans +=  ways_n[i] * (U((k - i + 1)) ^ m);
	}
	cout << ans.val << '\n';
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
    int T=1, caseIdx=0;
    //cin >> T;
    while (T--) {
        caseIdx++;
        long r, x, y, ans=0;
        cin >> r >> x >> y;
        double d = sqrt(x*x + y*y);
        ans = ceil(d/r);
        if (ans==1 && d != r)
		    ++ans;
        cout << ans << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)

int main(){
    int n;
    string s;
    int q;
    cin >> n;
    cin >> s;
    cin >> q;
    vector<int> T(q);
    vector<int> A(q);
    vector<int> B(q);
    rep(i, q){
        cin >> T[i] >> A[i] >> B[i];
    }
    rep(i, q - 1){
        if (T[i] == 2 && T[i + 1] == 2){
            T[i] = -1;
            T[i + 1] = -1;
            i++;
        }
    }

    rep(i, q){
        if (T[i] == 1){
            char tmp = s[A[i] - 1];
            s[A[i] - 1] = s[B[i] - 1];
            s[B[i] - 1] = tmp;
        }
        else if (T[i] == 2){
            string s1, s2;
            s1 = s.substr(n);
            s2 = s.substr(0, n);
            s = s1 + s2;
        }
        else continue;
    }
    cout << s << endl;
}

/*Jai Shree Ram*/
// Never Give Up

#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define F(i,s,e,j)        for(int i=s;i<=e;i+=j)
#define mt19937                 rng(chrono::steady_clock::now().tjhe_since_epoch().count());
//shuffle(arr,arr+n,rng)
/*---------------------------------------------------------------------------------------------------------------------------*/
int gcd(int a, int b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
int expo(int a, int b,int m) {int res = 1; while (b > 0) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b = b >> 1;} return res;}
void extendgcd(int a, int b, int*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); int x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size1 3
int mminv(int a, int b) {int arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
int mminvprime(int a, int b) {return expo(a, b - 2, b);}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
int combination(int n, int r, int m, int*fact, int *ifact) {int val1 = fact[n]; int val2 = ifact[n - r]; int val3 = ifact[r]; return (((val1 * val2) % m) * val3) % m;}
void google(int t) {cout << "Case #" << t << ": ";}
vi sieve(int n) {int*arr = new int[n + 1](); vi vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
int mod_add(int a, int b, int m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
int mod_mul(int a, int b, int m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
int mod_sub(int a, int b, int m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
int mod_div(int a, int b, int m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;}  //only for prime m
int phin(int n) {int number = n; if (n % 2 == 0) {number /= 2; while (n % 2 == 0) n /= 2;} for (int i = 3; i <= sqrt(n); i += 2) {if (n % i == 0) {while (n % i == 0)n /= i; number = (number / i * (i - 1));}} if (n > 1)number = (number / n * (n - 1)) ; return number;} //O(sqrt(N))
/*--------------------------------------------------------------------------------------------------------------------------*/
 void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
 int32_t main()
{   c_p_c();
    int n;
    cin>>n;
    string str;
    cin>>str;
    string a = str.substr(0,n);
    string b = str.substr(n,n);

    w(q)
    {
    	int t,l,r;
    	cin>>t>>l>>r;
    	l--;
    	r--;
    	if(t==2)
    	 {
    	 	 swap(a,b);
    	 }
    	else
    	{
    		if(l<n && r<n)
              swap(a[l],a[r]);
            else if(l>=n && r>=n)
            	swap(b[l-n],b[r-n]);
            else
            {
            	swap(a[l],b[r-n]);
            }
    	}
    }
     str = a+b;
    cout<<str<<endl;
}


#include<bits/stdc++.h>
 using namespace std;

   int m1(int n)
   {
   string s;
   s=to_string(n);
   sort(s.begin(),s.end());
   n=stoi(s);

   return(n);
   }

  int m2(int n)
  {
     string s2;
     s2=to_string(n);
     sort(s2.begin(),s2.end(),greater<int>());
     n=stoi(s2);

      return(n);
  }

  int main(){
      int x,y,z,i,k;
      scanf("%d %d",&x,&k);
      for(i=0;i<k;i++)
  {
      y=m1(x);
      z=m2(x);

      x=z-y;
  }
     printf("%d",x);

 return(0);
 }

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  set<int> st1, st2;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    st1.insert(a);
  }
  for (int i = 0; i < m; i++) {
    int b;
    cin >> b;
    st2.insert(b);
  }

  vector<int> ans;
  for (auto i : st1) {
    if (st2.find(i) == st2.end()) ans.emplace_back(i);
  }
  for (auto i : st2) {
    if (st1.find(i) == st1.end()) ans.emplace_back(i);
  }

  sort(ans.begin(), ans.end());

  for (int i = 0; i < ans.size(); i++) {
    if (i) cout << " ";
    cout << ans.at(i);
  }
  cout << '\n';
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,1,0,-1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
  return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
  return ((a > b) ? (a = b, true) : (false));
}

int main(){
  ll n;cin >> n;
  string s;cin >> s;
  vl a(n+1);rep(i,n+1)cin >> a[i];
  ll k=inf;rep(i,n)chmin(k,abs(a[i+1]-a[i]));
  cout << k <<endl;
  vvl mat(k,vl(n+1));
  vl use(n+1);
  rep(i,k){
    rep(j,n+1){
      mat[i][j]=a[j]/k;
      use[j]+=a[j]/k;
    }
  }
  rep(i,n+1)a[i]-=use[i];
  rep(i,n+1){
    rep(j,a[i]){
      mat[j][i]++;
    }
  }
  rep(i,k){
    rep(j,n+1)cout << mat[i][j] <<" ";cout << endl;
  }
}

#include <bits/stdc++.h>
#define PRINT(x) cerr<<#x<<'='<<x<<endl
#define NL(x) " \n"[(x)]
#define sz(x) int((x).size())
#define all(x) begin(x),end(x)
#define mid (l+r)/2
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define lld long long
#define pii pair<int,int>
#define pli pair<lld,int>
#define pil pair<int,lld>
#define pll pair<lld,lld>
#define INF 1000000000
#define LINF 1000000000000000000LL
#define EPS 1e-9
using namespace std;
#define MAXN 200010
lld X[MAXN], Y[MAXN];
lld sgnX[MAXN], sgnY[MAXN];
lld koefX[MAXN], koefY[MAXN];
lld flipped[MAXN];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int N; cin >> N;
    for(int i = 1; i <= N; i++) cin >> X[i] >> Y[i];
    sgnX[0] = sgnY[0] = 1;
    koefX[0] = koefY[0] = 0;
    flipped[0] = 0;
    int M; cin >> M;
    for(int i = 1; i <= M; i++) {
        int tip; cin >> tip;
        if(tip == 1) {
            koefX[i] = koefY[i-1]; koefY[i] = -koefX[i-1];
            sgnX[i] = sgnY[i-1]; sgnY[i] = -sgnX[i-1];
            flipped[i] = 1^flipped[i-1];
        } else if(tip == 2) {
            koefX[i] = -koefY[i-1]; koefY[i] = koefX[i-1];
            sgnX[i] = -sgnY[i-1]; sgnY[i] = sgnX[i-1];
            flipped[i] = 1^flipped[i-1];
        } else if(tip == 3) {
            lld p; cin >> p;
            koefY[i] = koefY[i-1]; sgnY[i] = sgnY[i-1];
            koefX[i] = 2*p-koefX[i-1]; sgnX[i] = -sgnX[i-1];
            flipped[i] = flipped[i-1];
        } else if(tip == 4) {
            lld p; cin >> p;
            koefX[i] = koefX[i-1]; sgnX[i] = sgnX[i-1];
            koefY[i] = 2*p-koefY[i-1]; sgnY[i] = -sgnY[i-1];
            flipped[i] = flipped[i-1];
        }
    }
    int Q; cin >> Q;
    for(int i = 1; i <= Q; i++) {
        int A, B; cin >> A >> B;

        cout << sgnX[A]*(flipped[A] ? Y[B]:X[B]) + koefX[A] << ' ' << sgnY[A]*(flipped[A] ? X[B]:Y[B]) + koefY[A] << endl;
    }
    return 0;
}


//g++ -std=gnu++14 a.cpp
// ./compile_run.sh

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >=0; i--)
#define P pair<ll,ll>
#define pb push_back
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;
//const ll M = MOD;

template<typename __T__>
int len(vector<__T__> x){
  return int(x.size());
}

template<typename __T__>
void vecout(vector<__T__> x){
  rep(i, len(x)) cout << x[i] << " ";
  cout << endl;
}

ll lmax(ll x,ll y){
  if(x < y) return y;
  else return x;
}

ll lmin(ll x, ll y){
  if(x > y)return y;
  else return x;
}

ll gen(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x%MOD;
  if(y%2 == 1){
    return ((x%MOD)*gen(x,y-1)%MOD)%MOD;
  }else{
    ll res = gen(x,y/2)%MOD;
    return ((res%MOD)*(res%MOD))%MOD;
  }
}

ll Factorial(ll x,ll y){ //xのy乗
  if(y == 1) return x;
  if(y == 0) return 1;
  if(y%2 == 0){
    ll res = Factorial(x,y/2);
    return res*res;
  }else{
    return x*Factorial(x,y-1);
  }

}

ll gcd(ll x, ll y){
  if(x < y) swap(x,y);
  if(y == 0) return x;
  return gcd(y,x%y);
}

ll lcm(ll x,ll y){
  ll s = gcd(x,y);
  x /= s;
  y /= s;
  return x*y*s;
}

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll> a(n),b(n);
  rep(i,2*n){
    ll c = s.at(i) - 'A';
    if(i < n) a[i] = c;
    else b[i-n] = c;
  }

  ll q;
  cin >> q;
  rep(i,q){
    ll x,y,z;
    cin >> x >> y >> z;
    y--;
    z--;
    if(x == 1){
      ll na,nb;

      if(y < n) na = a[y];
      else na = b[y-n];

      if(z < n) nb = a[z];
      else nb = b[z-n];

      if(y < n) a[y] = nb;
      else b[y-n] = nb;

      if(z < n) a[z] = na;
      else b[z-n] = na;

    }else{
      swap(a,b);
    }
  }
  string ans = "";
  rep(i,2*n){
    char add;
    if(i < n) add = 'A'+a[i];
    else add = 'A'+b[i-n];
    ans += add;
  }
  cout << ans << endl;

}

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using PQ = priority_queue<T>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
constexpr ll dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
inline void Yes() { cout << "Yes" << ENDL; }
inline void No() { cout << "No" << ENDL; }
inline void YES() { cout << "YES" << ENDL; }
inline void NO() { cout << "NO" << ENDL; }

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T>
vector<T> finddivisor(T x) {  //整数xの約数(xを含む)
  vector<T> divisor;
  for(T i = 1; (i * i) <= x; i++) {
    if(x % i == 0) {
      divisor.push_back(i);
      if(i * i != x) { divisor.push_back(x / i);}
    }
  }
  sort(divisor.begin(), divisor.end());
  return divisor;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(auto&& x: vec) is >> x;
  return is;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}

template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,m;cin>>n>>m;
  V<int> a(m),b(m);
  map<Pi,int> id;
  V<int> dir(m,0);//1 ->
  rep(i,0,m){
    cin>>a[i]>>b[i];
    --a[i];--b[i];
    id[{a[i],b[i]}]=id[{b[i],a[i]}]=i;
  }
  V<ll> c(n);cin>>c;

  VV<int> e(n);
  rep(i,0,m){
    int x=a[i],y=b[i];
    if(c[x]>c[y])dir[i]=1;
    else if(c[x]<c[y])dir[i]=2;
    else{
      e[x].eb(y);
      e[y].eb(x);
    }
  }

  V<bool> used(n,false);
  auto dfs=[&](auto self,int now)->void{
    for(auto&& to:e[now]){
      if(dir[id[{now,to}]])continue;

      if(now==a[id[{now,to}]])dir[id[{now,to}]]=1;
      else dir[id[{now,to}]]=2;

      if(used[to])continue;
      used[to]=true;
      self(self,to);
    }
  };

  rep(i,0,n)if(!used[i]){
    used[i]=true;
    dfs(dfs,i);
  }

  rep(i,0,m){
    assert(dir[i]);
    if(dir[i]==1)cout<<"->"<<ENDL;
    else cout<<"<-"<<ENDL;
  }
}
//(・_・)(・_・)(・_・)(・_・)
//CHECK overflow,what to output?
//any other simpler approach?


#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <climits>
#include <string>
#include <cmath>
#include <stack>
#include <functional>
#include <list>
#include <array>
#include <queue>
#include <bitset>
#include <ciso646>
#include <fstream>
#include <string.h>
using namespace std;

#define db(x) cout << #x << " " << (x) << "\n";
const int mod1 = 1000000007;
const int mod2 = 1000000009;
#define inf LLONG_MAX
#define n_inf LLONG_MIN
#define all(x) x.begin(), x.end()
#define sorta(x) sort(all(x))
typedef long long int ll;
template<typename... T>
void read(T&... args)
{
    ((cin >> args), ...);
}
template<typename... T>
void write(T&&... args)
{
    ((cout << args << " "), ...);
}
#define w(t)       \
    int t;         \
    std::cin >> t; \
    while (t--)

#define FastIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

void solve(int test_case = 0)
{
    int n; cin>>n;
    vector<ll> A(n);
    for(int i=0; i<n; i++)
    {
        cin>>A[i];
    }
    ll curr = 0, max_inc = 0, last_inc = 0, max_possible = 0;
    for(int i=0; i<n; i++)
    {
        max_inc = max(max_inc, last_inc + A[i]);
        max_possible = max(max_possible, curr + max_inc);
        curr += last_inc + A[i];
        last_inc += A[i];
    }
    cout<<max_possible;

}

int main()
{
    FastIO;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    int test_case = 1, i = 0;
    //cin>>test_case;
    while (test_case--)
    {
        i++;
        solve(i);
    }
}

#include <bits/stdc++.h>

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.14159265359;

template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, Q; cin >> N >> Q;
    vl A(N); REP(i, N) cin >> A[i];
    vl K(Q); REP(i, Q) cin >> K[i];

    sort(ALL(A));
    vl s;
    vl t;
    t.pb(0);
    if(A[0] != 1)
    {
        s.pb(1);
        t.pb(A[0]-1);
    }
    REP(i, N-1)
    {
        if(A[i]+1 != A[i+1]) s.pb(A[i]+1), t.pb(A[i+1]-A[i]-1);
    }
    s.pb(A[N-1]+1);
    t.pb((ll)2e18);

    REP(i, (int)t.size()-1) t[i+1] += t[i];

    REP(i, Q)
    {
        int idx = lower_bound(ALL(t), K[i]) - t.begin() -1;
        cout << s[idx]+K[i]-1-t[idx] << endl;
    }
}