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

const int MAX_N = 2e5+2;
int n;
pair<ll,ll> p[MAX_N];
int m;
ll t[MAX_N],axis[MAX_N];
int q;
ll A[MAX_N], B[MAX_N];
pair<ll,ll> ans[MAX_N];

struct query
{
    ll a, b, id;
    bool operator<(const query& other) const
    {
        return a < other.a;
    }
};

void solve()
{
	vector<query> Q;
	for(int i=0;i<q;++i)Q.emplace_back(query{A[i],B[i],i});
	sort(Q.begin(),Q.end());
	ll sw=0,sx=1,sy=1;
	ll cx=0,cy=0;
	int idx=1;
	for(int i=0;i<q;++i){
		for(; idx<=m && idx<=Q[i].a; ++idx){
			if(t[idx]==1){
				sw ^= 1;
				swap(cx,cy), swap(sx,sy);
				cy*=-1,sy*=-1;
			}else if(t[idx]==2){
				sw ^= 1;
				swap(cx,cy), swap(sx,sy);
				cx*=-1,sx*=-1;
			}else if(t[idx]==3){
				sx*=-1,cx*=-1;
				cx+=2LL*axis[idx];
			}else{
				sy*=-1,cy*=-1;
				cy+=2LL*axis[idx];
			}
		}
		if(!sw){
		    ans[Q[i].id].first =sx*p[Q[i].b].first+cx;
		    ans[Q[i].id].second=sy*p[Q[i].b].second+cy;
		}
		else{
		    ans[Q[i].id].first=sx*p[Q[i].b].second+cx;
		    ans[Q[i].id].second=sy*p[Q[i].b].first+cy;
		}
	}
	for(int i=0;i<q;++i)cout<<ans[i].first<<' '<<ans[i].second<<'\n';
}

int main()
{
  	ios::sync_with_stdio(false);
  	cin.tie(nullptr);
    cout.tie(nullptr);
	cin >> n;
	for(int i=1;i<=n;++i)cin>>p[i].first>>p[i].second;
	cin >> m;
	for(int i=1;i<=m;++i){
		cin >> t[i];
		if(t[i]==3 || t[i]==4) cin>>axis[i];
	}
	cin >> q;
	for(int i=0;i<q;++i)cin>>A[i]>>B[i];
	solve();
	return 0;
}

#include <bits/stdc++.h>
#define rep(i, n)	for(ll i=0;i<(ll)(n);i++)
#define ALL(a)	(a).begin(),(a).end()
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;

void op2(ll& x,ll& y){
    y*=(-1);
    ll tmp=x;
    x=y; y=tmp;
    return ;
}
void op1(ll& x,ll& y){
    x*=(-1);
    ll tmp=x;
    x=y; y=tmp;
    return ;
}
void op3(ll& x,ll& y,ll p){
    x=2*p-x;
    return ;
}
void op4(ll& x,ll& y,ll p){
    y=2*p-y;
    return ;
}

int main(){
    ll n;
    cin>>n;
    vector<P> xy(n);
    rep(i,n) cin>>xy[i].first>>xy[i].second;
    ll m;
    cin>>m;
    vector<vector<P>> c(3);
    c[0].push_back(P(0,0));
    c[1].push_back(P(1,0));
    c[2].push_back(P(0,1));
    rep(i,m){
        ll op;
        cin>>op;
        vector<ll> x(3),y(3);
        rep(j,3){
            x[j]=c[j][i].first;
            y[j]=c[j][i].second;
            //cout<<x[j]<<" "<<y[j]<<endl;
        }
        if(op==3||op==4){
            ll t;
            cin>>t;
            if(op==3){
                rep(k,3){
                    op3(x[k],y[k],t);
                    c[k].push_back(P(x[k],y[k]));
                }
            }
            else{
                rep(k,3){
                    op4(x[k],y[k],t);
                    c[k].push_back(P(x[k],y[k]));
                }
            }
        }
        else{
            if(op==1){
                rep(k,3){
                    op1(x[k],y[k]);
                    c[k].push_back(P(x[k],y[k]));
                }
            }
            else{
                rep(k,3){
                    op2(x[k],y[k]);
                    c[k].push_back(P(x[k],y[k]));
                }
            }
        }
    }
    vector<P> ans;
    ll q;
    cin>>q;
    rep(i,q){
        ll a,b;
        cin>>a>>b;
        b--;
        ll nx=c[0][a].first, ny=c[0][a].second;
        nx+=xy[b].first*(c[1][a].first-c[0][a].first);
        nx+=xy[b].second*(c[2][a].first-c[0][a].first);
        ny+=xy[b].first*(c[1][a].second-c[0][a].second);
        ny+=xy[b].second*(c[2][a].second-c[0][a].second);
        ans.push_back(P(nx,ny));
    }
    for(auto p:ans) cout<<p.first<<" "<<p.second<<endl;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include <math.h>
#include<climits>
using namespace std;
#define int long long
#define vi vector<int>
#define vpii vector<pair<int,int>>
#define pii pair<int,int>
#define ff first
#define ss second
#define print(x) cout<<x<<"\n"
#define printt(x,y) cout<<x<<" "<<y<<"\n"
#define printtt(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define pb push_back
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define all(v) v.begin(),v.end()
#define vvi vector<vector<int>>
#define maxq priority_queue<int>
#define minq priority_queue<int,vector<int>,greater<int>>
#define mod 1000000007
#define N 200009
#define atmod 998244353

bool cmp(pii &a, pii &b) {

	return a.ff > b.ff;
}

void solve() {

	int n, k;
	cin >> n >> k;

	int a[10][10];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			cin >> a[i][j];

	vector<int> v;
	for (int i = 2; i <= n; i++)
		v.pb(i);

	int cnt = 0;
	do {
		int s = 0;
		int p = 1;
		//cout << 1 << " ";
		for (int i = 0; i < v.size(); i++) {
			int j = v[i];
			//cout << v[i] << " ";
			int val = a[p][v[i]];
			s = s + val;
			p = j;
		}

		s = s + a[p][1];
		if (s == k)
			cnt++;
		//cout << 1 << "\n";

	} while (next_permutation(all(v)));

	print(cnt);

}

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

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<fixed<<setprecision(15)<<head;print0(tail...);}
void print() { print0("\n"); }
template<typename Head,typename... Tail>void print(Head head,Tail... tail){print0(head);if(sizeof...(Tail)>0)print0(" ");print(tail...);}
// clang-format on

const ll MODULO = 998244353;
ll mod_minus(ll x, ll modval) {
    if (x >= 0) {
        return x % modval;
    } else {
        ll mm = ((-x) % modval);
        if (mm == 0) {
            return 0;
        } else {
            return modval - mm;
        }
    }
}
ll mod(ll x) {
    return mod_minus(x, MODULO);
}

const ll COMBMAX = 212345;
ll fac[COMBMAX], finv[COMBMAX], inv[COMBMAX];
void combination_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < COMBMAX; i++) {
        fac[i] = fac[i - 1] * i % MODULO;
        inv[i] = MODULO - inv[MODULO % i] * (MODULO / i) % MODULO;
        finv[i] = finv[i - 1] * inv[i] % MODULO;
    }
}
ll combination(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MODULO) % MODULO;
}

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> a(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
    }

    vector<ll> apow(N, 1);
    vector<ll> powsum(K + 1, 0);
    powsum[0] = N;
    for (ll k = 1; k <= K; k++) {
        for (ll i = 0; i < N; i++) {
            apow[i] = (apow[i] * a[i]) % MODULO;
            powsum[k] = (powsum[k] + apow[i]) % MODULO;
        }
    }

    combination_init();
    for (ll k = 1; k <= K; k++) {
        ll result = 0;
        for (ll m = 0; m * 2 <= k; m++) {
            ll v = 0;
            v = mod(powsum[m] * powsum[k - m]);
            v = mod(v - powsum[k]);
            v = mod(combination(k, k - m) * v);
            if (m * 2 == k) {
                v = mod(finv[2] * v);
            }
            result = mod(v + result);
        }
        print(result);
    }
}


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

#define FASTIO ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define int long long
#define mod ((int)1e9 + 7)

int n , m , ans = INT_MIN ;
vector<int> a , mb , ms ;
vector<vector<int>> adj ;
vector<bool> visited ;

void dfs(int x){
        visited[x] = true ;
        for(int y : adj[x]){
                if(!visited[y]) dfs(y) ;
                ms[x] = max(max(ms[x] , ms[y]) , mb[y]) ;
        }
}

void solve(){
        cin >> n >> m ;
        a.resize(n + 1) ; mb.resize(n + 1) ;
        ms.resize(n + 1 , 0) ; visited.resize(n + 1 , false) ;
        adj.resize(n + 1 , vector<int>()) ;
        for(int i = 1 ; i <= n ; ++i){ cin >> a[i] ; mb[i] = a[i] ; }
        for(int i = 0 ; i < m ; ++i){
                int x , y ; cin >> x >> y ;
                adj[x].push_back(y) ;
        }
        for(int i = 1 ; i <= n ; ++i){
                if(visited[i]) continue ;
                dfs(i) ;
        }
        for(int i = 1 ; i <= n ; ++i){
                if(ms[i] == 0) continue ;
                //cout << ms[i] << " " << mb[i] << "\n" ;
                ans = max(ans , ms[i] - mb[i]) ;
        }
        cout << ans << "\n" ;
}

signed main(){
        FASTIO
        int T = 1 ;
       // cin >> T ;
        while(T--) solve() ;
        return 0 ;
}

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int n,m;
vector<int>v[200100];
ll a[200100];
bool used[200100];
ll can[200100];
void dfs(int u)
{
	used[u]=1;
	rep(i,v[u].size())
	{
		if(!used[v[u][i]])dfs(v[u][i]);
		can[u]=max(can[u],can[v[u][i]]);
		can[u]=max(can[u],a[v[u][i]]);
	}
}
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>m;
	rep(i,n)cin>>a[i];
	rep(i,m)
	{
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		v[x].pb(y);
	}
	rep(i,n)can[i]=-1e18;
	fore(i,n-1,0)
	{
		if(!used[i])dfs(i);
	}
	ll ans=-1e18;
	rep(i,n)
	{
		ans=max(ans,can[i]-a[i]);
	}
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main()
{
  int a,b;
  cin >> a >> b;
  int ans = 2*a+100 - b;
  if(ans < 0) ans = 0;
  cout << ans << endl;
}

#include <iostream>

using namespace std;

int main(){
    int m, h;

    cin >> m >> h;

    if (h%m == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int64_t INF=1000000007;
typedef pair<int,set<int>> P;
typedef pair<int,int>Q ;

int64_t gcd(int64_t x, int64_t y) {
    if(x % y == 0) {
        return y;
    } else {
        return gcd(y, x % y);
    }
}

int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  int T;cin >> T;
  for(int i=0;i<T;i++){
    int64_t N,S,K;cin >> N >> S >> K;
    if(gcd(N,K)!=1){
      if(S%gcd(N,K)!=0) cout << -1 << endl;
      else{
        int a=gcd(N,K);
        K/=a;N/=a;S/=a;
        int64_t b=modinv(K,N);
        cout << (b*(N-S))%N << endl;
      }
    }
    else{
      int64_t a=modinv(K,N);
      cout << (a*(N-S))%N << endl;
      //cout << "      " << a << endl;
    }
  }
}

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

#ifdef LOCAL
#include "/debug.h"
#else
#define db(...)
#endif

#define all(v) v.begin(), v.end()
#define pb push_back
using ll = long long;
const int NAX = 2e5 + 5, MOD = 1000000007;

// int a[101][101];

#define int __int128_t
#define ll __int128_t

__int128_t myabs(__int128_t x)
{
    if (x < 0)
        return -x;
    return x;
}

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

bool find_any_solution(int a, int b, int c, int &x0, int &y0, int &g)
{
    g = gcd(myabs(a), myabs(b), x0, y0);
    if (c % g)
    {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0)
        x0 = -x0;
    if (b < 0)
        y0 = -y0;
    return true;
}

std::ostream &
operator<<(std::ostream &dest, __int128_t value)
{
    std::ostream::sentry s(dest);
    if (s)
    {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[128];
        char *d = std::end(buffer);
        do
        {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0)
        {
            --d;
            *d = '-';
        }
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len)
        {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}

void solveCase()
{
    int32_t n1, s1, k1;
    cin >> n1 >> s1 >> k1;
    ll n = n1, s = s1, k = k1;
    // cin >> n >> s >> k;
    db(n, s, k);
    ll x0, y0, g;
    if (find_any_solution(n, -k, s, x0, y0, g))
    {
        if (!(n * x0 + (-k) * y0) == s)
        {
            exit(1);
        }
        db(n * x0 + (-k) * y0, s);
        db(x0, y0, g);
        ll dx = k / g;
        ll dy = n / g;
        // assert(dx > 0 && dy > 0);
        if (!(dx > 0 && dy > 0))
        {
            exit(1);
        }
        db(dx, dy);
        bool ok = false;
        if (x0 < 0)
        {
            auto t = (-x0 + dx - 1) / dx;
            db("a", x0, y0, t);
            x0 += t * dx;
            y0 += t * dy;
            db(x0, y0);
        }
        else if (x0 >= dx)
        {
            auto t = x0 / dx;
            db("a", x0, y0, t);
            x0 -= t * dx;
            y0 -= t * dy;
            db(x0, y0);
            ok = true;
        }
        if (y0 < 0)
        {
            auto t = (-y0 + dy - 1) / dy;
            db("a", x0, y0, t);
            x0 += t * dx;
            y0 += t * dy;
            db(x0, y0);
        }
        // else if (y0 >= dy)
        // {
        //     auto t = y0 / dy;
        //     db("a", x0, y0, t);
        //     x0 -= t * dx;
        //     y0 -= t * dy;
        //     db(x0, y0);
        // }
        if (y0 > 0)
            cout << y0 << '\n';
        else
            cout << "-1\n";
    }
    else
        cout << "-1\n";
}

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int32_t t = 1;
    cin >> t;
    for (int i = 1; i <= t; ++i)
        solveCase();
    return 0;
}


#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0, length = n; i < length; i++)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ep emplace
#define epb emplace_back
#define scll static_cast<long long>
#define sz(x) static_cast<int>((x).size())
#define pfll(x) printf("%lld\n", x)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define ci3(x, y, z) cin >> x >> y >> z
#define ci4(w, x, y, z) cin >> w >> x >> y >> z
#define co(x) cout << x << endl
#define co2(x, y) cout << x << " " << y << endl
#define co3(x, y, z) cout << x << " " << y << " " << z << endl
using namespace std;
typedef long long ll;
typedef pair<int, ll> P;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int>> PQG;
typedef priority_queue<P> PQP;
typedef priority_queue<P, vector<P>, greater<P>> PQPG;

const int MAX_N = 2e5, MOD = 1e9 + 7, INF = 1e9;
int n, m, q, t[MAX_N], x[MAX_N], y[MAX_N], memo[MAX_N][2];
map<int, int> ma;
vector<ll> ans;

P bit[MAX_N + 2][2];

P sum(int i, int j) {
    P s = P(0, 0);
    while (i > 0) {
        s.fi += bit[i][j].fi;
        s.se += bit[i][j].se;
        i -= i & -i;
    }
    return s;
}

void add(int i, int j, int x, int y) {
    while (i <= q + 1) {
        bit[i][j].fi += x;
        bit[i][j].se += y;
        i += i & -i;
    }
}

int main() {
    ci3(n, m, q);
    rep(i, q) {
        ci3(t[i], x[i], y[i]);
        ma.ep(y[i], 0);
    }
    ma.ep(0, 0);
    int cnt = 0;
    for (auto &i: ma) i.se = ++cnt;
    ans.epb(0);
    rep(i, n) add(1, 0, 1, 0);
    rep(i, m) add(1, 1, 1, 0);
    rep(i, q) {
        int old_y = memo[x[i] - 1][t[i] - 1];
        add(ma[y[i]], t[i] - 1, 1, y[i]);
        add(ma[old_y], t[i] - 1, -1, -old_y);
        P p1 = sum(ma[y[i]] - t[i] % 2, t[i] % 2);
        P p2 = sum(ma[old_y] - t[i] % 2, t[i] % 2);
        ll tmp = ans.back();
        tmp += scll(p1.fi) * y[i] - scll(p2.fi) * old_y;
        tmp += p2.se - p1.se;
        ans.epb(tmp);
        memo[x[i] - 1][t[i] - 1] = y[i];
    }
    rep(i, q) co(ans[i + 1]);
    return 0;
}

#include <iostream>
#include <string>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <set>
#include <map>
#include <cassert>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200010
#define LIMIT2 500010
#define LIMIT3 1000010
#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define ALL(a) (a).begin(),(a).end()
#define ALL2(a, n) (a),(a)+(n)
template<class T,class C> T max(T a,C b){ return std::max(a, (T)b); }
template<class T,class C> T min(T a,C b){ return std::min(a, (T)b); }
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a/gcd(a,b))*b;}
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){

}
struct UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n,-1) {}
  void init(int n) { par.assign(n,-1); }
  //木の根であれば連結する頂点数×(-1),そうでなければ親ノードのID
  int root(int x){
    if(par[x]<0) return x;
    else return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x==y) return;//既に連結

    if(par[x] > par[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return;
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
  int size(int x){
    return -par[root(x)];
  }
};
ll mm[200010];
vector<ll> edge[200010];
ll a[LIMIT2]={0};
vector<bool> visited(200010,false);
ll dfs(ll i){
  if(visited[i]==true) return mm[i];
  visited[i] = true;
  ll j;
  ll res=-LLINF;
  rep(j,edge[i].size()){
    res = max(res,dfs(edge[i][j]));
    res = max(res,a[edge[i][j]]);
  }
  mm[i] = res;
  return res;
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,x,y;
  string s;

  cin >> n >> m;
  rep(i,n) cin >> a[i];
  rep(i,m){
    cin >> x >> y;
    x--;y--;
    edge[x].push_back(y);
  }
  rep(i,n){
    dfs(i);
  }
  result = -LLINF;
  rep(i,n){
    result = max(result,mm[i]-a[i]);
  }
  cout << result << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
  double A,B;
  cin >> A >> B;
  double ans = 0.0;
  ans = 100 - B/A*100;
  cout << ans << endl;
}

#include<iostream>
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	if(x>y)
	{
		if(y+3>x)
		{cout<<"Yes"<<endl;}
		else
		{cout<<"No"<<endl;}
	}
	else
	{
		if(x+3>y)
			{cout<<"Yes"<<endl;}
		else
		{cout<<"No"<<endl;}
	}

	return 0;
}


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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)
#define mod 1000000007

//dp(i,j)
//i=until the ith element
//j=how many groups

int dp[3005][3005];
int su[3005],sum[3005];
int a[3005];

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

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

	int n;
	cin>>n;
	forn(i,1,n+1){
		cin>>a[i];
		su[i]=su[i-1]+a[i];
	}
	forn(j,1,n+1){ //groups
		memset(sum,0,sizeof sum);
		forn(i,1,n+1){
			if (j==1) dp[i][j]=1;
			else dp[i][j]=sum[su[i]%j]%mod;
			sum[su[i]%j]=(sum[su[i]%j]+dp[i][j-1])%mod;
		}
	}
	int ans=0;
	forn(j,1,n+1) ans=(ans+dp[n][j])%mod;
	cout<<ans<<endl;
	return 0;
}

#include <bits/stdc++.h>

#define ll long long
#define pi pair<int, int>
#define pf pair<float, int>
#define ps pair<string, int>
#define pii pair<int, pi>
#define mi map<int, int>
#define ml map<long long, int>
#define ms map<string, int>
#define mc map<char, int>
#define mpi map<pi, int>
#define F first
#define S second
#define vt vector
#define vi vector<int>
#define vd vector<double>
#define vf vector<float>
#define vl vector<long long>
#define vpi vector<pi>
#define vpf vector<pf>
#define vpii vector<pii>
#define st set
#define si set<int>
#define sd set<double>
#define sf set<float>
#define sl set<long long>

#define FOR(t, q) for(int q = 0; q < t; q++)
#define FORN(t, q, v) for(int q = v; q < t; q++)
#define sz(v) (int)(v.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define LOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define UPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define pb(s) push_back(s);

#define nl endl
#define TC int _t; cin >> _t; FOR(_t, _q)

using namespace std;

void solve() {
	string s; cin >> s;
	FOR(sz(s), i) {
		if (i % 2 == 0) {
			if (isupper(s[i])) goto L;
		} else {
			if (islower(s[i])) goto L;
		}
	}
	cout << "Yes";
	return;
	L: cout << "No";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // TC
    	solve();

    return 0;
}


#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pair<int,int>>;

void solve() {
    ll N,C; cin >> N >> C;
    map<ll,ll> timeline;

    REP(i,N) {
        int a,b,c; cin >> a >> b >> c;
        timeline[a]+=c;
        timeline[b+1]-=c;
    }

    ll rui = 0;
    ll total = 0;
    ll bef = -1;
    for(const auto &p :timeline) {
        if (bef != -1) total += min(rui,C) * (p.first - bef - 1);
        rui += p.second;
        total += min(rui,C);
        bef = p.first;
    }

    cout << total << endl;
}

int main() {
    solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128_t LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 2e5 + 10;
int a[N], b[N], c[N];
vector<int> open[N + N], close[N + N];
vector<int> all;
map<int, int> mp;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, sub;
    cin >> n >> sub;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    for (int i = 1; i <= n; i++) {
        all.pb(a[i]);
        all.pb(b[i] + 1);
    }
    sort(all.begin(), all.end());
    all.erase(unique(all.begin(), all.end()), all.end());
    for (int i = 0; i < all.size(); i++) {
        mp[all[i]] = i;
    }
    for (int i = 1; i <= n; i++) {
        open[mp[a[i]]].pb(i);
        close[mp[b[i] + 1]].pb(i);
    }
    ll sum = 0;
    ll ans = 0;
    for (int i = 0; i < all.size(); i++) {
        for (int j : close[i]) {
            sum -= c[j];
        }
        for (int j : open[i]) {
            sum += c[j];
        }
        if (i + 1 != all.size()) {
            ans += 1ll * (all[i + 1] - all[i]) * min((ll) sub, sum);
        }
    }
    cout << ans << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

int main(){
    int N, K, M;
    cin >> N >> K >> M;

    vector<int> A(N, 0);
    rep(i, N) cin >> A.at(i);

    int s = 0;
    rep(i, N) s += A.at(i);

    int gap = (M * N) - s;
    cout << ((gap > K) ? -1 : max(gap, 0)) << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using LD = long double;

template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> void coutall(T v) { if(v.empty()){cout << endl; return;} for(auto i = v.begin(); i != --v.end(); i++){cout << *i << " ";} cout << *--v.end() << endl; }
inline void IN(void){ return; }
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return; }
inline void OUT(void){ cout << "\n"; return; }
template <typename First, typename... Rest> void OUT(First first, Rest... rest){ cout << first << " "; OUT(rest...); return; }
void yes(bool ok = true){ cout << (ok ? "yes" : "no") << endl; }
void Yes(bool ok = true){ cout << (ok ? "Yes" : "No") << endl; }
void YES(bool ok = true){ cout << (ok ? "YES" : "NO") << endl; }
ll myceil(ll a, ll b) { return a >= 0 ? (a+b-1)/b : -((-a)/b); }
ll myfloor(ll a, ll b) { return a >= 0 ? a/b : -myceil(-a, b); }

void Main(){
    ll n, m; IN(n, m);
    ll cnt = 0;
    rep(i, n) {
        string s; IN(s);
        int pc = count(all(s), '1');
        if(pc & 1) cnt++;
    }
    cout << cnt * (n-cnt) << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll tmp = a[0];
    for(ll i = 1; i < n; i++){
        tmp = gcd(tmp, a[i]);
    }
    cout << tmp << endl;
}


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

int main()
{
    int n;
    cin >> n;
    unsigned long long s, d, x[100], y[100];
    cin >> s >> d;
    for (int i = 0; i < n; ++i)
    {
        cin >> x[i] >> y[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        if (x[i] < s && y[i] > d)
        {
            ans += 1;
        }
    }
    if (ans != 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

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

   vector<pair<int,string>>v;
   int n;
   cin>>n;
   string name;
   int length;
   for(int i=0;i<n;i++){
       cin>>name>>length;
       v.push_back({length,name});
   }
   sort(v.begin(),v.end());

   cout<<v[n-2].second<<'\n';

   return 0;
}


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

#define ll long long
#define test int tt; cin>>tt; while(tt--)
#define ff first
#define ss second
#define pb push_back

#define Mod 998244353

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

    int n;
    cin>>n;

    vector<ll int> v(n);

    for(auto &e: v)
        cin>>e;

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

    ll int sum_suff[n]={0};

    ll int pre=0;
    for(int i=n-1;i>=0;i--)
    {
        sum_suff[i]+=pre+v[i];
        pre*=2;
        pre+=v[i];

        sum_suff[i]%=Mod;
        pre%=Mod;
    }

    ll int ans=0;
    for(int i=0;i<n;i++)
    {
        ans+=(v[i]*sum_suff[i])%Mod;
        ans%=Mod;
    }

    cout<<ans<<endl;
}

#include <bits/stdc++.h>

#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i, n) for(ll i=n-1;i>=0;--i)
#define rep1(i, n) for(ll i=1; i<=n; ++i)
#define repitr(itr,mp) for(auto itr=mp.begin();itr!=mp.end();++itr)
#define rrepitr(itr, mp) for(auto itr = mp.rbegin(); itr!=mp.rend(); ++itr)
#define ALL(a) (a).begin(),(a).end()

template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

using namespace std;
using ll  = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;
const double PI = 3.1415926535897932384626;

double angle2rad(double angle){return angle * (PI / 180.0);}
double rad2angle(double rad){return rad * (180.0 / PI);}
ll mod(ll a, ll m){return (a + m) % m;}

int main(){
    ll n;
    cin >> n;

    vector<ll> l(n), r(n);
    vector<char> lc(n), rc(n);
    rep(i, n){
        ll t;
        cin >> t >> l[i] >> r[i];
        if(t == 1){lc[i] = '[';rc[i] = '[';}
        if(t == 2){lc[i] = '[';rc[i] = '(';}
        if(t == 3){lc[i] = '(';rc[i] = '[';}
        if(t == 4){lc[i] = '(';rc[i] = '(';}
    }

    ll ans = 0;
    rep(i, n)for(ll j = i+1; j < n; ++j){
        if(l[i] > r[j])continue;
        if(r[i] < l[j])continue;

        if(l[i] == r[j] && lc[i] != rc[j] )continue;
        if(l[i] == r[j] && lc[i] == '(')continue;
        if(r[i] == l[j] && rc[i] != lc[j])continue;
        if(r[i] == l[j] && rc[i] =='(')continue;

        // cout << l[i] << " : " << r[i] << " , " << l[j] << " : " << r[j] << endl;
        // cout << lc[i] << " : " << rc[i] << " , " << lc[j] << " : " << rc[j] << endl;
        ans++;
    }

    cout << ans << endl;
}


#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

struct DSU
{
	int S;

	struct node
	{
		int p; ll sum;
	};
	vector<node> dsu;

	DSU(int n)
	{
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}

	void reset(int n)
	{
		dsu.clear();
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}

	int rt(int u)
	{
		if(dsu[u].p == u) return u;
		dsu[u].p = rt(dsu[u].p);
		return dsu[u].p;
	}

	void merge(int u, int v)
	{
		u = rt(u); v = rt(v);
		if(u == v) return ;
		if(rand()&1) swap(u, v);
		dsu[v].p = u;
		dsu[u].sum += dsu[v].sum;
	}

	bool sameset(int u, int v)
	{
		if(rt(u) == rt(v)) return true;
		return false;
	}

	ll getstat(int u)
	{
		return dsu[rt(u)].sum;
	}
};

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD =998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b);
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
void rmult(int &a, int b)
{
	a=mult(a,b);
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}

int a[155][155];

int main()
{
	init(100000);
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	DSU R(n); DSU C(n);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int pos=1;
			for(int z=0;z<n;z++)
			{
				if(a[i][z]+a[j][z]>k) pos=0;
			}
			//cerr<<i<<' '<<j<<' '<<pos<<'\n';
			if(pos) R.merge(i,j);
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int pos=1;
			for(int z=0;z<n;z++)
			{
				if(a[z][i]+a[z][j]>k) pos=0;
			}
			//cerr<<"C: "<<i<<' '<<j<<' '<<pos<<'\n';
			if(pos) C.merge(i,j);
		}
	}
	int ans=1;
	for(int i=0;i<n;i++)
	{
		if(R.rt(i)==i)
		{
			ans=mult(ans,fact[R.getstat(i)]);
		}
		if(C.rt(i)==i)
		{
			ans=mult(ans,fact[C.getstat(i)]);
		}
	}
	cout<<ans<<'\n';
}

#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;

int n, k;
vector<int> gr[maxn];

int depth[maxn], p[maxn];
int max_depth = 0;

vector<int> vertices[maxn];

int need[maxn], fire[maxn];

void read_input()
{
    cin >> n >> k;
    for(int i = 1; i < n; ++i)
    {
        int u, v;
        cin >> u >> v;
        gr[u].push_back(v);
        gr[v].push_back(u);
    }
}

void dfs_modify(int u, int par)
{
    p[u] = par;
    depth[u] = depth[par] + 1;
    vertices[depth[u]].push_back(u);
    max_depth = max(max_depth, depth[u]);
    for(auto&v: gr[u])
        if(v != par)
            dfs_modify(v, u);
}

bool check(int t)
{
    fill(need + 1, need + n + 1, t);
    fill(fire + 1, fire + n + 1, -1);
    int cnt = 0;
    for(int d = max_depth; d > 1; --d)
        for(auto&u: vertices[d])
        {
            if(need[u] == 0)
            {
                ++cnt;
                if(cnt > k) return false;
                fire[u] = t;
                fire[p[u]] = max(fire[p[u]], t - 1);
            }
            else
            {
                if(fire[u] + need[u] >= t)
                    fire[p[u]] = max(fire[p[u]], fire[u] - 1);
                else
                {
                    fire[p[u]] = max(fire[p[u]], fire[u] - 1);
                    need[p[u]] = min(need[p[u]], need[u] - 1);
                }
            }
        }
    if(need[1] + fire[1] < t)
        ++cnt;
    return cnt <= k;
}

void solve()
{
    dfs_modify(1, 0);
    int low = 1, high = max_depth;
    while(low <= high)
    {
        int mid = (low + high) / 2;
        if(check(mid)) high = mid - 1;
        else low = mid + 1;
    }
    cout << low << '\n';
}

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


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

void solve(void)
{
    ll n;
    cin >> n;
    set<ll> st;
    for (ll i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            ll j = n / i;
            st.insert(i);
            if (n % j == 0)
                st.insert(j);
        }
    }
    for (auto i : st)
        cout << i << "\n";
}
int main(void)
{
    solve();
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

const unsigned int BIT_FLAG_0 = (1 << 0);  // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1);  // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2);  // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3);  // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4);  // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5);  // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6);  // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7);  // 0000 0000 1000 0000

const double PI = 3.14159265358979323846;

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

#define H_MAX 500
#define W_MAX 500
#define INF 1e9 + 7
const long long MOD = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<ull> v, v2;
    for (int i = 1; i <= sqrt(N); i++) {
        if (N % i == 0) {
            v.push_back(i);
            if (i != sqrt(N)) {
                v2.push_back(N / i);
            }
        }
    }
    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << endl;
    }
    for (int i = 0; i < v2.size(); i++) {
        cout << v2[v2.size() - 1 - i] << endl;
    }
}


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

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

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

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

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

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

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

const ll maxf = 10000000;
ll fact[maxf+5];
ll ifact[maxf+5];

void fact_init(){
  fact[0] = 1;
  for(ll i=1; i<=maxf; i++) fact[i] = (fact[i-1] * i) % MOD;
  ifact[maxf]=modpow(fact[maxf],MOD-2);
  for(ll i=maxf; i>=1; i--) ifact[i-1] = (ifact[i] * i) % MOD;
}

ll comb(ll n, ll r){
  if(n<r || n<0 || r<0) return 0;
  if(fact[0] == 0) fact_init();
  return ((fact[n] * ifact[n-r]) % MOD * ifact[r]) % MOD;
}

ll naive_comb(ll n, ll r){
  ll res = 1;
  for (ll i = n; i > n - r; i--) res = res * i % MOD;
  for (ll i = 1; i <= r; i++) res = (res * modpow(i, MOD-2)) % MOD;
  return res;
}

// カタラン数
// (m,n)へ行く経路から、y=x+k+1を通る経路を除いた経路数が答え
// y=x+k+1を通って(m,n)への経路数は、原点の直線と対称な点(-k-1,k+1)から(m,n)への経路数と同じ
// よって、n+mCn - n+mCn-k-1 もしくは n+mCm+k+1
// k+1>n の場合は、y=x+k+1の直線を跨ぐことが無いので減算する必要なし
// コーナーケース
// y=x+k+1の直線より上に(m,n)が存在する場合がある n>m+k
// より具体的にはk=0として、(m,n)=(2,3)とか 白が多いなら必ず白が多いタイミングができてしまう
// この場合は、解無しとして場合分け

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

  ll n,m,k; cin>>n>>m>>k;

  if(n>m+k){
    cout<<0<<endl;
    return 0;
  }

  ll ans=comb(n+m,n);
  ans=(ans-comb(n+m,m+k+1)+MOD)%MOD;
  cout<<ans<<endl;
}

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

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cout.tie(NULL);                   \
    cin.tie(NULL);
#define write(a)          \
    for (auto x : a)      \
    {                     \
        cout << x << " "; \
    }                     \
    cout << endl;
#define read(a)       \
    for (auto &x : a) \
    {                 \
        cin >> x;     \
    }
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i++)
#define IN cin >>
#define OUT cout <<
#define endl "\n"
#define all(a) (a).begin(), (a).end()
#define allr(a) (a).rbegin(), (a).rend()
#define pb push_back

#define fi first
#define se second

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

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'<<endl;}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"<<endl;}
template<typename T, typename... Args>
void __print(T t, Args... args) // recursive variadic function
{
    cout << t <<" " ;
    __print(args...) ;
}
void nl()
{
    cout<<endl;
}

using ll = long long int;
using ld = long double;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using plll  = pair<ll,pll>;
using vll = vector<ll>;
using vi = vector<int>;

const ll MOD = (ll)(1e9) + 7LL;
const ll MM = 998244353LL;
const ll INF  = INT_MAX;

const int dir8[8][2]={{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
const int dir4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};

const ll MAXN = 200005;

/*
for(int i=0;i<n-1;i++)
{
    int a,b;
    cin>>a>>b;
    a--,b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
}
*/

void solve()
{
    vector<ll>arr(3);
    for(int i=0;i<3;i++)cin>>arr[i];
  	sort(all(arr));
  	if(arr[2]-arr[1]==arr[1]-arr[0])
    {
      cout<<"Yes"<<endl;
    }
  	else{
      cout<<"No"<<endl;
    }
  return;
}

/*
1.check for ll for all variables.
2.check brackets in all equation and order of conditions.
3.check custom compare funtions if any.
4.check logic carefully.
5.Dont get stuck on one approch.
*/

int main()
{
    fast;
    ll tc = 1;
    //IN tc;
    while (tc--)
    {
        solve();
        cout.flush();
    }
    return 0;
}


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

template<typename T>
bool is_prime(T x) {
	if (x == 1) {
		return false;
	}
	for (int i = 2; (T) i * i <= x; i++) {
		if (x % i == 0) {
			return false;
		}
	}
	return true;
}

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

	long long a, b;
	cin >> a >> b;

	int len = b - a + 1;

	vector<int> p;
	for (int i = 1; i <= len; i++) {
		if (is_prime(i)) {
			p.push_back(i);
		}
	}

	vector<int> mask_of(len);
	for (long long x = a; x <= b; x++) {
		for (int i = 0; i < int(p.size()); i++) {
			if (x % p[i] == 0) {
				mask_of[x - a] |= (1 << i);
			}
		}
	}

	vector<long long> dp(1 << p.size());
	dp[0] = 1;

	for (int i = 0; i < len; i++) {
		for (int mask = (1 << int(p.size())) - 1; mask >= 0; mask--) {
			if ((mask & mask_of[i]) == 0) {
				dp[mask | mask_of[i]] += dp[mask];
			}
		}
	}
	cout << accumulate(dp.begin(), dp.end(), 0ll) << '\n';
	return 0;
}

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
LL a,b;
int g[22],d[22];
int _v,_w;
LL gcd(LL x,LL y){
  return y==0?x:gcd(y,x%y);
}
int ban_v[1<<22];
int sum_v[1<<22];
vector<LL>G;
LL ans;
void gao(vector<LL>&v,vector<LL>&w){
  while(v.size()>w.size()){
    w.pb(v.back());
    v.pop_back();
  }
  _v=v.size(),_w=w.size();
  memset(ban_v,0,sizeof ban_v);
  memset(sum_v,0,sizeof sum_v);
  memset(g,0,sizeof g);
  memset(d,0,sizeof d);
  for(int i=0;i<_v;i++){
    for(int j=0;j<_v;j++){
      if(i==j)continue;
      if(gcd(v[i],v[j])!=1){
        g[i]|=1<<j;
      }
    }
  }
  for(int i=0;i<_w;i++){
    for(int j=0;j<_w;j++){
      if(i==j)continue;
      if(gcd(w[i],w[j])!=1){
        d[i]|=1<<j;
      }
    }
    for(int j=0;j<_v;j++){
      if(gcd(w[i],v[j])!=1){
        ban_v[i]|=1<<j;
      }
    }
  }
  for(int i=0;i<1<<_v;i++){
    int st=0;
    for(int j=0;j<_v;j++){
      if(1<<j&i){
        if(( g[j]) & (i^(1<<j)))st=1;
      }
    }
    if(!st) {
      sum_v[i] = 1;
    }
  }

  for(int i=0;i<_v;i++){
    for(int j=0;j<1<<_v;j++){
      if(1<<i&j)sum_v[j]+=sum_v[j^(1<<i)];
    }
  }
  int sum_sta=1<<_v ;
  sum_sta--;
  for(int i=0;i<1<<_w;i++){
    int st=0;
    int sum_ban=0;
    for(int j=0;j<_w;j++){
      if(1<<j&i){
        if(( d[j]) & (i))st=1;
        sum_ban|=ban_v[j];
      }
    }
    if(!st){
      assert((sum_ban&sum_sta)==sum_ban);
      //cout<<i<<' '<<(sum_ban^sum_sta)<<'\n';
      ans+=sum_v[sum_ban^sum_sta];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>a>>b;vector<LL>v,w;
  for(LL i=a;i<=b;i++){
    if(i&1)v.pb(i);
    else G.pb(i);
  }
  G.pb(1);
  /*
   * 因为偶数只能选一个
   * 枚举不选 或者 选哪个 偶数
   * 存一下跟这个偶数gcd为1的奇数
   *
   * meet in middle 来计算 奇数部分的答案。
   * */
  for(auto k:G){
    v.clear();w.clear();
    for(LL i=a;i<=b;i++){
      if(i%2==0)continue;
      if(gcd(k,i)==1)v.pb(i);
    }
    //cout<<"ev-> "<<k<<'\n';
   // cout<<"od->\n";
   //for(auto x:v)cout<<x<<' ';cout<<'\n';
    gao(v,w);
  }
  cout<<ans<<'\n';
  return 0;
}
//2125824
//4589568


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define vsort(v) sort(v.begin(),v.end())
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

/*
sort(ord.begin(),ord.end(),[&](int x, int y){
    return p[x]>p[y];
});
*/

string ans_Yes = "Yes";
string ans_No = "No";
string ans_yes = "yes";
string ans_no = "no";

vll A;
vll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

ll calcMatch(ll ai, ll bi){
    ll tai = ai;
    ll tbi = bi;
    ll ans = 0;
    while(tai<N && tbi < M){
        if(A[tai]!=B[tbi]) ans++;
        tai++;
        tbi++;
    }
    return ans;
}

vector <vector<int>> dp;
int getval(int ai, int bi){
    int tmp = INF;
    if(ai==1){
        tmp = bi-1;
    } else if(bi==1){
        tmp = ai-1;
    }else{
        for( int tai = 1 ; tai <=ai-1 ; tai++ ) tmp = min(tmp, dp[tai][bi-1] + (ai-1-tai) );
        for( int tbi = 1 ; tbi <=bi-1 ; tbi++ ) tmp = min(tmp, dp[ai-1][tbi] + (bi-1-tbi));
    }
    if(A[ai]!=B[bi]) tmp++;
    return tmp;
}
int getans(){

    dp.resize(1001);
    rep(di,1001) rep(ni,1001) dp[di].push_back(0);
    for( ll ai = 1 ; ai <=N ; ai++ ){
        for( ll bi = 1 ; bi <=M ; bi++ ){
            dp[ai][bi] = getval(ai,bi);
        }
    }
    for( ll ai = 1 ; ai <=N ; ai++ ){
        for( ll bi = 1 ; bi <=M ; bi++ ){
            dp[ai][bi] += (N-ai);
            dp[ai][bi] += (M-bi);
        }
    }

    int ans = INF;
    for( ll ai = 1 ; ai <=N ; ai++ ){
        for( ll bi = 1 ; bi <=M ; bi++ ){
            //cout << "ai " << ai <<  " bi " << bi << " = " << dp[ai][bi] << endl;
            ans = min(ans,dp[ai][bi]);
        }
    }

    return ans;
}
int main(){

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

    cin >> N;
    cin >> M;
    A.resize(N+1);
    B.resize(M+1);
    rep(ni,N) cin >> A[ni+1];
    rep(mi,M) cin >> B[mi+1];

    ll minA = 0;
    ll minB = 0;

    cout << getans() << endl;

}


#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 300
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main ()
{
    RUN_FAST; cin.tie(nullptr);
    int n, cnt, mx1=0, mx2, ans;
    cin >> n;
    int arr[n], i, j;
    for (i=0; i<n; i++) {
        cin >> arr[i];
        mx1=max(mx1, arr[i]);
    }
    mx2=0;
    ans=2;
    for (i=2; i<=mx1; i++) {
        cnt=0;
        for (j=0; j<n; j++)
            if (arr[j]%i==0) cnt++;
        if (cnt>mx2) {
            mx2=cnt;
            ans=i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int t;
    long int n=0, m=0, a=0, a1=0, b=0, c=0, d=0, x=0, y=0, z=0, k=0, l=0, x1;
  cin>>n;
  long int arr[n];
  for ( int i=0; i<n; i++ )  {  cin>>arr[i];
                              a=a+abs(arr[i]);
                              b=b+(arr[i]*arr[i]);
                              if (d<abs(arr[i]))
                                d=abs(arr[i]);
                             }

   double val1 = 1.0;
  val1=val1*b;
  cout<<a<<endl;

    cout << fixed << setprecision(12) << sqrt(val1) << endl;
  cout<<d<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
#define rep2(i, n, m) for(int i=(int)n; i<=(int)m; i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
const ll inf=1LL<<60;
const ll mod=1000000007;

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

  int n;
  ll x;
  cin >> n >> x;
  vl a(n);
  rep(i, n)cin >> a[i];

  rep(i, n){
  	if(a[i]==x)continue;
  	cout << a[i];
  	if(i!=n-1)cout << " ";
  }

  cout << endl;

  return 0;
}

#include<bits/stdc++.h>
#define int long long
#define zmrl(x) signed((x).size())
#define ahen(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii = pair<int,int>;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int A[105][105];
    int h,w; cin>>h>>w;
    int mmin = 100;
    for (int i=1; i<=h; i++) {
        for (int j=1; j<=w; j++) {
            cin>>A[i][j];
            mmin = min(A[i][j], mmin);
        }
    }
    int res = 0;
    for (int i=1; i<=h; i++) {
        for (int j=1; j<=w; j++) {
            res += A[i][j] - mmin;
        }
    }
    cout<<res<<'\n';
    return 0;
}


#include <bits/stdc++.h>
#define lc (o<<1)
#define rc ((o<<1)|1)
#define PB push_back
#define MK make_pair
using namespace std;
#define DebugP(x) cout << "Line" << __LINE__ << " " << #x << "=" << x << endl

const int maxn = 3e5 + 5;
const int modu = 998244353; // 1e9 + 7
const int inf = 0x3f3f3f3f;
const double eps = 1e-5;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

typedef long long LL;

void read(LL &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch<'0'||ch>'9')  {f|=(ch=='-');ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    x=f?-x:x;
    return;
}

void read(int &x) { LL y; read(y); x = (int)y; }
void read(char &ch) { char s[3]; scanf("%s", s); ch = s[0]; }
void read(char *s) { scanf("%s", s); }
template<class T, class ...U> void read(T &x, U& ... u) { read(x); read(u...); }

int n;
LL a[maxn], sum, sum2, ans;

int main() {
    // freopen("my.txt", "w", stdout);
    read(n);
    for (int i = 0; i < n; ++i) read(a[i]);
    sum = a[0];
    sum2 = a[0]*a[0];
    ans = 0;
    for (int i = 1; i < n; ++i) {
        ans += i*a[i]*a[i] - 2*sum*a[i] + sum2;
        sum += a[i];
        sum2 += a[i]*a[i];
    }
    cout << ans << "\n";
	return 0;
}

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

int main() {
  long long N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  vector<long long> count(401);
  for (int i = 0; i < N; i++) {
    count.at(A.at(i) + 200)++;
  }

  long long total = 0;

  for (int i = 0; i < 401; i++) {
    for (int j = i; j < 401; j++) {
      int x = i - j;
      total += count.at(i) * count.at(j) * x * x;
    }
  }

  cout << total << endl;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
string ans[20];
bool check(string s){
    bool ret=false;
    int i,j;
    for(i=0;i<20;i++){
        string wk="";
        for(j=0;j<20;j++){
            if(ans[i].size()>j){
                wk+=ans[i];
            }else{
                break;
            }
        }
        if(wk.find(s)!=std::string::npos){
            ret=true;
            break;
        }
    }
    return ret;
}
int main()
{
    int n,m;
    cin>>n>>m;
    string s;
    vector<pair<int,string>> vec;
    int i,j;
    for(i=0;i<m;i++){
        cin>>s;
        bool add=true;
        for(j=0;j<vec.size();j++){
            if(s.size()<=vec[j].second.size()){
                if(vec[j].second.find(s)==std::string::npos) continue;
                (vec[j].first)++;
                add=false;
                break;
            }else{
                if(s.find(vec[j].second)==std::string::npos) continue;
                (vec[j].first)++;
                vec[j].second=s;
                add=false;
                break;
            }
        }
        if(add){
            vec.push_back({0,s});
        }
    }
    sort(vec.begin(),vec.end());
    for(i=vec.size()-1;i>=0; i--){
        int len=vec[i].second.size();
        if(check(vec[i].second)) continue;
        for(j=0;j<20;j++){
            if(ans[j].size()+len<=20){
                ans[j]+=vec[i].second;
                break;
            }
        }
    }
    for(i=0;i<20;i++){
        for(j=ans[i].size();j<20;j++){
            ans[i]+='.';
        }
        cout<<ans[i]<<endl;
    }
    return 0;
}

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

int main()
{
    int N,M;
    string a;
    random_device rnd;

    cin >> N >> M;

    for(int i=0; i<M; i++) {
        cin >> a;
    }

    for(int y=0; y<N; y++) {
        for(int x=0; x<N; x++){
            char a = rnd()%8 + 'A';
            cout << a;
        }

        cout << endl;
    }
};


#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int t=0;
	cin>>a;
	for(int i=0;i<a.size()-3;i++){
		string s(a,i,4);
		if(s=="ZONe") t++;
	}
	cout<<t;
	return 0;
}

/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define debug2(x, y) cout << #x << " = " << x << " " << #y << " " << y << "\n";
#define MOD 1000000007

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;
using namespace __gnu_pbds;

// Refer to https://codeforces.com/blog/entry/11080
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> ordered_set;

void solve()
{
    int x;
    cin >> x;

    if(x % 100)
    {
        cout << 100 - (x % 100) << "\n";
    }
    else {
        cout << 100 << "\n";
    }

}

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

    int T = 1;
    //cin >> T;

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

    return 0;
}


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

#define ll long long
#define all(x) x.begin(), x.end()

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n, m; cin >> n >> m;
	vector<array<int, 2>> black(m);
	for(auto &[x, y] : black) cin >> x >> y;
	set<int> white;
	white.insert(n);
	sort(all(black));
	for(int i = 0; i < m;){
		int cur = black[i][0];
		vector<int> rem, ins;
		while(i < m && cur == black[i][0]){
			int l = white.count(black[i][1] - 1), r = white.count(black[i][1] + 1);
			if(l + r == 0) rem.push_back(black[i][1]);
			else ins.push_back(black[i][1]);
			++i;
		}
		for(auto j : ins) white.insert(j);
		for(auto j : rem) white.erase(j);
	}
	cout << (int)white.size() << "\n";
}

#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <bits/stdc++.h>
using namespace std;
/*----------------------------------ここからマクロ----------------------------------*/
#define f(i, n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vb  vector<bool>
#define pii pair<int,int>
#define mii  map<int, int>
#define msi  map<string, int>
#define pii pair<int,int>
#define vpii  vector<pair<int, int>>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define len(x) ((int)(x).size())
#define contains(x,key) ((x).find(key) != (x).end())
#define cauto const auto
#define ll  long long
#define float long double
#define elif else if
#define exit return 0
const ll mod1 = 1000000007LL;
const ll mod2 = 998244353LL;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
const float pi = 3.14159265358;
constexpr long long gcd(long long a, long long b) { while(b){ long long A = a; (a = b), (b = A % b); } return a; }
constexpr long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
constexpr int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
constexpr const char* YesNo(bool b) { return b ? "Yes" : "No"; }
constexpr const char* YESNO(bool b) { return b ? "YES" : "NO"; }
constexpr const char* yesno(bool b) { return b ? "yes" : "no"; }
constexpr const char* yn(bool b) { return YesNo(b); }
template<class T> string join(const vector<T> &v){ stringstream s; rep (i, len(v)) s<<' '<<v[i]; return s.str().substr(1); }
template<class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template<class T> istream& operator>>(istream& is, vector<vector<T>>& v) { for(auto& x : v) for (auto& y : x) is >> y; return is; }
template<class T, class U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.FI >> p.SE; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>>& v){ rep (i, len(v)) { if (len(v[i])) os << join(v[i]) << (i-len(v)+1 ? "\n" : ""); } return os; }
void print(){ cout << "\n"; }
template<class T, class... A>void print(const T& v, const A&...args){cout << v; if(sizeof...(args))cout << " "; print(args...);}
void print_d(float i){ cout << fixed << setprecision(8) << i << endl; }

/*----------------------------------マクロここまで----------------------------------*/

int main() {
    fast;
    ll S, P;
    cin >> S >> P;

    for(ll i = 1; i*i <= P; i++){
        if(P%i != 0) continue;
        ll j = P / i;
        if(i+j == S){
            cout << "Yes" << endl;
            exit;
        }
    }

    cout << "No" << endl;
    return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <array>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

#pragma GCC optimize("Ofast")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getrnd(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2> inline bool relax(T1& a, const T2& b) {
    return a > b ? a = b, true : false;
}

template <typename T1, typename T2> inline bool strain(T1& a, const T2& b) {
    return a < b ? a = b, true : false;
}

// :::::::::::::::::::::::::::::::

const int N = 103;

int cnt[N], was[N];

void dfs(int v, vector<string>& graph) {
    if (was[v]) return;

    was[v] = 1;
    ++cnt[v];
    for (int i = 0; i < graph[v].size(); ++i) {
        if (graph[v][i] == '1')
            dfs(i, graph);
    }
}

void solve() {
    int n;
    cin >> n;

    vector<string> graph(n);
    for (int i = 0; i < n; ++i)
        cin >> graph[i];

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j)
            was[j] = 0;
        dfs(i, graph);
    }

    ld ans = 0;
    for (int i = 0; i < n; ++i)
        ans += (ld) 1 / cnt[i];
    cout.precision(10);
    cout << fixed << ans << '\n';
}

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

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

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll INF = 0x3fffffff;
#define lln          \
	long long n = 0; \
	cin >> n
#define rep(i, n) for (ll i = 0; i < n; i++)
#define sVec(vec) sort(vec.begin(), vec.end())
#define rVec(vec) reverse(vec.begin(), vec.end())
#define iVec(vec)                       \
	for (ll i = 0; i < vec.size(); i++) \
	{                                   \
		cin >> vec.at(i);               \
	}
#define oVec(vec)                       \
	for (ll i = 0; i < vec.size(); i++) \
	{                                   \
		cout << vec.at(i) << endl;      \
	}
#define ExactMinority(degits) \
	cout << fixed << setprecision(degits)
#define UniqueVector(vec)         \
	sort(vec.begin(), vec.end()); \
	vec.erase(unique(vec.begin(), vec.end()), vec.end())

int main()
{
	string s;
	cin >> s;
	string t;
	bool a = false;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'R')
		{
			a = !a;
		}
		else
		{
			if (a)
			{
				t.insert(t.begin(), s[i]);
			}
			else
			{
				t += s[i];
			}
		}
	}
	if (a)
	{
		reverse(t.begin(), t.end());
	}
	if (t.empty())
	{
		cout << endl;
		return 0;
	}
	for (int i = 0; i < t.size() - 1; i++)
	{
	a:
		if (t[i] == t[i + 1])
		{
			t.erase(i, 2);
			if (t.empty())
			{
				cout << endl;
				return 0;
			}
			if (i > 0)
			{
				i --;
			}
			goto a;
		}
	}
	cout << t << endl;
}


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

int main() {
	int A,B;
	cin>>A>>B;
	int solids=A+B;
	if(solids >= 15 and B>=8) cout<<1<<endl;
	else if(solids >= 10 and B>=3) cout<<2<<endl;
	else if(solids >= 3) cout<<3<<endl;
	else cout<<4<<endl;

	return 0;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    cout << (_x) << '\n'; return;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
inline P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll = int64_t;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<int>(1e9 + 7);

//.data

//.code
void SolveTask() {
    int a, b;
    cin >> a >> b;
    if (a + b >= 15 && b >= 8) {
        RET(1);
    }
    if (a + b >= 10 && b >= 3) {
        RET(2);
    }
    if (a + b >= 3) {
        RET(3);
    }
    cout << 4 << endl;
}

int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int test_cases = 1;
    // cin >> test_cases;
    for (int yt = 1; yt <= test_cases; ++yt) {
        SolveTask();
    }
#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
//indexed set is using "int" here--------- use ll ...
// typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    string a,b;
    cin>>a>>b;
    ll x=0,y=0;
    for (auto z: a)
    {
        x+=(z-'0');
    }
    for (auto z: b)
    {
        y+=(z-'0');
    }
    cout<<max(x,y)<<"\n";
}

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

#define pb push_back
#define FOR(i,f,n) for(int i=f;i<n;i++)
#define FORI(i,f,n) for(int i=f;i>=n;i--)
#define sz(a) ((int)(a).size())
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define alli(a) (a).rbegin(),(a).rend()
#define approx(a) fixed<<setprecision(a)
#define trav(a,x) for(auto& a : x)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,bool> pib;
typedef pair<ll,bool> plb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class T> void ckmin(T &a, const T &b) { a = min(a, b); }
template <class T> void ckmax(T &a, const T &b) { a = max(a, b); }

template <class T> void read(vector<T> &v);
template <class F, class S> void read(pair<F, S> &p);
template <class T> void read(T &x) {cin>>x;}
template <class R, class... T> void read(R& r, T&... t){read(r); read(t...);};
template <class T> void read(vector<T> &v) {trav(x, v) read(x);}
template <class F, class S> void read(pair<F, S> &p) {read(p.ff, p.ss);}

template <class F, class S> void pr(const pair<F, S> &x);
template <class T> void pr(const T &x) {cout<<x;}
template <class R, class... T> void pr(const R& r, const T&... t) {pr(r); pr(t...);}
template <class F, class S> void pr(const pair<F, S> &x) {pr("{", x.ff, ", ", x.ss, "}");}
void ps() {pr("\n");}
template <class T> void ps(const T &x) {pr(x); ps();}
template <class T> void ps(vector<T> &v) {trav(x, v) pr(x, ' '); ps();}
template <class F, class S> void ps(const pair<F, S> &x) {pr(x.ff, ' ', x.ss); ps();}
template <class R, class... T> void ps(const R& r,  const T &...t) {pr(r, ' '); ps(t...);}

int h, w, n, m;

void solve(){
    read(h, w, n, m);
    vector<vi> grid(h, vi(w));
    FOR(i,0,n){
        int x, y; read(x,y);
        x--, y--;
        grid[x][y] = 1;
    }
    FOR(i,0,m){
        int x, y; read(x,y);
        x--, y--;
        grid[x][y] = -1;
    }
    vector<vi> row = grid;
    vector<vi> col = grid;
    FOR(i,0,h){
        FOR(j,1,w){
            if(row[i][j] != -1 && row[i][j-1] == 1){
                row[i][j] = 1;
            }
        }
        FORI(j,w-2,0){
            if(row[i][j] != -1 && row[i][j+1] == 1){
                row[i][j] = 1;
            }
        }
    }
    FOR(j,0,w){
        FOR(i,1,h){
            if(col[i][j] != -1 && col[i-1][j] == 1){
                col[i][j] = 1;
            }
        }
        FORI(i,h-2,0){
            if(col[i][j] != -1 && col[i+1][j] == 1){
                col[i][j] = 1;
            }
        }
    }

    int ans = 0;
    FOR(i,0,h){
        FOR(j,0,w){
            if(row[i][j] == 1 || col[i][j] == 1) ans++;
        }
    }
    ps(ans);
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}


#include <iostream>

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

#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 HOME
	~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__) << "] "

#define ff first
#define ss second
#define REP(i,st,en) for (int i = st; i <= en; i++)
#define REPR(i,st,en) for (int i = st; i >= en; i--)

const int MOD = 998244353;

class Modint {
public:
	long long val;

	Modint (long long _val = 0) {
		if (_val >= MOD) _val %= MOD;
		val = _val;
	}

	Modint operator+ (Modint other) {
		return Modint(val + other.val);
	}

	void operator+= (Modint other) {
		val += other.val;
		if (val >= MOD) val %= MOD;
	}

	Modint operator- () {
		return Modint(MOD - val);
	}

	Modint operator- (Modint other) {
		return Modint(val + MOD - other.val);
	}

	void operator-= (Modint other) {
		val += MOD - other.val;
		if (val >= MOD) val %= MOD;
	}

	Modint operator* (Modint other) {
		return Modint(val * other.val);
	}

	void operator*= (Modint other) {
		val *= other.val;
		if (val >= MOD) val %= MOD;
	}

	bool operator== (Modint other) {
		return val == other.val;
	}

	bool operator!= (Modint other) {
		return val != other.val;
	}
};

Modint exp (Modint a, long long k) {
	Modint res = 1;
	while (k) {
		if (k & 1) res *= a;
		a *= a;
		k >>= 1;
	}
	return res;
}

Modint inv (Modint a) {
	return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
	out << p.val;
	return out;
}

const int maxn = 2e5;

vector<Modint> fact(maxn + 1, 1);
vector<Modint> inv_fact(maxn + 1, 1);

void preC() {
	for (int i = 2; i <= maxn; i++) {
		fact[i] = fact[i - 1] * i;
	}
	inv_fact[maxn] = inv(fact[maxn]);
	for (int i = maxn - 1; i >= 0; i--) inv_fact[i] = inv_fact[i + 1] * (i + 1);
}

Modint C(int n, int r) { // nCr % MOD
	if (n < r) return 0;
	return fact[n] * inv_fact[r] * inv_fact[n - r];
}

class MainClass {
public:

	void solve() {

		int n, m; cin >> n >> m;

		if (m == 1) {
			cout << 1;
			return;
		}

		int lgm = log2(m) + 1;

		Modint ans = 0;
		vector<Modint> dp(m + 1, 1);

		for (int i = 1; i <= lgm; i++) {
			vector<Modint> new_dp(m + 1, 0);
			Modint curr = 0;

			for (int j = 1; j <= m; j++) {
				for (int k = 2 * j; k <= m; k += j) new_dp[k] += dp[j];
				curr += dp[j];
			}

			ans += C(n - 1, i - 1) * curr;
			swap(dp, new_dp);
		}

		cout << ans;

		return;
	}
};

int main() {
	preC();

	int test = 1; //cin >> test;
	for (int tst = 1; tst <= test; ++tst) {
		MainClass Ausmosian;

		Ausmosian.solve();
		cout << "\n";
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) begin(v), end(v)
#define sz(v) v.size()
#define INF 1e18+9
#define EPSILON 1e-14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
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;
  }
  // 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, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vector<pair<long long, long long> > prime_factorize(long long N) {
  vector<pair<long long, long long> > res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0; // 指数
    // 割れる限り割り続ける
    while (N % a == 0) {
     ++ex;
      N /= a;
    }
    // その結果を push
    res.push_back({a, ex});
  }
  // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}

vector<mint> fac(2000003, 1);
void calc(int n){
  rep(i, n){
    fac.at(i+1) = fac.at(i) * (i+1);
  }
  return;
}

mint mcom(int n, int k){ // nCk
  if(n-k < 0){
      return 0;
  }
  mint a = fac.at(n);
  mint b = fac.at(k);
  mint d = fac.at(n-k);
  mint ans = a / (b * d);
  return ans;
}

int main()
{
    ll N, M;
    cin >> N >> M;
    calc(2000000);
    mint ans = 0;
    rep2(i, 1, M+1){
        vector<pair<ll, ll>> pf = prime_factorize(i);
        mint t = 1;
        for(auto p : pf){
            t *= mcom(p.second+N-1, p.second);
        }
        ans += t;
    }
    cout << ans << '\n';
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define fore(i_in,a) for (auto& i_in: a)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fio() cin.tie(nullptr);ios::sync_with_stdio(false);
#define DEBUG_CTN(v) cerr<<#v<<":";for(auto itr=v.begin();itr!=v.end();itr++) cerr<<" "<<*itr; cerr<<endl
template<class T> bool chmax(T &a, const T &b) {if (a<b) { a = b; return true; } return 0;}
template<class T> bool chmin(T &a, const T &b) {if (a>b) { a = b; return true; } return 0;}
template<class T> void print(const T &t) { cout << t << "\n"; }
const ll INF = 1LL << 62;
const int iINF = 1 << 30;

string s;

int main() {
    fio(); cin>>s;
    auto itr = s.find('.');
    print(s.substr(0,itr));
}

#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long ll;

vector<ll> v;

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

	int n; cin >> n; v.resize(n);
	for (auto& x : v) { cin >> x; }

	ll res = 0; for (auto& x : v)
		res += x * x * (n - 1);

	ll s = accumulate(v.begin(), v.end(), 0ll);
	for (auto& x : v) res -= x * (s - x);
	cout << res << '\n'; cin.ignore(2); return 0;
}


#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long
#define F first
#define S second
#define pb push_back

using namespace std;

const ll mx1=3e5+6, mx2=6e3+6, mod=1e9+7, lg=30;

ll a[10];

int main(){
	fast;
	ll sum=0;
	for(int i=0; i<4; i++){
		cin>>a[i];
		sum+=a[i];
	}
	for(int msk=0; msk<(1<<4); msk++){
		ll sum2=0;
		for(int i=0; i<4; i++) if((1<<i)&msk) sum2+=a[i];
		if(sum2*2==sum){
			cout<<"Yes"<<endl;
			exit(0);
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
#define mul(a, b) ((a*b)%MOD)
#define add(a, b) ((a+b)%MOD)
#define dec(a, b) ((a-b+MOD)%MOD)
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int INF = 1e9;
const long LINF = 1e18;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());
// inv[1] = 1;
// fac[0] = ifac[0] = 1;
// for(int i = 2; i <= 500000; i++) inv[i]=MOD-(MOD/i)*inv[MOD%i]%MOD;
// for(int i = 1; i <= 500000; i++) fac[i] = mul(i, fac[i-1]), ifac[i] = mul(inv[i], ifac[i-1]);
// /mnt/c/Users/vince/Desktop/POST-IOI/

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	long A[4];
	scanf("%lld %lld %lld %lld", &A[0], &A[1], &A[2], &A[3]);
	sort(A, A+4);
	bool bol = 0;
	do
	{
		if(A[0] == A[1] + A[2] + A[3]) bol = 1;
		if(A[0]+A[1] == A[2] + A[3]) bol = 1;
		if(A[0]+A[1]+A[2] == A[3]) bol = 1;
	}while(next_permutation(A, A+4));

	if(bol) printf("Yes\n");
	else printf("No\n");

}


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

int main() {
    int64_t R, C;
    cin >> R >> C;
    vector<vector<int64_t>> A(R, vector<int64_t>(C - 1));
    vector<vector<int64_t>> B(R - 1, vector<int64_t>(C));
    for (int64_t i = 0; i < R; i++) {
        for (int64_t j = 0; j < C - 1; j++) {
            cin >> A[i][j];
        }
    }
    for (int64_t i = 0; i < R - 1; i++) {
        for (int64_t j = 0; j < C; j++) {
            cin >> B[i][j];
        }
    }

    vector<vector<int64_t>> cost(R, vector<int64_t>(C, LLONG_MAX));
    struct Element {
        int64_t r, c, cost;
        bool operator>(const Element& rhs) const {
            return cost > rhs.cost;
        }
    };
    priority_queue<Element, vector<Element>, greater<Element>> pq;

    pq.push({ 0, 0, cost[0][0] = 0 });
    while (!pq.empty()) {
        Element t = pq.top();
        pq.pop();
        if (t.cost > cost[t.r][t.c]) {
            continue;
        }

        if (t.r == R - 1 && t.c == C - 1) {
            break;
        }

        if (t.c < C - 1) {
            int64_t new_cost = t.cost + A[t.r][t.c];
            if (new_cost < cost[t.r][t.c + 1]) {
                pq.push({ t.r, t.c + 1, cost[t.r][t.c + 1] = new_cost });
            }
        }
        if (t.c > 0) {
            int64_t new_cost = t.cost + A[t.r][t.c - 1];
            if (new_cost < cost[t.r][t.c - 1]) {
                pq.push({ t.r, t.c - 1, cost[t.r][t.c - 1] = new_cost });
            }
        }
        if (t.r < R - 1) {
            int64_t new_cost = t.cost + B[t.r][t.c];
            if (new_cost < cost[t.r + 1][t.c]) {
                pq.push({ t.r + 1, t.c, cost[t.r + 1][t.c] = new_cost });
            }
        }
        for (int64_t i = 1; i <= t.r; i++) {
            int64_t new_cost = t.cost + 1 + i;
            if (new_cost < cost[t.r - i][t.c]) {
                pq.push({ t.r - i, t.c, cost[t.r - i][t.c] = new_cost });
            }
        }
    }

    cout << cost[R - 1][C - 1] << endl;
}

// E - 潜入
#include <bits/stdc++.h>
using namespace std;
#define vec vector
using vi = vec<int>;
using PR = pair<int,int>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int V; // 頂点数
vec<vec<PR>> G; // [from]<to, cost> 隣接リスト
int INF = 1e9;

vi dijkstra(int s){
	vi dist(V, INF);
	dist[s] = 0;
	priority_queue<PR, vec<PR>, greater<PR>> pq;
	pq.push({0, s});
	while(pq.size()){
		auto[from_d, from_v] = pq.top(); pq.pop();
		if(dist[from_v] < from_d) continue;
		for(auto[to_u, to_d]:G[from_v]){
			to_d += dist[from_v];
			if(dist[to_u] <= to_d) continue;
			dist[to_u] = to_d;
			pq.push({to_d, to_u});
		}
	}
	return dist;
}

int main(){
	int R, C; cin>>R>>C;

	auto rc2id = [&](int r, int c){ return r*C + c; };

	V = R*C*2;
	G.resize(V);

	int x, a, b;
	rep(r, R) rep(c, C-1){
		cin>>x;
		a = rc2id(r, c), b = rc2id(r, c+1);
		G[a].emplace_back(b, x), G[b].emplace_back(a, x);
	}

	rep(r, R-1) rep(c, C){
		cin>>x;
		G[rc2id(r, c)].emplace_back(rc2id(r+1, c), x);
	}

	rep(r, R) rep(c, C){
		a = rc2id(r, c), b = rc2id(r, c+R*C);
		G[a].emplace_back(b, 1), G[b].emplace_back(a, 0);
		if(r != R-1) G[rc2id(r+1, c+R*C)].emplace_back(rc2id(r, c+R*C), 1);
	}

	cout<< dijkstra(0)[rc2id(R-1,C-1)] <<endl;
}


#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>

#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
using namespace std;

int main(){
    float n,a,b;
    cin >> n;
    vector<float> x(n);
    vector<float> y(n);
    rep(i,n){
        cin >> x[i] >> y[i];
    }
    int count=0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(i!=j){
                if((y[i]-y[j])/(x[i]-x[j])>=-1&&(y[i]-y[j])/(x[i]-x[j])<=1) count++;
            }
        }
    }
    cout << count << endl;
}

#include<bits/stdc++.h>
using namespace std;
double slope(int n,int m,int n1,int m1){
	if(n-n1==0)return 9;
	double i=(m1-m)*1.00;
	double j=(n-n1)*1.00;
	return i/j;
}
int a[100001];
int b[100001];
int main(){
	int n,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d %d",&a[i],&b[i]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			if(slope(a[i],b[i],a[j],b[j])>=-1.000000 && slope(a[i],b[i],a[j],b[j])<=1.000000)ans++;
		}
	cout<<ans;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const ll mod = 1000000007;

int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    string s,str;
    cin>>s;
    ll i,n=s.length();
    for(i=0;i<n;i++)
    {
        if(s[i]=='.')
        {
            break;
        }
        else
            str=str+s[i];
    }
    cout<<str<<"\n";

}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll dp[201][13];

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

    // if a == b or b == 0 => C = 1
    int l;
    cin >> l;
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(int i = 0; i < l; i++) {
    	for(int j = 0; j < 12; j++) {
    		if(dp[i][j] == 0) continue;
    		dp[i + 1][j] += dp[i][j];
    		dp[i + 1][j + 1] += dp[i][j];
    	}
    }
    cout << dp[l - 1][11] << endl;
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) int(x.size())
#define ok cerr<<"ok"<<endl
#define db(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
//1.integer overflow (1e5 * 1e5) (2e9 + 2e9)
//2.runtime error
//3.boundary condition
const int N=(int)1e5+100;
int n,m,col[N];
vector< pair<int,int> > G[N];
void dfs(int now){
    for(pair<int,int> pnow:G[now]){
        if(col[pnow.fi]>0) continue;
        if(col[now]==pnow.se){
            col[pnow.fi]=pnow.se%n+1;
        } else col[pnow.fi]=pnow.se;
        dfs(pnow.fi);
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif
    ms(col,0);
    cin>>n>>m;
    forn(i, m){
        int u,v,c;
        cin>>u>>v>>c;
        G[u].eb(mp(v,c));
        G[v].eb(mp(u,c));
    }
    col[1]=1;
    dfs(1);
    for1(i, n) cout<<col[i]<<'\n';
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}

#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define read(x) for(auto& qw : (x)) cin >> qw;
#define print(x) for(auto& qw : (x)) cout << qw << " "; cout << endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MAX = 1e5 + 10;

vector<int> g[MAX];
int N, M, K;
vector<int> A;
vector<vector<int>> D(18,vector<int>(MAX,0));

void bfs(int s, vector<int> &d){
	fill(all(d), INF);
	queue<int> Q;
	Q.push(s);
	d[s] = 0;

	while(Q.size()){
		int v = Q.front();
		Q.pop();

		for(int u : g[v]){
			if(d[u] != INF) continue;
			d[u] = d[v] + 1;
			Q.push(u);
		}
	}
}

ll DP[(1<<18)][20];

ll solve(int mask, int last){
	if(DP[mask][last] + 1)
		return DP[mask][last];

	if(mask == (1<<K) - 1)
		return 0;

	ll ans = LINF;

	for(int i = 0; i < K; i++){
		if(mask >> i & 1) continue;

		int n_mask = mask | (1 << i);

		ans = min(ans, (ll)D[last][A[i]] + solve(n_mask, i));
	}

	return DP[mask][last] = ans;
}

void test_case(){
	cin >> N >> M;

	while(M--){
		int a,b;
		cin >> a >> b;
		a--;b--;

		g[a].pb(b);
		g[b].pb(a);
	}

	cin >> K;
	A.resize(K);
	for(int& x : A){
		cin >> x;
		x--;
	}

	for(int i = 0; i < K; i++)
		bfs(A[i],D[i]);

	memset(DP, -1, sizeof DP);

	ll ans = LINF;
	for(int i = 0; i < K; i++)
		ans = min(ans, 1 + solve(1<<i, i));

	cout << (ans >= INF ? -1 : ans) << endl;
}

int main(){ _

	int tt = 1;
//	cin >> tt;

	while(tt--){
		test_case();
	}

	return 0;
}


#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
const int N = 1e6 + 50;

ll M;
char s[N];

bool mul(ll &x, ll y){
    ll tt = 0;
    while(y){
    	if(x > M)  return 0;
        if(y & 1)  tt += x;
        x = x + x,  y >>= 1;
        if(tt > M)  return 0;
    }
    x = tt;
    return 1;
}

bool check(ll bs){
    ll now = 0;
    for(int i = 1; s[i]; ++i){
        int bt = s[i] - '0';
        bool ok = mul(now, bs);
        now += bt;
        if(!ok || now > M)  return 0;
    }
    return 1;
}

int main(){
    scanf("%s%lld", s + 1, &M);
    int mx = 0;
    for(int i = 1; s[i]; ++i)  mx = max(mx, s[i] - '0');
    ++mx;
	if(!check(mx))  printf("0");
	else{
		ll l = mx, r = 1e18, ans;
		if(strlen(s + 1) == 1){
			if(s[1] - '0' <= M)  puts("1");
			else  puts("0");
			return 0;
		}
		while(l <= r){
			ll mid = (l + r) >> 1;
			if(check(mid))  ans = mid, l = mid + 1;
			else  r = mid - 1;
		}
		printf("%lld", ans - mx + 1);
	}
}

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

typedef long long ll;

int n;

string t,s;

int main()
{
	cin>>n;
	cin>>t;
	while(s.size()<t.size()+3-1)
		s+="110";
	int m=s.size();
	int cnt=0,ok0=0,ok1=0;
	for(int i=0;i<3;i++)
	{
		int ok=1;
		for(int j=0;j<t.size();j++)
			ok&=t[j]==s[i+j];
		cnt+=ok;
		if(i==0)
			ok0=ok;
		if(i==1)
			ok1=ok;
	}
	ll ans=1e10-m/3+1;
	ans*=cnt;
	if(t.size()%3==0&&ok0)
		ans++;
	if(t.size()%3==2&&(ok0||ok1))
		ans++;
	printf("%lld\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 5;
// int tree[maxn];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// iota(tree, tree + maxn, 0);
	string s;
	cin >> s;
	cout << s.substr(1) << s[0] << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long double ld;
/*
#include <chrono>
using namespace std::chrono;
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<lli,lli>, null_type,less<pair<lli,lli>>, rb_tree_tag,tree_order_statistics_node_update>
*/
#define endl "\n"
#define pb push_back
const lli mod=1e9+7;
const lli mod1=998244353;
#define fir first
#define sec second
#define plli pair<lli,lli>
/*
lli power(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
lli powermod(lli a, lli b)
{
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = ((res%mod)*(a%mod))%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}
*/
bool comp(plli &p1,plli &p2)
{
    return (p1.fir>p2.fir || (p1.fir==p2.fir and p1.sec<p2.sec));
}
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    lli T;
    T=1;
    //cin>>T;
    while(T--)
    {
        lli i,j,k;
        vector<lli> v;
        lli vis[51]={0};
        for(i=2;i<=50;i++)
        {
            if(!vis[i])
            {
                for(j=i*i;j<=50;j+=i)
                {
                    vis[j]=1;
                }
                v.pb(i);
            }
        }
        lli x=v.size();
        lli n;
        cin>>n;
        lli a[n];
        for(i=0;i<n;i++)
            cin>>a[i];
        lli b[n];
        lli ans=mod*mod;
        for(i=0;i<(1<<x);i++)
        {
            for(j=0;j<n;j++)
                b[j]=a[j];
            lli temp=1;
            for(j=0;j<x;j++)
            {
                if(i&(1<<j))
                {
                    for(k=0;k<n;k++)
                    {
                        while(b[k]%v[j]==0)
                            b[k]/=v[j];
                    }
                    temp*=v[j];
                }
            }
            lli flag=1;
            for(j=0;j<n;j++)
                if(b[j]==a[j])
                    flag=0;
            if(flag)
                {ans=min(ans,temp);}
        }
        cout<<ans<<"\n";
    }
    return 0;
}

#include<bits/stdc++.h>
#include<iostream>
#include<set>
#include<map>
#include<iterator>
#define ll              long long
#define lli             long long int
#define pb              push_back
#define RIP(i,n)        for(int i=0; i<n; i++)
#define RIP1(i,n)       for(int i=n-1; i>=0; i--)
#define FOR(i,a,b)      for(int i=a;i<(b); i++)
#define FOR1(i,a,b)     for(int i=a; i>=(b); i--)
#define sc(a)           scanf("%lld",&a)
#define SC(a)           scanf("%d",&a)
#define cin(a)          cin >> a
#define cout(a)         cout << a
#define pi              acos(-1)
#define pr(a)           printf("%lld\n",a)
#define PR(a)           printf("%lld ",a)
#define s(a,b)          sort(a,b)
#define sz(x)           (int)(x).size()
#define nl              '\n'
#define Max             1001
#define mod             1e9 + 7
using namespace std;
void c_p_c()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /*#ifdef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif*/
}
int dp[1001][1001],a[Max],b[Max];
int cost(int i,int j)
{
    if(i==-1 && j==-1)
    {
        return 0;
    }
    if(i==-1)
    {
        return j+1;
    }
    if(j==-1)
    {
        return i+1;
    }
    if(dp[i][j]!=0)
    {
        return dp[i][j];
    }

    int x=cost(i-1,j)+1;
    int y=cost(i,j-1)+1;
    int z=cost(i-1,j-1)+(a[i]!=b[j]);

    return dp[i][j]=min(x,min(y,z));
}
int main()
{
    c_p_c();
    int n,m;
    SC(n);SC(m);
    //int a[n],b[m];
    RIP(i,n)
    {
        SC(a[i]);
    }
    RIP(i,m)
    {
        SC(b[i]);
    }
    int ans = cost(n-1,m-1);
    cout << ans << nl;
}


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

#define int long long
#define pb push_back
#define all(v) begin(v), end(v)
#define inf (int)(4e18)
#define N (int)(2e5 + 10)

void testCase() {
     int n; cin >> n;
     vector<int> a(n);
     for (int &i : a) cin >> i;
     sort(all(a));
     int ans = 0;
     for (int i = 0; i < n; i++)
          ans += (2 * i + 1 - n) * a[i];     cout << ans;
}

/* Work hard .. Calm and proceed */
int32_t main() {
     ios_base::sync_with_stdio(false);
     cin.tie(nullptr), cout.tie(nullptr);
     int t_c = 1;
     // cin >> t_c;
     while (t_c--)
          testCase();
}

#include<bits/stdc++.h>
#define lli long long int
#define endl "\n"
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
using namespace std;
lli min(lli a,lli b)
{
    if (a<b)
    {
        return a;
    }
    else
    {
        return b;
    }
}
lli max(lli a,lli b)
{
    if (a>b)
    {
        return a;
    }
    else
    {
        return b;
    }
}

void solve()
{
    lli a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,min(b,min(c,d)))<<endl;
}

int main(){
    fastio;
    cout<<fixed;
    cout<<setprecision(10);
    lli t=1;
   //cin>>t;
    for(lli i=1;i<=t;i++)
    {
        solve();
    }
    return 0;

}