#include<bits/stdc++.h>

/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

//PBDS
/*
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

//PBDS_SET
//Index of Value - .order_of_key()
//Value at Index - .find_by_order()
/*
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_multiset;
*/

#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}

template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

 int a[N],par[N],cnt[N];
bool vis[N];
 int findroot(int u){
  if(u==par[u])return u;

  return par[u]=findroot(par[u]);
 }

 void merge(int u,int v){
  u=findroot(u);
  v=findroot(v);

  if(u!=v){
    par[u]=v;
    cnt[v]+=cnt[u];
  }
 }

int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){

      int n;
      Int(n);

      for(int i=1;i<=n;++i){
        Int(a[i]);
        par[a[i]]=a[i];
        cnt[a[i]]=1;
      }

      for(int i=1,j=n;i<j;++i,--j){
        if(a[i]!=a[j]){
          merge(a[i],a[j]);
        }
      }

      int res=0;
      for(int i=1,j=n;i<j;++i,--j){
        if(a[i]!=a[j]){
          int u=findroot(a[i]);

          if(!vis[u]){
            res+=cnt[u]-1;
            vis[u]=true;
          }
        }
      }
      printf("%d\n", res);

        //printf("Case %d: ",++te);
    }

    //cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

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

#define stp(var, init, end) for (auto var = init; var < end; ++var)
#define stpe(var, init, end) for (auto var = init; var <= end; ++var)
#define ll long long

int main(void)
{
    int n;
    ll input;
    cin >> n;
    vector<ll> a(n + 1);
    a[0] = 0;
    stp(i, 1, n + 1)
    {
        cin >> input;
        if (i % 2 == 0)
            a[i] = input;
        else
            a[i] = -input;
    }
    //累積和
    stp(i, 1, n + 1)
    {
        a[i] += a[i - 1];
    }
    sort(a.begin(), a.end());

    //累積和が等しい=和が0
    ll count = 1, ans = 0;
    stp(i, 1, n + 1)
    {
        if (a[i] == a[i - 1])
            ++count;
        else
        {
            if (count > 1)
                ans += count * (count - 1) / 2;
            count = 1;
        }
    }
    if (count > 1)
        ans += count * (count - 1) / 2;

    cout << ans;
    return 0;
}


 // God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

struct CRT
{
    ll n;
    vector < ll > m, r;

    void init()
    {
        m.clear();
        r.clear();
    }

    pll ext_euclid(ll a, ll b)
    {
        pll ret = {0,0};

        ll x1 = 0, y1 = 1;
        ll x2 = 1, y2 = 0;

        ll r3, r0;

        for(ll r1 = b, r2 = a; r1 ; r2 = r1, r1 = r3)
        {
            r0 = r2 / r1;
            r3 = r2 % r1;

            ll x3 = (x2 - (x1 * r0));
            ll y3 = (y2 - (y1 * r0));

            x2 = x1, y2 = y1;
            x1 = x3, y1 = y3;
        }

        return {x2,y2};
    }

    ll lcm(ll a, ll b)
    {
        ll ret = a / __gcd(a,b);
        return ret * b;
    }

    ll mul(__int128 a, __int128 b, __int128 m)
    {
        __int128 ret = ((a % m) * (b % m)) % m;

        return (long long) ret;
    }

    pll start()
    {
        ll r1 = r[0], m1 = m[0];
        ll n = m.size();

        for(ll i = 1; i < n; i++)
        {
            ll r2 = r[i], m2 = m[i];
            ll g = __gcd(m1,m2);

            if(r2 % g != r1 % g) return {-1,-1};

            pll ans = ext_euclid(m1/g,m2/g);

            ll md = lcm(m1,m2);

            ll x = (mul(mul(r2,m1/g,md),ans.first,md) + mul(mul(r1,m2/g,md),ans.second,md)) % md;

            r1 = x, m1 = md;

            if(r1 < 0) r1 += md;
        }

        return {r1,m1};
    }
};

ll solve()
{
	ll p, q, x, y;

	cin >> x >> y >> p >> q;

	CRT crt;

	ll ans = mxlld;

	for(ll i = x; i < x + y; i++)
	{
		for(ll j = p; j < (p + q); j++)
		{
			crt.init();

			crt.m.push_back(2 * (x + y));
			crt.m.push_back(p + q);

			crt.r.push_back(i);
			crt.r.push_back(j);

			pll ret = crt.start();

			if(ret.second == -1) continue;

			ans = min(ans, ret.first);

		}
	}

	if(ans == mxlld) return -1;

	return ans;

}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

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

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

    slld(testcase);

    for(ll cs = 1; cs <= testcase; cs++)
    {
		ans = solve();

		if(ans == -1) cout << "infinity\n";
		else cout << ans << "\n";
    }

}

#include <bits/stdc++.h>
using namespace std;
long long exgcd(long long a, long long b, long long &x, long long &y)
{
	if (!b)
	{
		x = 1, y = 0;
		return a;
	}
	long long ans = exgcd(b, a % b, y, x);
	y -= a / b * x;
	return ans;
}

long long solve(long long a, long long b, long long c)
{
	long long x, y, z;
	z = exgcd(a, b, x, y);
	if (c % z)
		return -1; //不成立
	//return x; //不需要最小正整数的话直接返回x
	x *= c / z;
	b = abs(b / z);
	return (x % b + b) % b;
}
int main()
{
	int T;
	cin >> T;
	while (T--)
	{
		long long x, y, p, q;
		cin >> x >> y >> p >> q;
		long long ans = INT64_MAX;
		for (long long yy = 0; yy < y; yy++)
		{
			for (long long qq = 0; qq < q; qq++)
			{
				long long d = solve(2 * x + 2 * y, p + q, p + qq - x - yy);
				if (d != -1)
				{
					ans = min(ans, d * (2 * x + 2 * y) + x + yy);
				}
			}
		}
		if (ans == INT64_MAX)
			cout << "infinity" << endl;
		else
			cout << ans << endl;
	}
	return 0;
}
/*
2(x+y)
x<=( [k(p+q)+p)   )%(2x+2y)<x+y

[ k*(2x+2y)+x,+x+y )
[ k(p+q)+p , k*(p+q)+p+q )

s*(2x+2y)+x+yy==t*(p+q)+p+qq
s*(2x+2y)-t*(p+q)=p+qq-x-yy;

ax+by=c

1499999999500000000
1000000000999999999
*/


//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>w(n);
  rep(i,0,n)cin>>w[i];
  ll mxw=*max_element(ALL(w));
  vector<P>p(m);
  rep(i,0,m){
    cin>>p[i].se>>p[i].fi;
    if(p[i].fi<mxw){
      cout<<-1<<endl;
      return 0;
    }
  }
  //荷重、長さ
  //p.EB(INF,INF);
  p.EB(0,0);
  sort(ALL(p));
  rep(i,0,(ll)p.size()-1){
    chmax(p[i+1].se,p[i].se);
  }
  //debug(p,p.size());
  vector<ll>v(n);
  iota(ALL(v),0);
  res=INF;
  do{
    vector<ll>pos(n);
    rep(i,1,n){
      ll nw=w[v[i]];
      ll mx=0;
      rrep(j,0,i){
        nw+=w[v[j]];
        P q=*(--lower_bound(ALL(p),MP(nw,0LL)));
        chmax(mx,q.se-(pos[i-1]-pos[j]));
      }
      pos[i]=pos[i-1]+mx;
    }
    /*if(is_sorted(ALL(v))){
      debug(v,3);debug(pos,3);cout<<endl;
    }*/
    chmin(res,pos[n-1]);
  }while(next_permutation(ALL(v)));
  cout<<res<<endl;
  return 0;
}

#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n, m, c[10], dl[10], vis[10], ans = 0x3f3f3f3f, lx[10], db[10];
struct judge {
    int l;
    int v;
};
judge a[100010];
bool tmp(judge x, judge y)
{
    if (x.l != y.l) return x.l < y.l;
    else return x.v > y.v;
}
int findl(int x)
{
    int b, e, t;
    b = 1, e = m, t = b + e >> 1;
    while (b < e)
    {
        if (a[t].v < x) b = t;
        else e = t - 1;
        t = b + e +1>> 1;
    }
    if (a[b].v >= x) return 0;
    return a[b].l;
}
void fact()
{
    memset(lx, 0, sizeof lx);
    for (int i = 1; i <= n; i++)
    {
        db[i] = db[i - 1] + c[dl[i]];
    }
    for (int i = 2; i <= n; i++)
        for (int j = 1; j < i; j++)
        {
            int l = findl(db[i] - db[j - 1]);
            lx[i] = max(lx[i], lx[j] + l);
        }
    ans = min(ans, lx[n]);
}
void dfs(int i)
{
    if (i == n + 1)
    {
        fact();
        return;
    }
    for (int j = 1; j <= n; j++)
    {
        if (!vis[j])
        {
            vis[j] = 1;
            dl[i] = j;
            dfs(i + 1);
            vis[j] = 0;
        }
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)  cin >> c[i];
    for (int i = 1; i <= m; i++)  cin >> a[i].l >> a[i].v;
    sort(a + 1, a + m + 1, tmp);
    for (int i = m - 1; i > 0; i--) a[i].v = min(a[i].v, a[i + 1].v);
    for (int i = 1; i <= n; i++) if (c[i] > a[1].v) { cout << -1; return 0; }
    dfs(1);
    cout << ans;
}


#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;

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fp(i,a,b) for(ll i=a ; i<b ; i++)
#define fn(i,a,b) for(int i=a ; i>=b ; i--)
#define ones(x) __builtin_popcount(x)
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define dbg(x) cout << (#x) << " = " << x << " "
#define fini cout << "\n";
#define line cout << "-----------------------------------\n";
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef tree<
ll,
null_type,
less_equal<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int read (){
    int x = 0, f = 1; char s = getchar();while (s < '0' || s > '9') {if (s == '-') f = -1; s = getchar();}
    while (s >= '0' && s <= '9') x = x * 10 + s - '0', s = getchar();
    return x * f;
}
const int M=1e2+7;
const int N=1e6+7;
const int inf=1e9;
const ll mod=1e9+7;
const ll mod2=2e9+11;

int a,b,w;
ll mn=inf,mx;

void go(int ide){
	cin >> a >> b >> w; w *= 1000;

	fp(i,1,1000001){
		if (a*i <= w && w <= b*i){
			mn = min(mn, i);
			mx = max(mx, i);
		}
	}

	if (mn == inf || !mx){
		cout << "UNSATISFIABLE\n"; return;
	}

	cout << mn << " " << mx << "\n";
}

int main(){
    fastio;
    int tst=1;
    // cin >> tst;
    // cout << fixed << setprecision(12);
    fp(i,0,tst) go(i+1);

    return 0;
}

#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;
#define ordered_set tree<int, null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update>
#define int long long int
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 998244353
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test int t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int32_t main()
{
    fastIO;
    ld a,b;
    cin>>a>>b;
    ld val=a/(ld)100;
    ld ans=val*b;
    cout<<fixed<<setprecision(10)<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n;
    t = 1;
    for(int i=0;i<t;i++)
    {
        int n,k,m;
        cin>>n>>k>>m;
        int req = n*m;
        int sum =0,x;
        for(int i=0;i<n-1;i++)
        {
            cin>>x;
            sum+=x;
        }
        int ans = max(req-sum,0);
        if(ans>k)
        {
            cout<<"-1";
        }
        else
        {
            cout<<ans;
        }
    }
    return 0;
}

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

int main() {
  int n,k,m,a,x;
  cin >> n >> k >> m;

  int sum = 0;
  for(int i = 0; i < (n -1); i++){
    cin >> a;
    sum += a;
  }

  x = m * n - sum;
  x = 0 > x ? 0 : x;
  x = k >= x ? x : -1 ;

  cout << x << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    ll N;
    cin >> N;
    vl E(2 * N, -1), id(2 * N, -1), used(2 * N), se(N), A(N), B(N);
    rep(i, N) {
        cin >> A[i] >> B[i];
        if (A[i] > 0) A[i]--, id[A[i]] = i, used[A[i]]++;
        if (B[i] > 0) B[i]--, id[B[i]] = i, used[B[i]]++;
        if (A[i] >= 0 and B[i] >= 0) se[i] = 1; // 始点終点が決まっている

        if((A[i] >= 0 and B[i] >= 0) and A[i] > B[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    rep(i, 2 * N){
        if(used[i] > 1){
            cout << "No" << endl;
            return 0;
        }
    }

    rep(i, N) {
        if (A[i] == -1 or B[i] == -1) continue;
        ll d = B[i] - A[i];
        repe(j, A[i], B[i] + 1) {
            if(!(E[j] == -1 or E[j] == d)){
                cout << "No" << endl;
                return 0;
            }
            E[j] = d;
        }
    }

    vl pass(2 * N + 1);
    pass[0] = 1;
    rep(i, 2 * N - 1){
        if (!pass[i]) continue;
        // 選ぶ人数
        repe(n, 1, N + 1){
            if (i + 2 * n > 2 * N) break;
            bool isok = true;
            rep(j, n){
                if(id[i + j] == -1 and id[i + j + n] == -1){
                    continue;
                }else if(id[i + j] == -1){
                    if (se[id[i + j + n]]) isok = false;
                }else if(id[i + j + n] == -1){
                    if (se[id[i + j]]) isok = false;
                }else{
                    if (id[i + j] != id[i + j + n]) isok = false;
                }
                if (!isok) break;
            }
            if (isok) pass[i + 2 * n] = 1;
        }
    }

    cout << (pass[2 * N] ? "Yes" : "No") << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cout << #x << ":\t" << x << endl;
const int N = 2e6 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
int n;
int a[N], b[N];
int dp[1010][1010], vis[1010];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int l, r;
		scanf("%d%d", &l, &r);
		if (l != -1 && r != -1 && r <= l) { puts("No"); return 0; }
		if (l != -1) {
			if (vis[l]) { puts("No"); return 0; }
			a[l] = r;
			vis[l] = 1;
		}
		if (r != -1) {
			if (vis[r]) { puts("No"); return 0; }
			b[r] = l;
			vis[r] = 1;
		}
	}
	n <<= 1;
	for (int len = 2; len <= n; len += 2) {
		for (int i = 1; i <= n - len + 1; i++) {
			int j = i + len - 1;
			for (int k = i; k < j; k++) {
				if (dp[i][k] && dp[k + 1][j]) {
					dp[i][j] = 1;
					break;
				}
			}
			if (dp[i][j])continue;
			dp[i][j] = 1;
			for (int k = i; k <= i + len / 2 - 1; k++) {
				if (b[k]) {
					dp[i][j] = 0;
					break;
				}
				if (a[k]) {
					if (a[k] != -1 && a[k] - k != len / 2)dp[i][j] = 0;
					else {
						if (b[k + len / 2] && b[k + len / 2] != k)dp[i][j] = 0;
					}
				}
			}
			for (int k = i + len / 2; k <= j; k++) {
				if (a[k]) {
					dp[i][j] = 0;
					break;
				}
				if (b[k]) {
					if (b[k] != -1 && k - b[k] != len / 2)dp[i][j] = 0;
					else {
						if (a[k - len / 2] && a[k - len / 2] != k)dp[i][j] = 0;
					}
				}
			}
		}
	}
	puts(dp[1][n] ? "Yes" : "No");
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for(int i=0;i<n;i++){
        cin>>x.at(i)>>y.at(i);
    }
    bool ans=false;
    int re_up,re_down,im_up,im_down;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                re_down=x.at(j)-x.at(i);
                im_down=y.at(j)-y.at(i);
                re_up=x.at(k)-x.at(i);
                im_up=y.at(k)-y.at(i);
                if((re_down*im_up-re_up*im_down) == 0){
                    ans = true;
                    break;
                }
            }
            if(ans){
                break;
            }
        }
        if(ans){
            break;
        }
    }
    if(ans){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
    return 0;
}

#include "bits/stdc++.h"
#define ll long long
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FOR(i, a, b) for (int i=a; i<(b); i++)
using namespace std;

bool collinear(int x1, int y1, int x2, int y2, int x3, int y3) {
  return (y1 - y2) * (x1 - x3) == (y1 - y3) * (x1 - x2);
}

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

    ll n;
    cin >> n;
    vector<pair<int, int>> v(n);
    F0R(i,n) {
        cin >> v[i].first >> v[i].second;
    }
    F0R(i,n) {
        FOR(j,i+1,n) {
            FOR(k,j+1,n) {
                if(collinear(v[i].first, v[i].second, v[j].first, v[j].second, v[k].first, v[k].second) == true) {
                    cout << "Yes\n";
                    return 0;
                }
            }
        }
    }
    cout << "No\n";

    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define irreps(i, m, n) for (long long i = ((long long)(n)-1); i > (long long)(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) (long long)(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>;

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 LINF = 1e18;

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

  ll n; cin>>n;
  string t; cin>>t;

  if(n==1){
    ll ans=10000000000;
    if(t=="0") cout<<ans<<endl;
    else cout<<ans*2<<endl;
  }else if(n==2){
    ll ans=10000000000;
    if(t=="11") cout<<ans<<endl;
    else if(t=="00") cout<<0<<endl;
    else if(t=="10") cout<<ans<<endl;
    else if(t=="01") cout<<ans-1<<endl;
  }else{
    bool flg=1;
    char cycle[]={'1','1','0'};

    ll base=10000000000, rem=0;
    base*=3;
    if(t.substr(0,3)=="110"){
      irep(i,3,n) if(cycle[i%3]!=t[i]) flg=0;
    }else if(t.substr(0,2)=="10"){
      rem=1;
      irep(i,2,n) if(cycle[(i-2)%3]!=t[i]) flg=0;
    }else if(t.substr(0,1)=="0"){
      rem=2;
      irep(i,1,n) if(cycle[(i-1)%3]!=t[i]) flg=0;
    }else{
      cout<<0<<endl;
      return 0;
    }
    if(!flg) cout<<0<<endl;
    else{
      ll x=(base-n-rem)/3;
      cout<<x+1<<endl;
      // rem=rem;
      // cout<<rem<<endl;
    }
  }

}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque>
#include <string>

using namespace std;

int n;
char s[200010];
long long totalCount;

long long getStartPos() {
	if ((s[0] == '1') && (s[1] == '1') && (s[2] == '0')) {
		return 0;
	} else if ((s[0] == '1') && (s[1] == '0') && (s[2] == '1')) {
		return 1;
	} else if ((s[0] == '0') && (s[1] == '1') && (s[2] == '1')) {
		return 2;
	}

	return -1;
}

int main()
{
	scanf("%d\n", &n);
	scanf("%s\n", s);
	totalCount = 10000000000L;

	if (n == 1) {
		long long zeroCount = 10000000000L;
		long long oneCount = 20000000000L;

		if (s[0] == '0') {
			printf("%lld\n", zeroCount);
		} else {
			printf("%lld\n", oneCount);
		}

		return 0;
	}

	if (n == 2) {
		if ((s[0] == '0') && (s[1] == '0')) {
			printf("0\n");
		} else if ((s[0] == '0') && (s[1] == '1')) {
			printf("%lld\n", totalCount - 1);
		} else {
			printf("%lld\n", totalCount);
		}

		return 0;
	}

	for (int i = 3 ; i < n ; i++) {
		if (s[i] != s[i - 3]) {
			printf("0\n");
			return 0;
		}
	}

	long long startPos = getStartPos();
	long long endPos = startPos + n - 1;

	if (startPos == -1) {
		printf("0\n");
		return 0;
	}

	long long startSect = startPos / 3;
	long long endSect = endPos / 3;

	long long ans = totalCount - endSect;

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

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int c=5002;
long long n, m, sum, mod=998244353;
long long po[c][c];
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (int i=0; i<=m; i++) {
        po[i][0]=1;
    }
    for (int i=0; i<=m; i++) {
        for (int j=1; j<=n; j++) {
            po[i][j]=po[i][j-1]*i%mod;
        }
    }
    sum=po[m][n]*n%mod;
    for (int i=1; i<n; i++) {
        for (int j=1; j<=m; j++) {
            sum-=(n-i)*po[m][n-i-1]%mod*po[m-j][i-1]%mod;
        }
    }
    sum%=mod;
    if (sum<0) {
        sum+=mod;
    }
    cout << sum << "\n";
    return 0;
}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<vector<int>> Graph;
typedef vector<string> Grid;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chMAX(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}

//#define DEBUG

//declaration area
const ll int_inf = 1LL << 30;
const ll INF = 1LL << 60;
const ll MOD = 998244353;
//struct area

//function area
ll pow(ll x, ll n, ll MOD){
    ll ret = 1;
    while(n > 0){
        if(n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}
//main area
int main(){
    ll n, m;
    cin >> n >> m;
    cout << ((pow(10,n,m*m))-(pow(10,n,m)))/m << endl;
}
/*

*/


#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(b-1)),y(up?b:(a-1)){}_RX(int a):_RX(0,a){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

bool iseven(int x) {
	return (x & 1) == 0;
}

void oesort3(vector<int>& xs, int pos, bool even, vector<int>& ops) {

	int retry = 0;

	auto check = [&]() {
		for(auto i : range(3)) {
			if(xs[pos + i] != pos + i) {
				return false;
			}
		}
		return true;
	};

	while(!check()) {

		int p = (iseven(pos) == even) ? pos : pos + 1;
		ops.push_back(p);
		swap(xs[p], xs[p + 1]);
		even = !even;

		retry += 1;
		assert(retry < 100);
	}
}

void oesort(vector<int>& xs, int pos, bool even, vector<int>& ops) {

	const int N = xs.size();

	if(N - pos == 3) {
		return oesort3(xs, pos, even, ops);
	}

	assert(N - pos >= 4);

	int target = pos;
	while(xs[target] != pos) {
		target += 1;
	}

	if(target == pos) {
		oesort(xs, pos + 1, even, ops);
		return;
	}

	int retry = 0;

	while(iseven(target - 1) != even) {
		if(target - 2 >= pos) {
			ops.push_back(target - 2);
			swap(xs[target - 2], xs[target - 1]);
			even = !even;
		} else {
			ops.push_back(target);
			swap(xs[target], xs[target + 1]);
			target += 1;
			even = !even;
		}
		retry += 1;
		assert(retry < 100);
	}

	for(auto i : revrange(pos, target)) {
		assert(iseven(i) == even);
		ops.push_back(i);
		swap(xs[i], xs[i + 1]);
		even = !even;
	}

	oesort(xs, pos + 1, even, ops);
}

void solve() {

	const int N = read_item();
	vector<int> As(N);
	for(auto i : range(N)) {
		As[i] = (int)read_item() - 1;
	}

	if(N == 2) {
		if(As[0] == 0) {
			printf("0\n");
			return;
		} else {
			printf("1\n1\n");
			return;
		}
	}

	static vector<int> ops;
	ops.resize(0);

	oesort(As, 0, true, ops);
	int c = ops.size();

	assert(c <= N * N);
	printf("%d\n", c);
	for(auto i : range(c)) {
		printf("%d%c", ops[i] + 1, splf(i, c));
	}

}

int main() {

	const int T = read_item();
	for(auto _ : range(T)) {
		solve();
	}

	return 0;
}

/* wafdayo~~~ */

/*
 * author: cyclexit
 * start from: 2021-01-25 16:23
 */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

template<typename T>
struct Point {
  T x, y;
};

template<typename T>
struct Plane {
  array<T, 3> unitx{1, 0, 0};
  array<T, 3> unity{0, 1, 0};
};

template<typename T>
inline Plane<T> rotate90(Plane<T> p) {
  swap(p.unitx, p.unity);
  for (int i = 0; i < 3; ++i) {
    p.unity[i] *= -1;
  }
  return p;
}

template<typename T>
inline Plane<T> rotate270(Plane<T> p) {
  swap(p.unitx, p.unity);
  for (int i = 0; i < 3; ++i) {
    p.unitx[i] *= -1;
  }
  return p;
}

template<typename T>
inline Plane<T> symmetric_x(Plane<T> p, T x) {
  for (int i = 0; i < 3; ++i) {
    p.unitx[i] *= -1;
  }
  p.unitx[2] += 2 * x;
  return p;
}

template<typename T>
inline Plane<T> symmetric_y(Plane<T> p, T y) {
  for (int i = 0; i < 3; ++i) {
    p.unity[i] *= -1;
  }
  p.unity[2] += 2 * y;
  return p;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<Point<ll>> points(n);
  for (int i = 0; i < n; ++i) {
    cin >> points[i].x >> points[i].y;
  }
  int m;
  cin >> m;
  vector<Plane<ll>> planes(m + 1);
  ll op, v;
  for (int i = 1; i <= m; ++i) {
    cin >> op;
    switch (op) {
      case 1:
        planes[i] = rotate90(planes[i - 1]);
        break;
      case 2:
        planes[i] = rotate270(planes[i - 1]);
        break;
      case 3:
        cin >> v;
        planes[i] = symmetric_x(planes[i - 1], v);
        break;
      case 4:
        cin >> v;
        planes[i] = symmetric_y(planes[i - 1], v);
        break;
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    --b;
    auto unitx = planes[a].unitx;
    auto unity = planes[a].unity;
    ll x = unitx[0] * points[b].x + unitx[1] * points[b].y + unitx[2];
    ll y = unity[0] * points[b].x + unity[1] * points[b].y + unity[2];
    cout << x << " " << y << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using  ll  = long long;
using Graph = vector<vector<int>>;
using VP = vector<pair<long long, long long>>;

ll A,B;

int main(){
    cin >> A >> B;
    ll E[A+B];
    ll sum1 = 0,sum2 = 0;
    if(A >= B) {
        for(int i = 1; i <= A; ++i) {
            E[i] = i;
            sum1 += i;
        }
        for(int i = 1; i < B; ++i) {
            E[A + i] = -i;
            sum2 += i;
        }
        E[A+B] = -(sum1-sum2);
        for(int i = 1; i <= A+B; ++i){
          cout << E[i] << " ";
        }
        cout << endl;
    }else {

        for(int i = 1; i <= B; ++i) {
            E[i] = -i;
            sum1+=E[i];
        }
        for(int i = 1; i < A; ++i) {
            E[B + i] = i;
            sum2 += E[i];
        }
        E[A+B] = -(sum1 - sum2);
        for(int i = 1; i <= A+B; ++i){
          cout << E[i] << " ";
        }
        cout << endl;
    }
    return 0;
}

//xhxh
//LYC_music yyds!
#include<bits/stdc++.h>
#define int long long
using namespace std;
int read()
{
	int pos=1,num=0;
	char ch=getchar();
	while (!isdigit(ch))
	{
		if (ch=='-') pos=-1;
		ch=getchar();
	}
	while (isdigit(ch))
	{
		num=num*10+(int)(ch-'0');
		ch=getchar();
	}
	return pos*num;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		write(-x);
		return;
	}
	if (x>=10) write(x/10);
	putchar(x%10+'0');
}
void writesp(int x)
{
	write(x);
	putchar(' ');
}
void writeln(int x)
{
	write(x);
	putchar('\n');
}
int A,B,sum;
signed main()
{
	A=read(); B=read();
	sum=A-B;
	if (sum==0)
	{
		for (int i=1;i<=A;i++)
		{
			writesp(i);
			writesp(-i);
		}
		return 0;
	}
	if (sum>0)
	{
		for (int i=1;i<=A;i++)
		{
			writesp(i);
		}
		for (int i=1;i<B;i++)
		{
			writesp(-i);
		}
		write(-(A*(A+1)/2-(B-1)*B/2));
		return 0;
	}
	for (int i=1;i<=B;i++)
	{
		writesp(-i);
	}
	for (int i=1;i<A;i++)
	{
		writesp(i);
	}
	write((B+1)*B/2-(A-1)*A/2);
}


#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	long long ll;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fio ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define RED "\033[31m"
#define GREEN "\033[32m"
#define RESET "\033[0m"
#define sleep for (int i = 1, a;i < 100000000;i++, a = a * a)
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ranked_pairset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_map;

int main() {
	fio;
	ll n, w;
	cin >> n >> w;
	cout << n / w << '\n';
}

#include<bits/stdc++.h>
#define ll          long long int
#define nl          '\n'
#define pi          acos(-1)
#define GCD(a, b)   __gcd(a, b)
#define boost       ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout       freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define mod         11092019
using namespace std;

int main(void){
    //boost;

    ll t,a,n,x,b,c,d,mx=1e9+5,ans=0,cnt;
       // cin>>t;

read:
    cin>>a>>b;

    cout<<a/b;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <bitset>

using namespace std;

#define rep(i,s,N) for(int i=s;i<N;i++)
typedef long long int lli;

//#define MOD 100000000
//#define MOD 998244353

int main(void)
{
	int N; cin >> N;
	set<int> A;
	rep(i, 0, N) {
		int a; cin >> a;
		A.insert(a);
	}

	while (A.size() > 1) {
		int X = *(--A.end()); A.erase(--A.end());
		int x = *A.begin();
		A.insert(X - x);
	}
	cout << *A.begin() << endl;

	return 0;
}

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

int main(){
    int n; cin >> n;
    if(n%2 == 0) cout << "White" << endl;
    else cout << "Black" << endl;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

int euclidExt(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int x1, y1;
    int d = euclidExt(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

void shiftAnswer(int &x, int &y, int k, int a, int b, int g) {
    x += k * (b / g);
    y -= k * (a / g);
}

bool solve(int a, int b, int c, int &n, int &m, int minize) {
    int g = euclidExt(abs(a), abs(b), n, m);
    if (c % g)
        return false;
    n *= (c / g);
    m *= (c / g);
    if (a < 0)
        n *= -1;
    if (b < 0)
        m *= -1;
    if (minize == 0) {
        int k;
        int num = -n * g;
        if (num >= 0) {
            k = (num + abs(b) - 1) / abs(b);
        } else {
            k = num / abs(b);
        }
        shiftAnswer(n, m, k, abs(a), abs(b), g);

    } else {
        int k;
        int num = -m * g;
        if (num >= 0) {
            k = (num + abs(a) - 1) / abs(a);
        } else {
            k = num / abs(a);
        }
        shiftAnswer(n, m, -k, a, b, g);
    }
    return n >= 0 && m >= 0;
}

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

    int t;
    cin >> t;

    while (t--) {
        int x, y, p, q;
        cin >> x >> y >> p >> q;

        int ans = LLONG_MAX;

        for (int k = 0; k < q; k++) {
            int n1 = 0, m1 = 0;
            if (solve(2 * x + 2 * y, -(p + q), p + k - x, n1, m1, 1))
                ans = min(ans, (p + q) * m1 + p + k);
        }

        for (int k = 0; k < y; k++) {
            int n2 = 0, m2 = 0;
            if (solve(2 * x + 2 * y, -(p + q), p - k - x, n2, m2, 1))
                ans = min(ans, (p + q) * m2 + p);
        }

        cout << (ans == LLONG_MAX ? "infinity" : to_string(ans)) << '\n';
    }
}

#include <bits/stdc++.h>
using namespace std;
template<typename T>
void read(T&x){
	x=0;
	int f=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')f*=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=x*10+(ch-'0');
		ch=getchar();
	}x*=f;
}
template<typename T>
void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
//=============================================
typedef long long ll;
#define int ll
int t,x,y,p,q;
vector<int>T1,T2;
int mod[3];
int ans[3];
void prelude(){
	for(int i=x;i<x+y;++i)T1.push_back(i);
	for(int i=p;i<p+q;++i)T2.push_back(i);
}

int mul(int a,int b,int mod){
	int res=0;
	while(b){
		if(b&1)res=(res+a)%mod;
		a=(a+a)%mod;
		b>>=1;
	}
	return res;
}
int exgcd(int a,int b,int&x,int&y){
	if(b==0){
		x=1,y=0;
		return a;
	}
	int r=exgcd(b,a%b,x,y);
	int t=x;
	x=y;
	y=t-a/b*y;
	return r;
}

int excrt(int ans[],int mod[],int n){
	int M=mod[0];
	int res=ans[0];
	for(int i=1;i<n;++i){
		int a=M,b=mod[i],c=((ans[i]-res)%b+b)%b;
		int x,y;
		int r=exgcd(a,b,x,y);
		if(c%r)return -1;
		int bb=b/r;
		x=mul(x,c/r,bb);
		res+=x*M;
		M*=bb;
		res=(res%M+M)%M;
	}
	return (res%M+M)%M;
}

int solve(){
	ll res=INT64_MAX;
	mod[0]=2*x+2*y;
	mod[1]=p+q;
	T1.clear();
	T2.clear();
	prelude();
	for(auto t1:T1){
		for(auto t2:T2){
			ans[0]=t1;ans[1]=t2;
			int tmp=excrt(ans,mod,2);
			if(tmp==-1)continue;
			res=min(res,tmp);
		}
	}
	return res==INT64_MAX?-1:res;
}

signed main(){
	//freopen("in.txt","r",stdin);
	read(t);
	while(t--){
		read(x),read(y),read(p),read(q);
		int res=solve();
		if(res==-1)puts("infinity");
		else write(res),putchar('\n');
	}
	return 0;
}


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

typedef long long ll;
const ll MOD = 1e9+7;
const ll MAXN = 5e6;

ll n, m, k;

ll fac[MAXN];
void init_fac() {
    fac[0] = 1;
    for (ll i = 1; i < MAXN; i++)
        fac[i] = fac[i-1] * i % MOD;
}

ll modpow(ll n, ll x) {
    ll res = 1;
    while (x) {
        if (x & 1) res = (res * n) % MOD;
        x >>= 1, n = (n * n) % MOD;
    }
    return res;
}

ll modinv(ll n) { return modpow(n, MOD-2); }

ll comb(ll n, ll r) {
    return fac[n] * modinv(fac[r] * fac[n - r] % MOD) % MOD;
}

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

    init_fac();
    cin >> n >> m >> k;
    if (n > m+k)
        cout << 0 << '\n';
    else
        cout << (MOD + comb(n+m, n) - comb(n+m, m+k+1)) % MOD << '\n';
    return 0;
}

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

#define int long long int

#define vi vector<int>

#define ff first
#define ss second

#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
#define Graph vector<vi>
#define Graphw vector<vector<pair<int,int>>>
#define sz(x) (int)x.size()
#define pr pair<int,int>

#define display(v) for(int i =0;i<(int)v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
#define read(a) for(int i = 0;i<(int)a.size();++i)cin>>a[i]
#define show(x) cout << #x << " is " << x << "\n";
// typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_si;
// typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_msi;
#define show_arr(a) cout << #a << "\n"; display(a) ; cout << "\n";
inline int add(int a, int b){ int c = (a%MOD) + (b%MOD); if(c >= MOD) c -= MOD; return c; }
inline int mul(int a, int b){ return ((a%MOD) * 1ll * (b%MOD)) % MOD; }
inline int sub(int a, int b){ int c = (a%MOD) - (b%MOD); if(c < 0) c += MOD; return c; }
inline int sum_till(int n) { return mul(mul(n, n + 1), (MOD + 1) / 2); }
const int nax = 2000*1000 + 10;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//#define ook order_of_key
//#define fbo find_by_order
//   order_of_key(x) -> number of elements less than x.
// * find_by_order(x) -> gives the element at index x (0 - indexing)

int fac[nax] , faci[nax];

int mod_inv(int a, int n){
    int res = 1LL;
    while(n > 0){
        if(n&1){
            res = mul(res , a);
            --n;
        }
        a = mul(a , a);
        n/=2;
    }
    return res;
}

void pre(){
    fac[0] = fac[1] = 1LL;
    faci[0] = faci[1] = 1LL;
    for(int i  = 2;i<nax;++i){
        fac[i] = mul(i , fac[i - 1]);
        faci[i] = mod_inv(fac[i] , MOD - 2);
    }
}

int ncrm(int n, int r){
   if(n==r || r==0){
       return 1LL;
   }
   if(n<r){
       return 0LL;
   }
   return mul(fac[n],mul(faci[r],faci[n-r]));
}

void test_case();
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    pre();
    int t = 1; //cin>>t;
    while(t--){
        test_case();
    }
    return 0;
}

void test_case(){
    int n, m, k; cin>>n>>m>>k;
    if(n > m + k){
        cout << 0 << '\n';
    }
    else{
        int ans = sub(ncrm(n + m, n), ncrm(n + m, m + k + 1));
        cout << ans%MOD;
    }
}

// Химаншу
// check overflow
// special case n == 1
// 🍪🍪🍪


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
const ll md = 998244353;
const ll OO = 1e16;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)

int ad(ll a, ll b) {
    return (a+b+md) % md;
}

int ml(ll a, ll b) {
    return ((a%md) * (b%md)) % md;
}

ll n, m;
const int N = 2e5 + 4;
pair<ll,ll> a[N+1];
ll dp[N+1];

void set_dp() {
    for(int i=0; i<N; ++i)
        dp[i] = -1;
}

int upperbound(int lo, int hi, pair<ll,ll> K) {
    while (lo < hi) {
        int mid = (lo + hi + 1) >> 1;
        if (a[mid].first < K.first) {
            lo = mid + 1;
        } else if (a[mid].first > K.first) {
            hi = mid - 1;
        } else {
            if (a[mid].second <= K.second) {
                lo = mid;
            } else {
                hi = mid-1;
            }
        }
    }
    if (lo > hi) return -1;
    if (a[lo].first != K.first || a[lo].second > K.second) return -1;
    return lo;
}

ll reach(int idx) {
    if (a[idx].first == n && a[idx].second == 0) return 1;
    ll &ans = dp[idx];
    if (ans != -1) return ans;
    ans = 0;
    int i = upperbound(0, idx-1, {a[idx].first-1, a[idx].second-1});
    if (i >= 0 && i < m)
        ans += reach(i);
    i = upperbound(idx+1, m-1, {a[idx].first+1, a[idx].second-1});
    if (i >= 0 && i < m)
        ans += reach(i);
    return ans = ans > 0;
}

int main() {
    FAST_IO;

    set_dp();
    cin >> n >> m;
    for (int i=0; i<m; ++i) {
        cin >> a[i].second >> a[i].first;
    }
    a[m] = {n,0};
    ++m;
    sort(a, a + m);
    ll ans = 0;
    for(int i=0; i<m-1; ++i) {
        if (a[i].first != a[i+1].first && reach(i) > 0)
            ans++;
    }
    if (reach(m-1) > 0) ans++;
    cout << ans << "\n";
    return 0;
}

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

#define pb push_back
#define pob pop_back
#define S second
#define F first
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vll vector<long long int>
#define pll pair<long long int,long long int>
#define mod 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define pi 3.141592653589793238
#define Endl endl
#define endl "\n"
const int N = 2e5 + 15;
const ll inf = 1e18;

void solve()
{
        ll n , m;
        cin >> n >> m;
        map<ll,set<ll>> mp;
        for(ll i=1;i<=m;i++)
        {
                ll r , c;
                cin >> r >> c;
                mp[r].insert(c);
        }
        set<ll> ans = {n};
        for(auto x:mp)
        {
                set<ll> good;
                set<ll> bad;
                for(auto y:x.S)
                {
                        if(ans.count(y-1) or ans.count(y+1))
                                good.insert(y);
                        else
                                bad.insert(y);
                }
                for(auto y:good)
                        ans.insert(y);
                for(auto y:bad)
                        ans.erase(y);
        }
        cout << ans.size();
}

void debug(ll tt) {}

signed main()
{
        FAST;
        int t = 1;
        // cin >> t;
        while(t--)
        {
                solve();
        }
}


#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>
#include <numeric>
#include <chrono>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define debug_pii(x) cerr << "(" << x.first << "," << x.second << ")";
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define F first
#define S second

// template<typename _Ty1, typename _Ty2>
// ostream& operator<<(ostream& _os, const pair<_Ty1, _Ty2>& _p) {
//     _os << '(' <<_p.first << ',' << _p.second << ')';
//     return _os;
// }
//
// template<typename _Ty1, typename _Ty2>
// istream& operator>>(istream& _is, pair<_Ty1, _Ty2>& _p) {
//     _is >> _p.first >> _p.second;
//     return _is;
// }

void solve() {
  int n;cin>>n;
  vector<ll> a(2*n);ll sum=0, temp = 0;
  rep(i,2*n){
    cin>>a[i];sum+=a[i];
  }
  int i = n-1, j = n;
  multiset<ll> ms;ms.insert(a[i]);ms.insert(a[j]);
  while(i >= 0) {
    temp += *ms.begin();
    ms.erase(ms.begin());
    i--;j++;
    if(i >= 0) {
      ms.insert(a[i]);ms.insert(a[j]);
    }
  }
  cout<<sum-temp<<endl;
}

// 6 -> 1 2 3  6

// <

// greedy will fail
// 8 4 7 4 -> 8, 4 -> 12
// 8 4 7 4 -> 7, 8 -> 15
//
// 1 2 3 4 5 6 7 8
// + * * + * * + +
//
// 1 2 3 4 5 6 7 8
// * * * * + + +  +
//
// 1 2 3 4 5 6 7 8
// + + * * * * + +
//
// 1 4 5 8 7 6 3 2
//
// 7 5 3 1=16 (36)

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);
 // cout << fixed << setprecision(15);

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

 int t = 1;
 // cin >> t;
 while (t--) {
   solve();
 }

 return 0;
}

#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
#define rip return 0
typedef long long ll;
typedef pair<ll,ll> P;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(12);
  /*-------------------------------------------*/
  int n;
  cin>>n;
  vec<vec<ll>> c(n,vec<ll>(n));
  rep(i,n){
    rep(j,n){
      cin>>c[i][j];
    }
  }
  vec<ll> down(n-1),across(n-1);
  rep(i,n-1){
    down[i]=c[i+1][0]-c[0][0];
    across[i]=c[0][i+1]-c[0][0];
    rep(j,n-1){
      if(c[i+1][j]-c[0][j]!=down[i] || c[j][i+1]-c[j][0]!=across[i]){
        cout<<"No"<<endl;rip;
      }
    }
  }

  vec<ll> a(n),b(n);
  ll ma=1e10,md=1e10;
  rep(i,n-1){
    md=min(md,down[i]);
    ma=min(ma,across[i]);
  }
  if(md<0)a[0]=md*-1;
  if(ma<0&&(c[0][0]-a[0])<(ma*-1)){
    cout<<"No"<<endl;rip;
  }
  b[0]=c[0][0]-a[0];

  rep(i,n-1)a[i+1]=a[0]+down[i];
  rep(i,n-1)b[i+1]=b[0]+across[i];

  if(a[n-1]+b[n-1]!=c[n-1][n-1]){
    cout<<"No"<<endl;rip;
  }

  cout<<"Yes"<<endl;
  rep(i,n)cout<<a[i]<<" ";
  cout<<endl;
  rep(i,n)cout<<b[i]<<" ";
  cout<<endl;
}


#include<cstdio>
long long n,a,b;
int main(){
  scanf("%lld%lld%lld",&n,&a,&b);
  printf("%lld\n",n-a+b);
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,b,c,d;
    cin>>a>>b;
    cin>>c>>d;
    cout<<a*d-c*b<<endl;
}


#pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
// #include <atcoder/all>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vii = V<int>;
using vvll = V<vll>;
using vvii = V< V<int> >;
using PII = P<int, int>;
using PLL = P<ll, ll>;
#define RevREP(i,n,a) for(ll i=n;i>a;i--)  // (a,n]
#define REP(i,a,n) for(ll i=a;i<n;i++)  // [a,n)
#define rep(i, n) REP(i,0,n)
#define ALL(v) v.begin(),v.end()
#define eb emplace_back
#define pb push_back
#define sz(v) int(v.size())

template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
template< class A, class B > ostream& operator <<(ostream& out, const P<A, B> &p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template< class A > ostream& operator <<(ostream& out, const V<A> &v) {
    out << '[';
    for (int i=0;i<int(v.size());i++) {
        if (i) out << ", ";
        out << v[i];
    }
    return out << ']';
}

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vii c(n);
    rep(i, n) cin >> c[i];
    vvii edges(n);
    rep(i, n - 1) {
        int a, b; cin >> a >> b;
        a--, b--;
        edges[a].eb(b), edges[b].eb(a);
    }

    vii exist(100001, 0), fc(100001, -1);
    vii ans;
    auto rec = [&](auto && me, int i, int p) -> void {
        if (!exist[c[i]]) {
            ans.eb(i + 1);
            exist[c[i]] = 1;
            fc[c[i]] = i;
        }
        for (auto e: edges[i]) {
            if (e == p) continue;
            me(me, e, i);
        }

        if (fc[c[i]] == i) {
            fc[c[i]] = -1;
            exist[c[i]] = 0;
        }
    };
    rec(rec, 0, -1);
    sort(ALL(ans));
    for (auto a: ans) cout << a << '\n';
    return 0;
}

//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
vector<pair<int, int>> E[200001];
int A[200001], B[200001];
ll zentai = 0;
ll kari = 0;
ll q[200001];
ll kotae[200001];

void dfs(int a, int mae) {

	kotae[a] = kari;
	for (auto p : E[a]) {
		int to = p.first;
		int e = p.second;
		if (mae == to) continue;

		if (B[e] == a) {
			kari += q[e];
			dfs(to, a);
			kari -= q[e];
		}
		else {
			zentai += q[e];
			kari -= q[e];
			dfs(to, a);
			kari += q[e];
		}

	}

}

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

	cin >> N;
	rep1(i, N - 1) {
		int a, b;
		cin >> a >> b;
		A[i] = a;
		B[i] = b;
		E[a].pb(mp(b, i));
		E[b].pb(mp(a, i));
	}
	int Q;
	cin >> Q;
	rep(i, Q) {
		int t, e, x;
		cin >> t >> e >> x;
		if (t == 2) {
			zentai += x;
			q[e] += -x;
		}
		else q[e] += x;
	}

	dfs(1, 0);

	rep1(i, N) {
		co(zentai + kotae[i]);
	}

	Would you please return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <limits>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
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; }
template<class T> inline int  sz(T &a) { return a.size(); }
using ll = long long; using ld = long double;
using pi = pair<int,int>; using pl = pair<ll,ll>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
const int inf = numeric_limits<int>::max();
const ll infll = numeric_limits<ll>::max();
// Modint
// modint<MOD> で宣言
template<long long MOD>
struct modint{
  long long x;
  long long mod = MOD;
  modint(long long x=0):x(x%MOD){}
  modint& operator+=(const modint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  modint& operator-=(const modint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  modint& operator*=(const modint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  modint operator+(const modint a) const{
    modint res(*this);
    return res+=a;
  }
  modint operator-(const modint a) const{
    modint res(*this);
    return res-=a;
  }
  modint operator*(const modint a) const{
    modint res(*this);
    return res*=a;
  }
  modint pow(long long t) const{
    if(!t) return 1;
    modint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }

  //for prime mod
  modint inv() const{
    return pow(MOD-2);
  }
  modint& operator/=(const modint a){
    return (*this) *= a.inv();
  }
  modint operator/(const modint a) const{
    modint res(*this);
    return res/=a;
  }
};
using mint = modint<1000000007>;

const int NMAX=1000010; // we can calculate nCk until n is equal to NMAX
mint fact[NMAX],infac[NMAX];
void Make_Fact(){
  fact[0]=fact[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    fact[i]=fact[i-1]*(mint)i;
  }
}
void Make_InvFact(){
  infac[0]=infac[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    infac[i]=infac[i-1]/(mint)i;
  }
}
mint Comb(int n,int k){
  if(n<0||k<0||n-k<0) return 0;
  return fact[n]*infac[k]*infac[n-k];
}

int main()
{
  int n; cin >> n;
  vi a(n);
  rep(i,n) {
    cin >> a[i];
  }

  vector<mint> dpp(n+1),cntp(n+1);
  vector<mint> dpm(n+1),cntm(n+1);
  dpp[0].x = a[0];
  cntp[0].x = 1;
  rep(i,n-1) {
    cntp[i+1] = cntp[i] + cntm[i];
    cntm[i+1] = cntp[i];
    dpp[i+1] = dpp[i] + dpm[i] + cntp[i+1] * (mint)a[i+1];
    dpm[i+1] = dpp[i] - cntm[i+1] * mint(a[i+1]);
    //cout << dpp[i].x << ":" << dpm[i].x << "\n";
  }
  cout << (dpp[n-1] + dpm[n-1]).x << "\n";
  return 0;
}

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int prime=1000000007;
	int N;
	cin>>N;
	vector <int> arr(N,0);
	for(int i=0;i<N;i++){
		int k;
		cin>>k;
		arr[i]=k;
	}
	sort(arr.begin(),arr.end());
	int dif[N];
	dif[0]=arr[0];
	for(int i=0;i<N-1;i++){
		dif[i+1]=arr[i+1]-arr[i];
	}
	long long int out=1;
	for(int i=0;i<N;i++){
		out*=(dif[i]+1);
		out%=prime;
	}
	cout<<out<<endl;
}


/*** author: yuji9511 ***/
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll H,W;
    cin >> H >> W;
    ll A[110][110];
    rep(i,0,H) rep(j,0,W) cin >> A[i][j];
    ll min_val = INF;
    rep(i,0,H){
        rep(j,0,W){
            min_val = min(min_val, A[i][j]);
        }
    }
    ll ans = 0;
    rep(i,0,H)rep(j,0,W) ans += A[i][j] - min_val;
    print(ans);

}

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

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

typedef long long ll;

#define F0R(i, x, y) for (int i = x; i < y; i++)
#define FOR(i, n) F0R(i, 0, n)
#define F0RD(i, x, y) for (int i = y - 1; i >= x; i--)
#define FORD(i, n) F0RD(i, 0, n)

#define F first
#define S second

int mp(int x, int c) {
    return 1000 * c + x;
}

vector<int> adj[2005];
bool vis[2005];

void dfs(int v) {
    vis[v] = true;
    for (int to : adj[v]) {
        if (!vis[to]) dfs(to);
    }
}

int main() {
#ifdef mikey
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin >> n >> m;
    auto ad = [&] (int a, int b, int c, int d) {
        adj[mp(a, b)].push_back(mp(c, d));
        adj[mp(c, d)].push_back(mp(a, b));
    };
    auto add = [&] (int a, int b, int c, int d) {
        adj[mp(a, b)].push_back(mp(c, d));
    };
    FOR(i, m) add(i, 1, 0, 0);
    FOR(i, m) add(i, 1, n - 1, 0);
    FOR(i, n) add(i, 0, 0, 1);
    FOR(i, n) add(i, 0, m - 1, 1);
    FOR(i, n) {
        string s; cin >> s;
        FOR(j, m) {
            if (s[j] == '#') {
                ad(i, 0, j , 1);
            }
        }
    }
    int rcc = 0;
    FOR(i, n) {
        if (!vis[mp(i, 0)]) {
            dfs(mp(i, 0));
            ++rcc;
        }
    }
    memset(vis, false, sizeof(vis));
    int ccc = 0;
    FOR(i, m) {
        if (!vis[mp(i, 1)]) {
            dfs(mp(i, 1));
            ++ccc;
        }
    }
    cout << min(rcc - 1, ccc - 1) << '\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));
}

const int mod = MOD9;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  bool operator==(const mint &p) const { return x == p.x; }
  bool operator!=(const mint &p) const { return x != p.x; }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);

int main(){
  ll n,m;cin >> n >>m;
  mint dp[64][5010];//iけた目のbitまでをたてて、合計がjになる組み方
  memset(dp,0,sizeof(dp));dp[0][0]=1;
  mint two=2;
  for(int i=0;i<32;i++){
    ll base=1LL<<i;
    rep(j,5010){
      ll cnt=0;
      for(ll k=0;k<5010;k+=base*2){
        if(j+k>=5010)break;
        dp[i+1][j+k]+=dp[i][j]*comb(n,cnt);
        cnt+=2;
      }
    }
  }
  cout << dp[32][m] <<endl;
}

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define set(x, i) (x | (1 << i))
#define check(x, i) (x & (1 << i))
#define printcase printf("Case %d: ",test++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0,lim-1);
  return uid(rang);
}
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

int test = 1;
vi g[N];
int a[N];

void solve() {
  int i, j, n, m;
  //printcase;
  cin >> n;
  vi nums(n);
  fo(i,n) cin >> nums[i];
  sortall(nums);
  fo(i,n) {
    if(nums[i] != i+1) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    // cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
  int i, u, v;
  while(m--){
    cin>>u>>v;
    u--, v--;
    g[u].pb(v);
    g[v].pb(u);
  }
}

void dfs(int u, int par){
  for(int v:g[u]){
    if (v == par) continue;
    dfs(v, u);
  }
}


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

int main(){
  char s,t; cin >>s >>t;
  if(s=='Y') t-=32;
  cout << t << endl;
  return 0;
}

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

#define MOD 1000000007
#define PI 3.141592653589793238462

/*########################################### DEBUG ###############################################################################################*/
#ifndef ONLINE_JUDGE
#define debug(x)       \
    cerr << #x << " "; \
    _print(x);         \
    cerr << endl;
#else
#define debug(x)
#endif

void _print(long long t)
{
    cerr << t;
}
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(unsigned long long t) { cerr << t; }

template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p)
{
    cerr << "{";
    _print(p.first);
    cerr << ",";
    _print(p.second);
    cerr << "}";
}
template <class T>
void _print(vector<T> v)
{
    cerr << "[ ";
    for (T i : v)
    {
        _print(i);
        cerr << " ";
    }
    cerr << "]";
}
template <class T>
void _print(set<T> v)
{
    cerr << "[ ";
    for (T i : v)
    {
        _print(i);
        cerr << " ";
    }
    cerr << "]";
}
template <class T>
void _print(multiset<T> v)
{
    cerr << "[ ";
    for (T i : v)
    {
        _print(i);
        cerr << " ";
    }
    cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v)
{
    cerr << "[ ";
    for (auto i : v)
    {
        _print(i);
        cerr << " ";
    }
    cerr << "]";
}

/*###############################################################################################################################################*/
int main()
{
#ifndef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char S, T;
    cin >> S >> T;
    string up = "ABC";
    string down = "abc";
    if (S == 'Y')
    {
        T ^= 32;
    }
    cout << T << "\n";
}


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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,Int k){
    Mint num(1),dom(1);
    for(Int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE

using M = Mint<Int>;
M inv2=M(2).inv();
M calc(Int x,Int y,Int n){
  // cout<<x<<' '<<y<<' '<<n<<':'<<M(x+y)*inv2*M(n)<<endl;
  return M(x+y)*inv2*M(n);
}

signed solve(){
  Int n,a,b;
  cin>>n>>a>>b;
  if(a+b>n){
    cout<<0<<newl;
    return 0;
  }
  vector<M> vs;
  if(b <= n - a - b){
    // i in [0, B)
    // i in [B, N - A - B]
    // i in (N - A - B, N - A]
    vs.emplace_back(calc(0+a,b-1+a,b-0));
    vs.emplace_back(calc(a+b-1,a+b-1,(n-a-b)-b+1));
    vs.emplace_back(calc(a+b-1,a,(n-a)-(n-a-b)));
  }else{
    // i in [0, N - A - B]
    // i in (N - A - B, B)
    // i in [B, N - A]
    vs.emplace_back(calc(0+a,n-b,(n-a-b)-0+1));
    vs.emplace_back(calc(n-b+1,n-b+1,b-(n-a-b)-1));
    vs.emplace_back(calc(n-b,a,(n-a)-b+1));
  }
  M ans{1};
  ans*=M(n-a+1)*M(n-a+1);
  ans*=M(n-b+1)*M(n-b+1);
  for(Int i=0;i<3;i++)
    for(Int j=0;j<3;j++)
      ans-=vs[i]*vs[j];
  cout<<ans<<newl;
  return 0;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int T;
  cin>>T;
  while(T--) solve();
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll mod = 1e9 + 7;

int main() {
	ll t, n, a, b;
	scanf("%lld", &t);
	while(t--) {
		scanf("%lld%lld%lld", &n, &a, &b);
		if(a + b > n) {
			printf("0\n");
			continue;
		}
		ll tmp = (n - a - b) % mod;
		ll ans = (tmp + 1) % mod * (tmp + 2) % mod
				* (2 * (n - a + 1) % mod * (n - b + 1) % mod - (tmp + 1) % mod * (tmp + 2) % mod + mod) % mod;
		printf("%lld\n", ans);
	}
	return 0;
}


#include"iostream"
#include"cstdio"
#include"cmath"
#include"cstring"
#include"algorithm"
#include"stack"
#include"queue"
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define MOD 998244353
#define MAXN 200005

int n,k;
ll sum[305],Cs[305];
ll fac[305];
ll a[MAXN];

ll quickpow(ll a,ll b)
{
	ll ans=1,base=a;
	while(b)
	{
		if(b&1) ans=ans*base%MOD;
		b>>=1;
		base=base*base%MOD;
 	}
 	return ans%MOD;
}

ll inv(ll a){return quickpow(a,MOD-2)%MOD;}

int main()
{
	read(n),read(k);
	fac[0]=1ll;
	for(int i=1;i<=n;i++) readl(a[i]);
	for(int i=1;i<=k;i++) fac[i]=fac[i-1]*i%MOD;
	for(int i=1;i<=n;i++)
	{
		ll op=1ll;
		for(int j=0;j<=k;j++)
		{
			sum[j]=(sum[j]+op)%MOD;
			op=op*a[i]%MOD;
		}
	}
	for(int x=1;x<=k;x++)
	{
		ll ans=0;
		if(x&1)
		{
			for(int i=0;i<=x/2;i++)
			{
				ll c=fac[x]*inv(fac[x-i]*fac[i]%MOD)%MOD;
				ll now=(sum[i]*sum[x-i]-sum[x]+MOD)%MOD;
				ans=(ans+now*c%MOD)%MOD;
			}
		}
		else
		{
			for(int i=0;i<x/2;i++)
			{
				ll c=fac[x]*inv(fac[x-i]*fac[i]%MOD)%MOD;
				ll now=(sum[i]*sum[x-i]%MOD-sum[x]+MOD)%MOD;
				ans=(ans+now*c%MOD)%MOD;
			}
			//499122177
			ll c=fac[x]*inv(fac[x/2]*fac[x/2]%MOD)%MOD;
			ll now=(sum[x/2]*sum[x/2]%MOD-sum[x]+MOD)%MOD;
			ans=(ans+now*c%MOD*499122177%MOD)%MOD;
		}
		printf("%d\n",ans%MOD);
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int MN = 2e5 + 5, MK = 305, MOD = 998244353;
int a[MN], sum[MK], c[MK][MK];
int main () {
	int n,k;
	scanf ("%d %d",&n,&k);
	for (int i = 1; i <= n; i++) {
		int a,pw=1; scanf ("%d",&a);
		for (int i = 0; i <= k; i++) {
			sum[i] += pw;
			if (sum[i] >= MOD) sum[i] -= MOD;
			pw = (long long)pw * a % MOD;
		}
	}
	c[0][0] = 1;
	for (int x = 1; x <= k; x++) {
		int ans = 0;
		for (int i = 0; i <= x; i++) {
			c[x][i] = c[x-1][i] + (i?c[x-1][i-1]:0);
			if (c[x][i] >= MOD) c[x][i] -= MOD;
			ans = (ans + (long long)c[x][i] * ((long long)sum[i] * sum[x-i]%MOD + MOD - sum[x]) % MOD * 499122177LL) % MOD;
		}
		printf ("%d\n",ans);
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <numeric>
using namespace std;

using ll = long long;

#define For(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFor(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
#define co(a) cout<<a<<endl
#define Sort(a) sort((a).begin(),(a).end())
#define Rev(a) reverse((a).begin(),(a).end())
#define Unique(a) (a).erase(unique((a).begin(), (a).end()),(a).end())
#define cfs(a) cout<<fixed<<setprecision(a)

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	ll temp;
	ll sum = 0;
	ll ans = 0;
	For(i, 0, N) {
		cin >> temp;
		A[i] = temp;
		sum += temp;
		ans += (N - 1) * (temp * temp);
	}
	For(i, 0, N) {
		sum -= A[i];
		ans -= 2 * (A[i] * sum);
	}
	co(ans);
}

#include<bits/stdc++.h>
#define FULL(x,y) memset(x,y,sizeof(x))
#define ll long long
#define SZ(x) (int)x.size()
#define pb push_back
using namespace std;

const int N=300005;
int n;
ll a[N],pre[N],pre2[N];

int main() {
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i];
	for(int i=1;i<=n;i++) pre2[i]=pre2[i-1]+a[i]*a[i];
	ll ans=0;
	for(int i=2;i<=n;i++) {
		ans+=(i-1)*a[i]*a[i];
	}
	for(int i=2;i<=n;i++) {
		ans+=pre2[i-1];
	}
	for(int i=2;i<=n;i++) {
		ans-=(2*a[i]*pre[i-1]);
	}
	cout<<ans;
	return 0;
}


/*
problem :
algorithm :
created : Programmer_juruo
*/

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

#define int long long
#define N 100005
#define lowbit(x) x & (-x)
#define F1(i, n) for(int i = 1; i <= n; i++)
#define F(i, a, n) for(int i = a; i <= n; i++)
#define F0(i, n) for(int i = 0; i < n; i++)
#define dbg(x) cout << #x << ":" << x << endl;
#define Se second
#define Fi first
#define y1 juruo
#define Mp make_pair
#define Pb push_back
typedef pair<int, int> pii;
typedef priority_queue<int> pq;
typedef long long ll;

int n, m;

inline ll Read() {
	ll y = 0, f = 1;char c = getchar();
	while(!isdigit(c)){if(c == '-') f = -1;c = getchar();}
	while(isdigit(c)) {y = y*10 + (c - '0'), c = getchar();}
	return y*f;
}
inline void read(int &x){x = Read();}

void work() {
	cin >> n;
	if(n % 4 == 0) cout << "Even" << endl;
	else if(n % 2 == 0) cout << "Same" << endl;
	else cout << "Odd" << endl;
}

signed main() {
  //freopen("1.in", "r", stdin);
  //freopen("1.out", "w", stdout);
  int T = 1;

  cin >> T;

  while(T--) {
  	work();
  }

  return 0;
}

#include <bits/stdc++.h>
#include <cmath>
#include <regex>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define all(x) (x).begin(),(x).end()
#define vll vector<long long int>
#define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)
using namespace std;
#define endl "\n"
ll C(ll n, ll k) {
    double res = 1;
    for (int i = 1; i <= k; ++i)
       res = res * (n - k + i) / i;
    return (ll)(res + 0.01);
}
vector<vll> readGraph(ll n,ll m){
    vector<vll> g(n);
    for(ll i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        //sc.read(a,b);
        //a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    return g;
}
vector<vll> readTree(int n){
    return readGraph(n,n-1);
}
//----------------------------------------------------------------------------
void solve()
{
   ll n;
   cin>>n;
   if(n%4==0){
       cout<<"Even"<<endl;
       return;
   }
   if(n%2==0){
       cout<<"Same"<<endl;
       return;
   }
   else{
       cout<<"Odd"<<endl;
       return;
   }
}
int main() {
FAST;
ll t;
cin>>t;
while(t--){
   solve();
}
return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

// x^n
ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

// x^{-1}
ll mod_inv(ll x) { return mod_pow(x, MOD - 2); }

int main() {
  int n, p;
  cin >> n >> p;
  ll ans = p - 1;
  ans = (ans * mod_pow(p - 2, n - 1)) % MOD;
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define debug(x) cerr << #x << " = " << x << endl;
main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n, k;
	cin >> n >> k;
	while(k > 0){
		if(n % 200 == 0) n /= 200;
		else n = n * 1000 + 200;
		k--;
	}
	cout << n;
}


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

#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007

ll myceil(ll a,ll b){return (a + (b - 1)) / b;}
ll myfloor(ll a,ll b){return a / b;}
int ReLU(int x){return x >= 0 ? x : 0;}
int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}
template<class t,class u> void chmax(t& a,u b){if(a < b) a = b;}
template<class t,class u> void chmin(t& a,u b){if(b < a) a = b;}
template<class T> void inner_product(const vector<pair<T, T>>& vec, T& product){for(const auto& e:vec) product += e.first * e.second;}

int factorial(int n){
    if(n == 0) return 1;
    else return factorial(n - 1) * n;
}
int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}
int ngcd(int n, int a[])
{
    int i, d;
    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}
vector<ll> enum_divisors(ll n){
    vector<ll> res;
    for(ll i = 1; i * i <= n; ++i){
        if(n % i == 0){
            res.push_back(i);
            if(n / i != i) res.push_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
int my_calc(const int a, const int b, const char& ope){
    if(ope == '+') return a + b;
    else if(ope == '-') return a - b;
    else return 0;
}

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};

void dfs_grid(int h, int w, int H, int W, const vector<string>& field, vector<vector<bool>>& seen){
    const int dx[4] = {1, 0, -1, 0};
    const int dy[4] = {0, 1, 0, -1};

    seen[h][w] = true;

    for(int dir = 0; dir < 4; ++dir){
        int nh = h + dx[dir];
        int nw = w + dy[dir];

        if(nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if(field[nh][nw] == 'x') continue;
        if(seen[nh][nw]) continue;
        dfs_grid(nh, nw, H, W, field, seen);
    }
}

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

    string x;
    char ans[203];
    cin >> x;

    int cnt = 0;
    for(int i = 0; i < x.size(); ++i){
        //cnt += i;
        if(x[i] == '.'){
            ans[i] = '\0';
            break;
        }
        //ans.push_back(x[i]);
        ans[i] = x[i];
        cnt++;
    }
    if(cnt == x.size()){
        ans[cnt] = '\0';
    }

    cout << ans << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    ll ans=0;
    vector<ll>data;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ll x=n/i;
            data.push_back(i);
            if(x!=i) data.push_back(x);
        }
    }
    sort(data.begin(),data.end());
    for(ll i=0;i<data.size();i++){
        cout << data[i] << endl;
    }
}


#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using llu = unsigned long long;
using ld = long double;

#define CEIL(x, y) (ll)ceil((ld)(x) / (ld)(y))

#define dbgPR(ds) cout << ds.first << ' ' << ds.second;
#define dbgLST(ds) for(auto it : ds) cout << it << ' ';
#define dbgMP(ds) for(auto it : ds) cout << it.first << ' ' << it.second << '\n';

const double PI = acos(-1.0), g = 9.80665;
const bool unseen = 0;
const ll pinf = 1e18 + 505, ninf = -1e18 - 505;
const int MOD = 1000000007;

int ans = 0;

void rcr(vector<vector<bool>> v, int h, int w, int a, int b)
{
    if(a == 0 && b == 0) {
        bool is = 1;
        for(int i = 0; is && i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(!v[i][j]) {
                    is = 0;
                    break;
                }
            }
        }
        if(is) ans++;
        return;
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(!v[i][j]) {
                if(b != 0) {
                    v[i][j] = 1;
                    rcr(v, h, w, a, b - 1);
                    v[i][j] = 0;
                }
                if(a != 0) {
                    if(i < (h - 1)) {
                        v[i][j] = 1;
                        v[i + 1][j] = 1;
                        rcr(v, h, w, a - 1, b);
                        v[i][j] = 0;
                        v[i + 1][j] = 0;
                    }
                    if(j < (w - 1)) {
                        v[i][j] = 1;
                        v[i][j + 1] = 1;
                        rcr(v, h, w, a - 1, b);
                        v[i][j] = 0;
                        v[i][j + 1] = 0;
                    }
                }
                return;
            }
        }
    }
}

void solve(void)
{
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    vector<vector<bool>> v(h, vector<bool> (w, 0));
    rcr(v, h, w, a, b);
    cout << ans;
}

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

    int testcase = 1;
    // cin >> testcase;
    while(testcase--) {
        solve();
    }
    return 0;
}

// I've had my share of sand kicked in my face but I've come through
#pragma GCC optimize("Ofast")
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define mod (int)(1e9+7)

void solve() {
  int n,m,x,y; cin>>n>>m>>x>>y;
  x--;y--;
  vector<vector<pair<int,pair<int,int>>>> v(n+1);
  for(int i=0;i<m;i++){
    int a,b,t,k; cin>>a>>b>>t>>k;
    a--;b--;
    v[a].pb({b,{t,k}});
    v[b].pb({a,{t,k}});
  }

  set<pair<int,int>> s;
  vector<int> d(n+1,1e18);
  s.insert({0,x});
  d[x]=0;
  while(!s.empty()){
    auto z=*s.begin();
    s.erase(s.begin());

    for(auto i:v[z.second]){
      int time=(((z.first+i.second.second-1)/i.second.second)*i.second.second)+i.second.first;
      if(time<d[i.first]){
        s.erase({d[i.first],i.first});
        d[i.first]=time;
        s.insert({d[i.first],i.first});
      }
    }
  }

  if(d[y]==(1e18))cout<<"-1\n";
  else cout<<d[y]<<'\n';
}

int32_t main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
string zero_padding(int val, int nf){ ostringstream sout;sout << setfill('0') << setw(nf) << val; return sout.str();};
ld PI=3.14159265358979323846;
//using namespace atcoder;

int main(){
    ll N;
    string S;
    cin >> S;
    N = S.size();
    if(N==1){
        if(S == "8"){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        return 0;
    }else if(N==2){
        if(S == "16" || S == "24" || S == "32" || S == "48" || S == "56" || S == "64" || S == "72" || S == "88" || S == "96"){
            cout << "Yes" << endl;
            return 0;
        }
        swap(S[0], S[1]);
        if(S == "16" || S == "24" || S == "32" || S == "48" || S == "56" || S == "64" || S == "72" || S == "88" || S == "96"){
            cout << "Yes" << endl;
            return 0;
        }
        cout << "No" << endl;
        return 0;
    }else{
        vector<ll> v(10);
        rep(i,N){
            ll c = S[i] - '0';
            v[c]++;
        }
        for(ll i = 112; i<1000; i += 8){
            bool flag = 1;
            string s = to_string(i);
            vector<ll> u(10);
            rep(j,3){
                u[s[j] - '0']++;
            }
            rep(j,10){
                if(v[j] < u[j] || u[0] > 0){
                    flag = 0;
                    break;
                }
            }
            if(flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+10;
struct BIT{
	int n,tr[N];
	void init(int _n){
		n=_n;
		memset(tr,0,sizeof tr);
	}
	void add(int x,int v){
		for(int i=x;i<=n;i+=i&-i)
		tr[i]+=v;
	}
	int sum(int x){
		int ans=0;
		for(int i=x;i;i-=i&-i)
		ans+=tr[i];
		return ans;
	}
}tr;
int n,a[N];
ll ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		a[i]++;
	}
	tr.init(n+2);
	for(int i=1;i<=n;++i){
		int v=i-1-tr.sum(a[i]);
		ans+=v;
		tr.add(a[i],1);
	}
	for(int i=1;i<=n;++i){
		printf("%lld\n",ans);
		tr.add(a[i],-1);
		int v=tr.sum(a[i]);
		ans-=v;
		v=tr.sum(n+2)-tr.sum(a[i]);
		ans+=v;
		tr.add(a[i],1);
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <random>
#include <chrono>
#include <queue>
#include <utility>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <limits>
#include <stack>

#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define showv(v) for(int i : v) cout << i + 1 << ' '; cout << '\n';
#define all(v) v.begin(), v.end()
#define MAXN 120000

using namespace std;
using namespace std::chrono;
typedef long long   ll;
typedef long double ld;

int inf = 1e9 + 9;
int mod = 1e9 + 7;

int dp[2005][2005];
int df[2005][2005];

template <typename T>
void show(T * begin, T * end) {
    for(T * it = begin;it != end;it++)
        cout << *it << ' ';
    cout << '\n';
}

void solve() {
    string s; cin >> s;
    if(s[0] == s[1] && s[1] == s[2]) cout << "Won\n";
    else cout << "Lost\n";
}

int main() {
    faster
    int test; test = 1;
    while(test--) {
        solve();
    }
    // auto start = high_resolution_clock::now();
    // auto stop  = high_resolution_clock::now();
    // double time = duration_cast<milliseconds>( stop - start ).count();
    // cout << time << " ms" << endl;
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("First");}else{puts("Second");}
#define MAX_N 200005

int main() {
    int T; cin >> T;
    rep(_,T){
        int n; cin >> n;
        ll a[n] = {};
        rep(i,n) cin >> a[i];
        if(n % 2 == 1){
            cout << "Second" << endl;
            continue;
        }

        sort(a,a+n);
        int ok = 0;
        rep(i,n/2){
            if(a[i*2]!=a[i*2+1])ok = 1;
        }
        if(ok)yn;
    }
    return 0;
}


/*
                    __
                   /\ \
 _ __   ___     ___\ \ \/'\     ___      __      ___     ___      __
/\`'__\/ __`\  /'___\ \ , <    / __`\  /'__`\  /' _ `\ /' _ `\  /'__`\
\ \ \//\ \L\ \/\ \__/\ \ \\`\ /\ \L\ \/\ \L\.\_/\ \/\ \/\ \/\ \/\ \L\.\_
 \ \_\\ \____/\ \____\\ \_\ \_\ \____/\ \__/.\_\ \_\ \_\ \_\ \_\ \__/.\_\
  \/_/ \/___/  \/____/ \/_/\/_/\/___/  \/__/\/_/\/_/\/_/\/_/\/_/\/__/\/_/

*/

#ifndef __AHA__HEADER
#define __AHA__HEADER

#include <bits/stdc++.h>
using namespace std;
#define g0 get<0>
#define g1 get<1>
#define g2 get<2>
#define ft first
#define sd second
#define sz(x) (i6) x.size()
#define psb(x) push_back(x)
#define ppb() pop_back()
#define bg(x) x.begin()
#define ed(x) x.end()
#define col(x) x.begin(), x.end()
#define srt(x) sort(x.begin(), x.end())
#define vec vector
#define deq deque
#define hmap unordered_map
#define pq priority_queue
#define fn function
#ifdef LOCAL
#define git stauDBG_MACRO_NO_WARNING
#include <dbg.h>
#define dbgt dbg(dbg::time())
#else
#define dbg(...)
#define dbgt
#endif
typedef string str;
typedef int32_t i3;
typedef int64_t i6;
typedef int64_t i64;
typedef uint32_t u3;
typedef uint64_t u6;
typedef long double d6;
typedef pair<i6, i6> p6;
typedef vec<i6> vi6;
typedef vec<p6> vp6;
typedef vec<bool> vb;
typedef vec<vi6> vv;
typedef deq<p6> dp6;
typedef deq<i6> di6;
typedef map<i6, i6> mi6;
typedef map<p6, i6> mp6;
typedef set<i6> si6;
typedef hmap<i6, i6> hi6;
typedef vv graph;
typedef vv matrix;

const d6 EPS = 1 / 1000000.0;
const i6 INF = INT64_MAX / 4;
const i6 NINF = -INF;
const i6 ZERO = 0;
const i6 ONE = 1;

namespace std {
template <typename T1, typename T2>
struct hash<pair<T1, T2>> {
  std::size_t operator()(const pair<T1, T2>& pair) const noexcept {
    return hash<T1>()(pair.first) ^ hash<T2>()(pair.second);
  }
};
}  // namespace std

template <typename T1, typename T2>
istream& operator>>(istream& stream, pair<T1, T2>& p) {
  stream >> p.ft;
  stream >> p.sd;
  return stream;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
  return stream << p.ft << " " << p.sd;
}

template <typename T>
istream& operator>>(istream& stream, vec<T>& v) {
  if (v.empty()) {
    u6 len;
    stream >> len;
    v.assign(len, T());
  }
  for (auto i = 0; i < sz(v); i++) {
    stream >> v[i];
  }
  return stream;
}

template <typename T>
ostream& operator<<(ostream& stream, const vec<T>& v) {
  if (!v.empty()) {
    stream << v[0];
  }
  for (auto i = 1; i < sz(v); i++) {
    stream << " " << v[i];
  }
  return stream;
}

#endif

vi6 res;
hmap<i6, vi6> g;
vb colors(200002);
vi6 c;

void dfs(i64 idx, i64 p) {
  bool added = false;
  if (!colors[c[idx - 1]]) {
    added = true;
    colors[c[idx - 1]] = true;
    res.push_back(idx);
  }

  for (auto& e : g[idx]) {
    if (e != p) {
      dfs(e, idx);
    }
  }

  if (added) {
    colors[c[idx - 1]] = false;
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifdef LOCAL
  ifstream cin{"input.txt"};
  ofstream cout{"output.txt"};
#endif

  cin >> c;
  i64 n = sz(c);

  for (i6 i = 0; i < n - 1; i++) {
    p6 tmp;
    cin >> tmp;

    g[tmp.ft].push_back(tmp.sd);
    g[tmp.sd].push_back(tmp.ft);
  }

  dfs(1, -1);
  srt(res);

  for (auto& e : res) {
    cout << e << endl;
  }

  return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

vector<int> ans;

void dfs(vector<vector<int>> &G, int v, int p, map<int, int> &S, vector<int> &C) {
    if (S[C[v]] == 0) {
        ans.push_back(v + 1);
    }
    S[C[v]]++;
    for(int i = 0; i < G[v].size(); i++) {
        int u = G[v][i];
        if (u == p) continue;
        dfs(G, u, v, S, C);
    }
    S[C[v]]--;
}

void solve() {
    int N;
    cin >> N;
    vector<int> C(N);
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }

    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    map<int, int> S;
    dfs(G, 0, -1, S, C);

    sort(all(ans));
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);

    solve();
}