#include <bits/stdc++.h>

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

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

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

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

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

using namespace std;

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

/* Some Libraries */

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

ll my_sqrt(__int128_t n){
    __int128_t lo=0,hi=n;
    while(hi-lo>1){
        __int128_t c = (lo+hi)/2;
        (c*c<n)?(lo=c):(hi=c);
    }
    return hi;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll R,X,Y; cin>>R>>X>>Y;
    if (X*X+Y*Y==R*R){
        cout<<"1\n";
        return 0;
    }
    if (X*X+Y*Y<R*R){
        cout<<"2\n";
        return 0;
    }
    ll ans = (my_sqrt(X*X+Y*Y)+R-1)/R;
    cout<<ans<<endl;
    return 0;
}

#include<iostream>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<vector>
#include<iomanip>
#include<fstream>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<sstream>
using namespace std;
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
//string::npos
#define eps 1e-6
const double pi = 3.141592653589;
const int maxn = 2e5+10;
const int maxm = 100040;
//const int mod = 998244353;
const int inf = 0x3f3f3f3f;
typedef long long ll;

int main(){
    sync;

    double r, x, y;
    cin >> r >> x >> y;
    ll ans = ceil(sqrt(x*x+y*y)/r);
    //ll ans = ceil(sqrt(ceil(x*x+y*y/r/r);
    //cout << sqrt(x*x+y*y)/r*1.0 << endl;
    if(sqrt(x*x+y*y)/r<1) cout << 2 << endl;
    else cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<string> S(N);
    REP(i, 0, N) cin >> S[i];

    vector<vector<bool>> d(N, vector<bool>(N, false));
    REP(i, 0, N) REP(j, 0, N) if (S[i][j] == '1') d[i][j] = true;
    REP(k, 0, N) REP(i, 0, N) REP(j, 0, N) if (d[i][k] && d[k][j]) d[i][j] = true;

    double ans = 0;
    REP(i, 0, N) {
        int cnt = 0;
        REP(j, 0, N) {
            if (i == j || d[j][i]) cnt++;
        }
        ans += (double)(1) / cnt;
    }
    cout << fixed << setprecision(15);
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define ff              first
#define ss              second
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define pii             pair<int,int>
#define pll             pair<long long,long long>
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost           ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define sss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;

/*
int bs(int l,int r,int n)
{
    int mid,res=inf;

    while(l<=r)
    {
        mid=l+(r-l)/2;

        if(check(mid,n))
        {
            r=mid-1;
            res=min(res,mid);
        }
        else
            l=mid+1;

    }

    return res;
}
*/

//--------------------------code starts here---------------------------------------
int L;

unsigned long long dp[205][13];

unsigned long long func(int pos,int taken)
{
    if(taken==11)
    {
        return 1;
    }

    if(pos==L)
        return 0;
    if(dp[pos][taken]!=-1)
        return dp[pos][taken];

    return dp[pos][taken]=func(pos+1,taken)+func(pos+1,taken+1);
}

int main()
{
    cin>>L;
    mem(dp,-1);
    cout<<func(1,0)<<nl;

	return 0;
}


// Problem: C - Squared Error
// Contest: AtCoder - AtCoder Beginner Contest 194
// URL: https://atcoder.jp/contests/abc194/tasks/abc194_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Parsed on: 10-03-2021 21:39:49 IST (UTC+05:30)
// Author: Kapil Choudhary
// ********************************************************************
// कर्मण्येवाधिकारस्ते मा फलेषु कदाचन |
// मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि || १.४७ ||
// ********************************************************************

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int>	vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii>	vpii;
typedef vector<pll>	vpll;
typedef vector<vi> vvi;
typedef vector<vll>	vvll;
typedef vector<vull> vvull;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}

const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;

void solve()
{
  	int n; cin >> n;
  	vi cnt(401, 0);
  	for(int i = 0; i < n; i++) {
  		int x; cin >> x;
  		x += 200;
  		cnt[x]++;
  	}

  	ll res = 0LL;
  	for(int i = 0; i <= 400; i++) {
  		for(int j = i + 1; j <= 400; j++) {
  			res += (ll)cnt[i] * cnt[j] * (i - j) * (i - j);
  		}
  	}

  	cout << res << "\n";
}

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

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

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

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef complex <double> cp;
#define debug(a) cout<<#a<<":"<<a<<endl;
#define fr freopen("in.txt","r",stdin);
#define Fill(x,a) memset(x,a,sizeof(x))
#define cpy(a,b) memcpy(a,b,sizeof(a))
const double PI = acos(-1);
const ll INF=0x3f3f3f3f;
const ll N=1e6+7;
const ll mod=1e9+7;
ll maxn,minn;
ll T,n,m,q;
ll arr[N];
ll dp[N];
ll sq[N];

int main(){
	ll ans = 0;
	cin >> n;
	sq[0] = 0;
	for(ll i = 1; i <= n; i ++ ){
		scanf("%lld",arr + i);
		sq[i] = sq[i - 1] + arr[i] * arr[i];
	}
	dp[n + 1] = 0;
	for(ll i = n; i >= 1; i --){
		dp[i] = dp[i + 1] + arr[i];
	}
	for(ll i = 1; i <= n; i ++ ){
		ans = ans + sq[n] - sq[i];
		ans = ans + (n - i) * arr[i] * arr[i];
		ans = ans - 2 * arr[i] * (dp[i + 1]);
	}
	cout << ans << endl;

	return 0;
}


//
// Created on 2021/03/20.
//

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
typedef long long ll;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const long long LINF =1e18;
const int INF = 1e9;

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int ans = -INF;

    for (int i = a; i <= b; ++i) {
        for (int j = c; j <= d; ++j) {

            chmax(ans,i-j);
        }
    }

    cout<<ans<<endl;
    return 0;
}

#include <iostream>
using namespace std;

int ri(){
    int n = 0;
    scanf("%d", &n);
    return n;
}

int main(){
    int min, max;
    int a=ri();
    int b=ri();
    int c=ri();
    int d=ri();

    if(a<b) max=b;
    else max = a;

    if(c>d) min=d;
    else min = c;

    max -= min;
    printf("%d", max);
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <unordered_set>
#include <algorithm>
using namespace std;
typedef long long ll;

vector<vector<pair<int, ll>>> adj;
vector<ll> dist;
const int MOD = 1e9 + 7;

int modadd(int a, int b) {
	return (a % MOD + b % MOD) % MOD;
}

int modmul(int a, int b) {
	return (ll) a * b % MOD;
}

void dfs(int u, int p, ll currdist) {
	dist[u] = currdist;
	for (auto v : adj[u]) if (v.first != p) dfs(v.first, u, currdist ^ v.second);
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	adj.resize(n + 1);
	dist.resize(n + 1);

	for (int i = 0; i < n - 1; i++) {
		ll u, v, w;
		cin >> u >> v >> w;
		adj[u].push_back({v, w});
		adj[v].push_back({u, w});
	}
	dfs(1, 0, 0);
	int ans = 0;

	for (int bitpos = 0; bitpos < 61; bitpos++) {
		ll mask = (1ll << bitpos);
		int ones = 0, zeros = 0;
		for (int u = 1; u <= n; u++) {
			ll currdist = dist[u];
			if (currdist & mask) ones++;
			else zeros++;
		}
		int count = modmul(ones, zeros);
		ans = modadd(ans, modmul(count, mask % MOD));
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
	int n =0 , m =0 ;
	cin >> n >> m;
	int s =0 , s2=0;
	vector<pair<int , int > > ar;
	for(int i=0;i<m;i++){
		cin >> s >> s2;
		ar.emplace_back(s ,s2 );
	}

	int k =0 ;
	cin >> k;
	vector< pair<int , int > > g ;
	for(int i=0;i<k;i++){
		cin >> s >> s2 ;
		g.emplace_back(s,s2);
	}
	int mx =0 ;
	for(int mask =0 ;mask < (1 << k);mask ++ ){
		int pts =0 ;

		map<int , bool > tmp;
		for(int i =k-1 ;i>=0;i--){
			if(mask &(1LL << i)){

				tmp[g[i].first] = 1;
			}
			else
				tmp[g[i].second] = 1;
		}

		for(int i =0 ;i<m;i++){
			if(tmp[ar[i].first] &&tmp[ar[i].second])
				pts ++ ;
		}

		mx = max(mx, pts );
	}

	cout << mx << endl;
return 0;}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 998244353
#define infi 1010000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

class Combination {
    vl fac,finv,inv;
public:
    Combination(ll n) {
        n++;
        fac.resize(n);finv.resize(n);inv.resize(n);

        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        reps(i,2,n){
            fac[i] = fac[i-1]*(ll)i%mod;
            inv[i] = (ll)mod - inv[mod%i]*(ll)(mod/i)%mod;
            finv[i] = finv[i-1]*inv[i]%mod;
        }
    }

    ll com(ll n, ll m){
        if(n < m) return 0;
        if(n < 0 || m < 0) return 0;
        return fac[n]*(finv[m]*finv[n-m]%mod)%mod;
    }
};

int main(){

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

    int N,M;
    cin >> N >> M;

    Combination C(10000);

    int n = 14;
    vvl dp(n+1,vl(M+1,0));
    dp[0][0] = 1;

    rep(i,n){
        int a = int(1<<i);
        rep(k,M+1){
            dp[i+1][k] += dp[i][k];
            dp[i+1][k] %= mod;

            if(dp[i][k] == 0) continue;
            for (int j = 2; j <= N; j += 2) {
                if(a*j+k > M) break;

                dp[i+1][a*j+k] += dp[i][k]*C.com((ll)N,(ll)j)%mod;
                dp[i+1][a*j+k] %= mod;
            }
        }

    }

    cout << dp[n][M] << endl;

    return 0;
}

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<cstdlib>
#include<utility>
using namespace std;
const int mod=998244353;
int f[17][5000+5],c[5000+5][5000+5];
void add(int &x,int y){x=(x+y)%mod;}
int main()
{
    int n,m,i,j,k,val;
    c[0][0]=c[1][1]=c[1][0]=1;
    for (i=2;i<=5000;i++)
        c[i][0]=1;
    for (i=2;i<=5000;i++)
    {
        for (j=1;j<=i;j++)
            c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
    }
    scanf("%d%d",&n,&m);
    f[0][0]=1;
    for (i=1;i<=15;i++)
    {
        val=1<<(i-1);
        for (k=0;k<=n&&k*val<=m;k+=2)
            for (j=k*val;j<=m;j++)
                add(f[i][j],1ll*f[i-1][j-k*val]*c[n][k]%mod);
    }
    printf("%d\n",f[15][m]);
}


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

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>
#define pqll priority_queue<ll>

constexpr ll INF = (1ll << 60);
constexpr ll mod = 1000000007;  // 998244353;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

void pt_vvll(vvll v) {
    rep(i, v.size()) {
        rep(j, v[0].size()) {
            cout << v[i][j];
            if (j != v[0].size() - 1)
                cout << " ";
            else
                cout << "\n";
        }
    }
}
void pt_vll(vll v) {
    rep(i, v.size()) {
        cout << v[i];
        if (i == v.size() - 1)
            cout << "\n";
        else
            cout << " ";
    }
}

vector<ll> sum, ans;
void pre_process(vector<ll> &a, vector<ll> &s) {  //累積和のvector
    ll n = (ll)a.size();
    s.assign(n + 1, 0);
    for (ll i = 0; i < n; i++) {
        s[i + 1] = s[i] + a[i];
    }
}
ll query(ll i, ll j, vector<ll> &s) {  //区間[i,j]の和
    return (s[j] - s[i]);
}

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

    ll H, W, N, M;
    cin >> H >> W >> N >> M;
    vvll g(H, vll(W));
    vll A(N), B(N), C(M), D(M);
    rep(i, N) {
        cin >> A[i] >> B[i];
        g[--A[i]][--B[i]] = 1;
    }
    rep(i, M) {
        cin >> C[i] >> D[i];
        g[--C[i]][--D[i]] = -1;
    }

    vvll dp1 = g, dp2 = g, dp3 = g, dp4 = g;

    rep(j, W) {
        rep(i, H) {
            if (g[i][j] == -1) continue;
            if (i + 1 < H && g[i + 1][j] != -1) chmax(dp1[i + 1][j], dp1[i][j]);
        }
    }
    for (ll i = H - 1; i >= 0; i--) {
        rep(j, W) {
            if (g[i][j] == -1) continue;
            if (0 <= i - 1 && g[i - 1][j] != -1)
                chmax(dp2[i - 1][j], dp2[i][j]);
        }
    }
    rep(i, H) {
        rep(j, W) {
            if (g[i][j] == -1) continue;
            if (j + 1 < W && g[i][j + 1] != -1) chmax(dp3[i][j + 1], dp3[i][j]);
        }
    }
    rep(i, H) {
        for (ll j = W - 1; j >= 0; j--) {
            if (g[i][j] == -1) continue;
            if (j - 1 >= 0 && g[i][j - 1] != -1)
                chmax(dp4[i][j - 1], dp4[i][j]);
        }
    }
    /*
        cout << "\n";
        cout << "dp1\n";
        pt_vvll(dp1);

        cout << "\n";
        cout << "dp2\n";
        pt_vvll(dp2);
        cout << "\n";
        cout << "dp3\n";
        pt_vvll(dp3);
        cout << "\n";
        cout << "dp4\n";
        pt_vvll(dp4);
        cout << "\n";

        pt_vvll(g);*/
    ll ans = 0;
    rep(i, H) {
        rep(j, W) {
            ll pl = 0;
            if ((dp1[i][j] + dp2[i][j] + dp3[i][j] + dp4[i][j] > 0)) pl = 1;

            ans += pl;
        }
    }

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

#include <bits/stdc++.h>
using namespace std;
#define deb(k) cerr << #k << ": " << k << "\n";
#define size(a) (int)a.size()
#define fastcin cin.tie(0)->sync_with_stdio(0);
#define st first
#define nd second
#define pb push_back
#define mk make_pair
#define int long long
typedef long double ldbl;
typedef double dbl;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef vector<int> vint;
#define MAXN 2000
#define MAXLG 20
const int inf = 0x3f3f3f3f;
const ll mod = 1000000007;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const int N = 300100;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int h, w;
int n, m;
set<int>bulb[2][1600], block[2][1600];

bool check(int i, int j, int t){
	auto it = bulb[t][i].lower_bound(j);
	auto it1 = block[t][i].lower_bound(j);
	if(*it1 == j) return false;
	if(it != bulb[t][i].end() && (it1 == block[t][i].end() || *it < *it1)) return true;
	if(it != bulb[t][i].begin() && it1 == block[t][i].begin()) return true;
	if(it != bulb[t][i].begin()){
		it--;
		it1--;
		if(*it > *it1) return true;
	}
	return false;
}

void solve(){
	cin>>h>>w>>n>>m;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		bulb[0][x].insert(y);
		bulb[1][y].insert(x);
	}
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		block[0][x].insert(y);
		block[1][y].insert(x);
	}
	int ans = 0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(check(i, j, 0) || check(j, i, 1)){
				ans++;
				//cout<<i<<" "<<j<<"\n";
			}
		}
	}
	cout<<ans<<"\n";

	// Have you read the problem again?
	// Maybe you understood the wrong problem
}

int32_t main(){
	fastcin;
	int t_ = 1;
	//cin>>t_;
	while(t_--)
		solve();
	return 0;
}


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

// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint1000000007;
// using mint2 = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()

const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;
//const Int mod = 998244353;

typedef struct {
    int64_t to, weight;
} edge;

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

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (auto &e : v) {
        is >> e;
    }
    return is;
}

bool print_space_enable = false;
void print() {
    std::cout << '\n';
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    std::cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

template<class T>
vector<T> make_vec(size_t n, T val) {
    return vector<T>(n, val);
}

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

bool is_overflow(Int a, Int b) {
    return a > INF / b;
}

void solve() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    cin >> a;
    vector<Int> b = a;
    for (Int i = 0; i + 1 < n; i++) {
        b[i + 1] += b[i];
    }
    for (Int i = 0; i + 1 < n; i++) {
        b[i + 1] += b[i];
    }
    vector<Int> c = a;
    for (Int i = 0; i + 1 < n; i++) {
        c[i + 1] = max(c[i], c[i + 1]);
    }
    for (Int i = 0; i < n; i++) {
        print(b[i] + (i + 1) * c[i]);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    //Int _t; cin >> _t; while (_t--) solve();
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> V(N, 0);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    V.at(A)++;
  }
  int ans = 0, X = V.at(0);
  for (int i = 0; i < N; i++) {
    X = min(K,min(X, V.at(i)));
    ans += X;
  }
  cout << ans << endl;
}


#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

using namespace std;

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

    int ans = (N - 1) / 100 + 1;

    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>

#define ll long long
#define ld long double
#define pb push_back
#define all(v) ((v).begin()),((v).end())
#define rep(i, val, n) for(int i = val; i < (n); i++)
#define repr(i, val, n) for(int i = n - 1; i >= val; i--)
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 2e18 + 100;
const double eps = 1e-7;
const ld pi = acos(-1);
const int N = 1e5 + 2;
//bool is_vowel(char a){ return (a=='A' || a=='E' || a=='O' || a=='I' || a=='U');}
//int dx[] = {2,-2,2,-2,1,1,-1,-1}, dy[] = {1,1,-1,-1,2,-2,2,-2}; // knight moves
//int dx[] = {0,0,1,1,1,-1,-1,-1}, dy[] = {-1,1,-1,0,1,-1,0,1}; // 8 adjacent neighbours
//int dx[] = {0,0,1,-1}, dy[] = {-1,1,0,0}; //4 adjacent neighbours
//bool inside(int x, int y,int n,int m){ return (x >= 0 && x < n && y >= 0 && y < m);}
void test() {
    int n;cin>>n;
    cout<<(n + 99) / 100;
}

int main() {
//    precompute();
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int cases = 1, c = 1;
//    cin >> cases;
    while (cases--) {
//        cout<<"Case #"<<c++<<": ";
        test();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define deb(x) cout << #x << " " << x << endl;
#define mod 1000000007
#define fast std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define endl "\n"

const ll INF = 1e18;
const ll NEGINF = -1 * INF;

/*NOTES: Take care of ll vs int
         Never use an iterator after erasing it
*/

void solve()
{
    vector<int> a(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    if (a[1] - a[0] == a[2] - a[1])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
int main()
{
     ll i,j,a,b,c;
        cin>>a>>b>>c;
        if(2*b==a+c||2*a==b+c||2*c==a+b) printf("Yes\n");
        else printf("No\n");
}


//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int>
#define all(v)          v.begin(),v.end()
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N],b[N];

void  solve(){

}
int n,m;

int32_t main()
{
    FIO
    int k; cin>>k>>n>>m;
    int tot=0;
    fi(i,k) {
        cin>>a[i];
        tot+=a[i];
    }
    int rem=0;
    priority_queue<pii, vector<pii> > p1;
    vip v;
    fi(i,k){
        b[i]=(a[i]*m)/n;
        rem+=b[i];
        p1.push({abs(n*b[i]-m*a[i]),i});
        // v.pb({abs(n*b[i]});
    }
    // fi(i,k) cout<<b[i]<<" "; cout<<"\n";

    rem=m-rem;
    while(rem>0){
        pii p=p1.top(); p1.pop();
        b[p.ss]+=1;
        // p1.push({p.ff+1,p.ss});
        rem--;
    }
    fi(i,k) cout<<b[i]<<" "; cout<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

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

int main() {
  ll K, N, M;
  cin >> K >> N >> M;
  vector<ll> A(K);
  vector<ll> B(K);
  // lib priority queue 使い方
  // l が既存, r が new element. new element の優先度が高い時は true を返すようにする
  auto c = [](pair<ll, pair<ll, ll>> l, pair<ll, pair<ll, ll>> r) {
    return l.second.first == r.second.first ? l.second.second >= r.second.second : l.second.first <= r.second.first;
  };
  priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>, decltype(c)> que(c);
  ll sum = 0;
  rep(i, 0, K) {
    cin >> A[i];
    B[i] = A[i] * M / N;
    // bi, { cur score, new score }
    que.push({i, {abs(B[i] * N - A[i] * M), abs(B[i] * (N + 1) - A[i] * M)}});
    sum += B[i];
  }

  while (que.size() != 0) {
    auto worst = que.top();
    que.pop();
    if (sum < M) {
      B[worst.first]++;
    } else {
      break;
    }
    sum++;
  }
  rep(i, 0, K) { cout << B[i] << " "; }
}


#include<bits/stdc++.h>
using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)
#define loop1(i,n) for(int i=1;i<=n;i++)
#define rloop(i,n) for(int i=n-1;i>=0;i--)
#define in cin>>
#define ou cout<<
#define nl cout<<endl;
#define yes cout<<"YES"<<endl;
#define no  cout<<"NO"<<endl;
void solve()
{
    int a,b;
    cin>>a>>b;
    if(a==b)
        cout<<a<<endl;
    else
    {
        if(a==0)
        {
            if(b==1)
                cout<<2<<endl;
            else
                cout<<1<<endl;
        }
        else if(a==1)
        {
            if(b==0)
                cout<<2<<endl;
            else
                cout<<0<<endl;
        }
        else
        {
            if(b==0)
                cout<<1<<endl;
            else
                cout<<0<<endl;
        }
    }
}
int main()
{
    //int t;
    //in t;
    //while(t--){
    solve();
    //}
    return 0;
}

#include <iostream>
using namespace std;

int main(){ int x,y;
cin>>x>>y;
if(x==y){cout<<x;}
else if(x==0&&y==1){cout<<2;}
else if(x==0&&y==2){cout<<1;}
else if(x==1&&y==0){cout<<2;}
else if(x==1&&y==2){cout<<0;}
else if(x==2&&y==0){cout<<1;}
else if(x==2&&y==1){cout<<0;}
return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#if 0 //B
#include <iomanip>
#endif
using namespace std;

long long int T[8][8];
int N, K;

int root[9] = { -1,-1,-1,-1,-1,-1,-1,-1,-1 }; // 通る経路。

bool isVisited[8] = { false,false, false, false, false, false, false, false };

int counter = 0;

vector<int> get_unvisited_city(){
    vector<int> vec_city;
    for (int i = 0; i < N; i++) {
        if (isVisited[i] == false) {
            vec_city.push_back(i);
        }
    }
    return vec_city;
}

int number_unvisited() {
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (isVisited[i] != true) cnt++;
    }
    return cnt;
}

// 未訪問の都市IDの中から最も若いIDの都市IDを返す関数。すべて訪問済みなら0を返す
int getUnvisitedCityID() {
    for (int i = 0; i < N; i++) {
        if (isVisited[i] == false) {
            return i;
        }
    }
    return 0;
}

// 階乗をおこなう関数
int kaijou(int x) {
    int ret = 1;
    for (int i = 1; i <= x; i++) {
        ret *= i;
    }
    return ret;
}

void calcTime() {
    long long time = 0;
    for (int i = 0; i < N; i++) {
        int from = root[i];
        int to = root[i + 1];
        time += T[from][to];
    }
    if (time == K) {
        counter++;
    }
}

// n番目に訪問する都市を決める関数
int DecideCityID(int n) {
    if (n == N) {
        // ルートが決まったので時間の計算

        calcTime();
        return 0;
    }
    vector<int> vec_city = get_unvisited_city();
    for (auto it = vec_city.begin(); it != vec_city.end(); it++) {
        isVisited[*it] = true;
        root[n] = *it;

        DecideCityID(n + 1);

        isVisited[*it] = false;
        root[n] = -1;
    }
    return 0;
}

int main()
{

    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> T[i][j];
        }
    }

    int pattern = kaijou(N-1);

    bool root_decided = false;

    root[0] = root[N] = 0;

    int from, to;
    from = 0;
    isVisited[from] = true;
    DecideCityID(1);

    to = getUnvisitedCityID();

    cout << counter;
    return 0;

}

// #pragma GCC optimise ("O1")
#include<bits/stdc++.h>
using namespace std;
#define ll           int
#define rep(i,j,n)   for(ll i=j;i<n;i++)
#define scn(a)       scanf("%d",&a)
#define scns(a,b)    scanf("%d %d",&a,&b)
#define print(a)     printf("%0.10lf",a)
#define vec          vector<ll>
#define pb           push_back
#define pairs        pair<ll,ll>
#define f            first
#define s            second
#define all(v)       v.begin(),v.end()
#define srt(v)       sort(v.begin(),v.end())
#define read(a)       for(auto &it:a) cin>>it;
#define write(a)       for(auto it:a) cout<<it<<" ";
#define mem(a,b)     memset(a,b,sizeof(a))
#define nl           printf("\n")
#define inf          1e9
#define zer          INT_MIN
#define fast         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N=2e3+5;

int main()
{
  int t=1;
  // cin>>t;
  while(t--)
  {
    int n,k; scns(n,k);
    int cost[n+5][n+5];

    rep(i,1,n+1)
    rep(j,1,n+1)
    scn(cost[i][j]);

    vec v;
    int cnt=0;
    rep(i,2,n+1)
    v.pb(i);

    do
    {
      int amt=0;
      amt+=cost[1][v[0]];

      // for(auto it:v)
      // cout<<it<<" ";
      // cout<<endl;

      rep(i,1,v.size())
      amt+=(cost[v[i-1]][v[i]]);
      amt+=cost[v[v.size() - 1]][1];

      // cout<<amt<<" ";

      if(amt==k)
      cnt++;
    } while(next_permutation(all(v)));

    cout<<cnt;
  }
}


//int max = 2 147 483 647 (2^31-1)
//ll max = 9 223 372 036 854 775 807 (2^63-1)
#include<bits/stdc++.h>
using namespace std;

#define forn(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

//Fast input and output
void fast_io(){
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);}

//Printing pairs and vectors
template<typename A, typename B> ostream& operator<< (ostream &cout, pair<A,B> const &p)
{return cout << "(" << p.f << ", " << p.s << ")";}
template<typename A> ostream& operator<< (ostream &cout, vector<A> const&v)
{cout << "["; forn(i,(int)v.size()){ if (i) cout << ", "; cout << v[i];} return cout << "]";}

int main(){
  fast_io();
  int a,b,c; cin >> a >> b >> c;
  cout << 21-a-b-c;
}
//code by DanTheMan

using namespace std;
#include<string>
#include<cmath>
#include<list>
#include<queue>
#include <map>
#include <unordered_map>
#include <set>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ml map<ll,ll>
#define pb push_back
#define mp make_pair
#define ppl pair<ll,ll>
#define F first
#define S second
#define T third
#define Fo fourth
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e9 + 7;
const ll P = 2e5 + 7;
const ll Q = 1e9 + 9;
#include<iterator>
#define EPSILON numeric_limits<double>::epsilon()
#include<tuple>

// struct tup
// {
// 	ll first, second;
// 	string third;
// };

// vector<vl> pr(N, vl(30, 0));

// vl vr;
// ml m;

// void precompute() {
//     fr(i, 2, N) {
//         if (!m[i]) {
//             // cout << i << " ";
//             vr.pb(i);
//             for (ll j = i * i; j < N; j += i)m[j] = 1;
//         }
//     }
// }

// vl pr(P, 0);

// void prime() {
//     fr(i, 2, P) {
//         if (pr[i] == 0) {vr.pb(i); for (ll j = i * i; j <= P; j += i)pr[j] = 1;}
//     }
// }

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

void show(ll a[], ll d) {
	if (d)fr(i, 0, d)cout << a[i] << " ";
}

void inp(ll a[], ll d) {
	fr(i, 0, d)cin >> a[i];
}

void Yesno(ll p) {
	if (p)cout << "YES";
	else cout << "NO";
}

// ll fact(ll n) {
//     ll res = 1;
//     fr (i, 2, n + 1) res = (res * i) % N;
//     return res;
// }

// ll nCr(ll n, ll r) {
//     return fact(n) / (((fact(r) * fact(n - r))) % N);
// }

// ll nPr(ll n, ll r) {
//     return ((fact(n) % N) / (fact(n - r) % N)) ;
// }

// vl rightgreater(ll a[], ll n) {
// 	vl v;
// 	stack<ll> s;
// 	ffr(i, n - 1, 0) {
// 		if (s.size() == 0)v.pb(-1);
// 		else if (s.size() > 0 && s.top() > a[i])v.pb(s.top());
// 		else if (s.size() > 0 && s.top() <= a[i]) {
// 			while (s.size() > 0 && s.top() <= a[i])s.pop();
// 			if (s.size() == 0)v.pb(-1);
// 			else v.pb(s.top());
// 		}
// 		s.push(a[i]);
// 	}
// 	reverse(v.begin(), v.end());
// 	return v;
// }

// vl par, ran;

// ll findpar(ll x) {
// 	if (x == par[x])return x;

// 	return par[x] = findpar(par[x]);
// }

// void Union(ll x, ll y) {
// 	ll parx = findpar(x);
// 	ll pary = findpar(y)Snippet: map;;
// 	if (ran[parx] < ran[pary])par[parx] = pary;
// 	else if (ran[parx] > ran[pary])par[pary] = parx;
// 	else {par[parx] = pary; ran[pary]++;}
// }

// ld nthRoot(ll A, ll N) {
// 	ld xPre = rand() % 10, eps = 1e-3, delX = INT_MAX, xK;
// 	while (delX > eps) {
// 		xK = ((N - 1.0) * xPre + (ld)A / pow(xPre, N - 1)) / (ld)N;
// 		delX = abs(xK - xPre);
// 		xPre = xK;
// 	}
// 	return xK;
// }

// bool comp(tup &a, tup &b) {
// 	if (a.F != b.F)return a.F < b.F;
// 	else return a.S < b.S;
// }

// vl b;
// vector<vector<ppl>> v;
// vector<vl> v;
// // vl dist, cumu;
// // ll n, m;
// // vl link, val;
// // vector<char>a;
// vector<bool> visited;

// ll dfs(ll pnt, ll data[], ll totsum, ll &mi) {
// 	visited[pnt] = true;
// 	ll sum = 0;
// 	for (auto it : v[pnt]) {
// 		if (!visited[it]) {
// 			ll tempans = dfs(it, data, totsum, mi);
// 			mi = min(mi, abs(totsum - (2 * (tempans))));
// 			sum += tempans;
// 		}

// 	}
// 	// cout << pnt << " " << mi << '\n';
// 	// visited[pnt]=false;
// 	sum += data[pnt];
// 	return sum;
// }

void solve() {
	ll x, y, z; cin >> x >> y >> z;
	cout << 21 - (x + y + z);
}

int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif
	// prime();
	// precompute();
	ll t;
	if (1)
		t = 1;
	else
		cin >> t;
	fr(i, 0, t) {
		// cout << "Case #" << i + 1 << ": ";
		solve();
		cout << '\n';
	}
	return 0;
}


// Problem: C - Squared Error
// Contest: AtCoder - AtCoder Beginner Contest 194
// URL: https://atcoder.jp/contests/abc194/tasks/abc194_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms

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

using l = long;
using ll = long long;
using ld = long double;
using db = double;
using str = string;

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vl = vector<long>;
using vll = vector<ll>;

#define mp make_pair
#define f first
#define s second

#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define modinv(a,m) modEx(a,m-2,m)
#define moddiv(a,b,m) (a*modinv(b,m))%m
const ll mod=1e9+7;

/* These template codes have been taken from cp-algorithms */
ll extEuclid(ll a,ll b,ll& x,ll& y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}

	ll x1,y1;
	ll d=extEuclid(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return d;
}

ll modInverse(ll a,ll n){
	ll x,y;
	extEuclid(a,n,x,y);
	return x;
}

ll linearCong(ll a,ll b,ll n){
	ll d=__gcd(a,n);

	if(b%d)
		return -1;
	a/=d;b/=d;n/=d;
	ll a_inv=modInverse(a,n);
	ll ans=(b*a_inv)%n;
	if(ans<0)
		ans+=n;
	return ans;
}

void divisors(map<int,int>& d,ll N){
	for(int div : {2,3,5}){
		int cnt=0;
		if(N%div==0){
			while((N%div)==0){
				N/=div;
				cnt++;
			}
			d[div]=cnt;
		}
	}
	static array<int,8> increments = {4,2,4,2,4,6,2,6};
	int i=0;
	for(ll div=7;div*div<=N;div+=increments[i++]){
		if((N%div)==0){
			int cnt=0;
			while((N%div)==0){
				N/=div;
				cnt++;
			}
			d[div]=cnt;
		}
		if(i==8)
			i=0;
	}
	if(N>1)
		d[N]=1;
}

/* Print the string of digits without leading zero */
void norm(string& str){
	bool zero=true;

	for(auto& c:str){
		if(c!='0')
			zero=false;
		if(c!='0' || !zero)
			cout<<c;
	}
}

void input(vll& v,int N){
	for(int i=0;i<N;i++){
		cin>>v[i];
	}
	sort(all(v));
}

void solve(vll& v,int N){
	ll ans=0;

	vll prefix(N);
	prefix[0]=v[0];
	for(int i=1;i<N;i++){
		prefix[i]+=prefix[i-1]+v[i];
	}

	for(int i=1;i<N;i++){
		ans-=(prefix[i-1])*v[i];
	}
	ans*=2;

	for(int i=0;i<N;i++)
		ans+=(N-1)*1ll*(v[i]*v[i]);

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

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

	int N;
	cin>>N;
	vll v(N);
	input(v,N);
	solve(v,N);

	return 0;
}

#include <bits/stdc++.h>
//#define IHAVEGIRLFRIEND
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,sse4,ssse3,popcnt,abm,mmx,avx,avx2,tune=native")
#define PB emplace_back
#define MP make_pair
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define F first
#define S second
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define REPP(i,a,b) for(int i = a; i <= b; ++i)
#define RREP(i,a,b) for(int i = a; i >= b; --i)
#define endl cout<<'\n'
#define _ <<' '<<
#define CASET int ___T; cin >> ___T; for(int kase = 1; kase <= T; kase++)
#define MS(X,V) memset(X,V,sizeof(X))

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#ifdef IHAVEGIRLFRIEND
#define IOS
#define PAUSE system("pause")
#define debug(...) fprintf(stderr, "\033[1m\033[31m%s [%d] \033[0m(%s) = ", __PRETTY_FUNCTION__, __LINE__, #__VA_ARGS__), _do(__VA_ARGS__)
template<typename T> void _do(T &&x){ cerr<<x<<'\n'; }
template<typename T, typename ...S> void _do(T &&x, S &&...y){ cerr<<x<<", ";_do(y...); }
#else
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PAUSE
#define debug(...)
#endif

constexpr int maxn = 3e5 + 5;

ll arr[maxn];

void solve(){
	int N; cin >> N;
	ll ans = 0, sum = 0;
	REP(i,0,N){
		cin >> arr[i];
		ans += (N-1)*arr[i]*arr[i];
		sum += arr[i];
	}
	REP(i,0,N-1){
		sum -= arr[i];
		ans -= arr[i] * sum * 2;
	}
	cout << ans << '\n';
}

signed main(){
	IOS;
	solve();
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200 + 10;

int c[8];

int main(){
	ios_base::sync_with_stdio(false);
	int tc;
	cin >> tc;
	while (tc --){
		string s;
		cin >> s;
		if (s > "atcoder"){
			cout << 0 << '\n';
			continue;
		}
		bool found = 0;
		for (int i = 0; i < s.size(); i++){
			if (s[i] > 'a'){
				if (s[i] > 't')
					cout << max(0,i-1) << '\n';
				else
					cout << i << '\n';
				found = 1;
				break;
			}
		}
		if (!found)
			cout << -1 << '\n';
	}
}

#include <bits/stdc++.h>

using namespace std;

string s;

string x = "atcoder";

int aduEgal(int poz)
{
    if(s[poz] == x[poz])
        return 0;

    for(int i = poz + 1; i < s.size(); i ++)
    {
        if(x[poz] == s[i])
        {
            for(int j = i; j > poz; j --)
                s[j] = s[j - 1];

            s[poz] = x[poz];

            return i - poz;
        }
    }

    return 9999;
}

int aduMare(int poz)
{
    if(s[poz] > x[poz])
        return 0;

    for(int i = poz + 1; i < s.size(); i ++)
    {
        if(s[i] > x[poz])
            return i - poz;
    }

    return 9999;
}

int main()
{
    int q;
    cin >> q;
    while(q > 0)
    {
        q --;

        cin >> s;

        int rez = 999999999;

        int ok = 0;
        for(int i = 0; i < s.size(); i ++)
        {
            if(s[i] != 'a')
                ok = 1;
        }

        if(ok == 0)
            cout << "-1\n";

        else
        {
            int cost = 0;
            for(int i = 0; i < min(s.size(), x.size()); i ++)
            {
                int w = aduMare(i);
                rez = min(rez, cost + w);

                cost += aduEgal(i);
            }

            if(s.size() > x.size())
                rez = min(rez, cost);

            cout << rez << "\n";
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int t;
ll n, s, k;
ll powmod (ll a, ll b) {
  if (b == 0) return 1;
  if (b == 1) return a % n;
  ll tmp = powmod(a, b / 2);
  tmp = (tmp * tmp) % n;
  if (b & 1) return (tmp * a) % n;
  return tmp;
}
ll phi (ll x) {
  ll res = x;
  for (ll i = 2; i * i <= x; ++ i) {
    if (x % i == 0) {
      res -= res / i;
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) res -= res / x;
  return res;
}
ll modInv (ll x) {
  ll phin = phi(n);
  return powmod(x, phin - 1);
}
void solve () {
  cin >> n >> s >> k;
  ll A = k, B = (n - s) % n, M = n;
  ll g = __gcd(A, __gcd(B, M));
  A /= g; B /= g; M /= g; n /= g;
  if (__gcd(A, M) != 1) {
    cout << -1 << '\n';
    return;
  }
  ll ans = (modInv(A) * B + M) % M;
  cout << ans << "\n";
}
int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> t;
  while (t --) solve();
  return 0;
}

#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 <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

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

bool find_any_solution(long long a, long long b, long long c, long long &x0, long long &y0, long long &g) {
	g = gcd(abs(a), abs(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;
}

int main() {

	long long test; cin >> test;
	for (long long tst = 1; tst <= test; ++tst) {
		long long n, s, k; cin >> n >> s >> k;

		long long g, x0, y0;

		if (!find_any_solution(-k, n, s, x0, y0, g)) {
			cout << -1 << "\n";
			continue;
		}

		long long dec = n / g;

		if (x0 > 0) x0 -= (x0 / dec) * dec;
		else x0 += ((-x0 + dec - 1) / dec) * dec;

		cout << x0 << "\n";
	}

	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int a[100010];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = -1;
	for (int i = 0; i < n; i++) {
		int m = a[i];
		for (int j = i; j < n; j++) {
			m = min(m, a[j]);
			if (ans < m * (j - i + 1)) {
				ans = m * (j - i + 1);
			}
		}
	}
	cout << ans << endl;
}


#include <algorithm>
#include <iostream>
#include <cstdint>

int main() {
  int N, K;
  std::cin >> N >> K;
  std::int64_t sum = 0;
  for (int ab = 2; ab <= 2 * N; ++ab) {
    const int cd = ab - K;
    if (cd < 2 || cd > 2 * N) continue;
    sum += std::min<std::int64_t>(ab - 1, 2 * N - ab + 1) * std::min<std::int64_t>(cd - 1, 2 * N - cd + 1);
  }
  std::cout << sum << std::endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n,w;
    cin >> n >> w;
    cout << n/w << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pii pair<int, int>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rfor(i, b, a) for(int i = b; i >= a; i--)
#define X first
#define Y second
#define pb push_back
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
//const int mod = 1e9 + 7;

int n, m;
const int template_size_array = 1e6 + 5;
int a[template_size_array];
int b[template_size_array];
int c[template_size_array];
string s;

void run_case(){
	cin >> n;
	int mn = INT_MAX;
	rep(i, 0, n){
		cin >> a[i];
		cin >> b[i];
		cin >> c[i];
	}
	rep(i, 0, n){
		if(c[i] - a[i] > 0){
			mn = min(mn, b[i]);
		}
	}
	if(mn == INT_MAX){
		cout << "-1";
		return;
	}
	cout << mn;
}

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(nullptr);
	cout << setprecision(12) << fixed;
	int t = 1;
	//cin >> t;
	while(t--){
		run_case();
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;++i)
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
#define int long long
int a[200050];
//3 5 8 11
int f[200050];
const double eps=1e-6;
const int mod=1e9+7;
int n;
double check(double x) {
	double res=0;
	rep(i,1,n) {
		res+=x+a[i]-min(1.0*a[i],2.0*x);
	}
	return res;
}
signed main() {
	cin>>n;
	rep(i,1,n) cin>>a[i];
	double L=0,R=1e9;
	double ans=0;
	while(R-L>eps) {
		double midl=L+(R-L)/3;
		double midr=R-(R-L)/3;
		if(check(midl)<=check(midr)) {
			R=midr;
			ans=check(midl);
		}
		else L=midl;
		//cout<<L<<" "<<R<<endl;
	}
	cout<<fixed<<setprecision(10)<<ans/n<<endl;
}


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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

template <typename T>
void print(vector<T>& x) {
    int N = x.size();
    REP(i, N) {
        if (i > 0) cout << " ";
        cout << x[i];
    }
    cout << "\n";
}

const ll MOD = 1000000007;
//const ll 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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = 1;
        mint tmp = *this;
        while(t > 0) {
            if (t & 1) a *= tmp;
            tmp *= tmp;
            t >>= 1;
        }

        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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

typedef vector<mint> vmi;

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

    ll n, p; cin >> n >> p;

    print(mint(p - 1) * mint(p - 2).pow(n - 1));

}

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

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

  long long n, c;
  cin >> n >> c;

  map<int, vector<int>> m;
  for (int i = 0; i < n; ++i) {
    int a, b, ci;
    cin >> a >> b >> ci;

    m[a].push_back(ci);
    m[b+1].push_back(-ci);
  }

  long long ans = 0, sum = 0, last = 0;

  for (auto i : m) {
    ans += min(sum, c) * (i.first - last);
    for (auto j : i.second) {
      sum += j;
    }
    last = i.first;
  }

  cout << ans << '\n';
}


#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;

ll c[500][500];
int main() {
  int n;
  cin >> n;
  rep(i,n)rep(j,n) cin >> c[i][j];
  vector<ll> a(n),b(n);
  rep(i,n-1){
    ll d = c[i+1][0]-c[i][0];
    rep(j,n) if(c[i+1][j]-c[i][j]!=d){
      cout << "No" << endl;
      return 0;
    }
    a[i+1] = d;
  }
  rep(j,n-1){
    ll d = c[0][j+1]-c[0][j];
    rep(i,n) if(c[i][j+1]-c[i][j]!=d){
      cout << "No" << endl;
      return 0;
    }
    b[j+1] = d;
  }
  rep(_,2){
    ll s=0,m=0;
    rep(i,n) s += a[i], m = min(m,s), a[i] = s;
    rep(i,n) a[i] -= m;
    swap(a,b);
  }
  rep(i,n)rep(j,n){
    if(c[i][j]<a[i]+b[j]){
      cout << "No" << endl;
      return 0;
    }
  }
  rep(i,n) a[i] = c[i][0]-b[0];

  cout << "Yes" << endl;
  rep(i,n) printf("%lld%c",a[i],i==n-1?'\n':' ');
  rep(i,n) printf("%lld%c",b[i],i==n-1?'\n':' ');
}

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

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

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

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

int main(){
    int n;
    cin >> n;
    V<V<int>> c(n,V<int>(n));
    cin >> c;
    bool ok = true;
    rep(i,n)rep(j,n-1) {
        ok &= (c[i][j+1]-c[i][j] == c[0][j+1]-c[0][j]);
    }
    rep(j,n)rep(i,n-1) {
        ok &= (c[i+1][j]-c[i][j] == c[i+1][0]-c[i][0]);
    }
    if(!ok) fin("No");

    V<int> d(n-1);
    Rep(i,n-1) d[i-1] = c[0][i]-c[0][i-1];

    int l = -1, r = INF;
    while(r-l > 1) {
        int mid = (l+r)/2;
        int now = mid;
        bool ok = true;
        rep(i,n-1) {
            now += d[i];
            if(now < 0) ok = false;
        }
        if(ok) r = mid;
        else l = mid;
    }
    V<int> b(n); b[0] = r;
    rep(i,n-1) b[i+1] = b[i] + d[i];
    V<int> a(n);
    rep(i,n) {
        a[i] = c[i][0]-b[0];
        if(a[i] < 0) fin("No");
    }
    cout << "Yes" << endl;
    cout << a << endl << b << endl;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
constexpr int INF = 1e9, MOD = 1e9 + 7;
constexpr int64_t LINF = 5e18, LMOD = 998244353;
// #include <atcoder/all>
// using namespace atcoder;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int64_t dp[200010][2];
map<int, set<int>> mp;
int main() {
	rep(i,200010)rep(j,2) dp[i][j] = LINF;
	dp[0][0] = dp[0][1] = 0;
	int n; cin >> n;
	rep(i,n) {
		int x, c; cin >> x >> c;
		mp[c].insert(x);
	}
	mp[n + 1].insert(0);
	int preL = 0, preR = 0;
	int pre_idx = 0;
	for(auto [idx, st] : mp) {
		int L = *st.begin();
		int R = *prev(st.end());
		if(L == R) {
			dp[idx][0] = dp[idx][1] = min(dp[pre_idx][0] + abs(preL - L), dp[pre_idx][1] + abs(preR - R));
		} else {
			dp[idx][0] = min(dp[pre_idx][0] + abs(preL - R) + abs(R - L), dp[pre_idx][1] + abs(preR - R) + abs(R - L));
			dp[idx][1] = min(dp[pre_idx][0] + abs(preL - L) + abs(R - L), dp[pre_idx][1] + abs(preR - L) + abs(R - L));
		}
		preL = L;
		preR = R;
		pre_idx = idx;
	}
	cout << dp[n + 1][0] << '\n';
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

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

#define rep(i, n) for (int i=0; i<(n); ++i)
#define rrep(i, n) for (int i=0; i<=(n); ++i)
#define each(v, i) for (auto i : v)
#define pb push_back
#define sz (int)(x).size()
#define fi first
#define se second
#define maxs(x, y) x = max(x, y)
#define mins(x, y) x = min(x, y)
#define pcnt __builtin_popcount
#define rng(a) a.begin(), a.end()

template<typename T> using vc = vector<T>;
template<typename T> using vv = vector<vector<T>>;
using vi = vc<int>;
using vvi = vv<int>;

template<int mod>
struct modint {
    const static int _mod = mod;
    int _v;

    // constructor
    modint() { _v = 0; }
    modint(const modint& o) { _v = o._v; }
    modint(int v) { _v = ((v%_mod)+_mod)%_mod; }

    // operator
    modint& operator+=(const modint& rhs) {
        _v = ((_v + rhs._v) % _mod + _mod) % _mod;
        return *this;
    }

    modint& operator-=(const modint& rhs) {
        _v = ((_v - rhs._v) % _mod + _mod) % _mod;
        return *this;
    }

    modint& operator*=(const modint& rhs) {
        _v = (int)(((long long)_v * rhs._v) % _mod);
        return *this;
    }

    modint& operator/=(const modint& rhs) {
        return *this = *this * rhs.inv();
    }

    modint pow(int n) const {
        modint x = *this, ret = 1;
        while (n) {
            if (n & 1) ret *= x;
            x *= x;
            n >>= 1;
        }
        return ret;
    }

    modint inv() const {
        return pow(_mod - 2);
    }

    friend modint operator+(const modint& a, const modint& b) {
        return modint(a)+=b;
    }

    friend modint operator-(const modint& a, const modint& b) {
        return modint(a)-=b;
    }

    friend modint operator*(const modint& a, const modint& b) {
        return modint(a)*=b;
    }

    friend modint operator/(const modint& a, const modint& b) {
        return modint(a)/=b;
    }

    friend bool operator==(const modint& a, const modint& b) {
        return a._v == b._v;
    }

    friend bool operator!=(const modint& a, const modint& b) {
        return a._v != b._v;
    }

    friend ostream& operator<<(ostream& out, const modint& rhs) {
        out << rhs.val();
        return out;
    }

    int val() const {
        return _v;
    }
};

using mint = modint<1000000007>;

const int M = 100005;
mint fib[M];

void init() {
    rep(i, M) {
        if (i <= 3) fib[i] = i;
        else fib[i] = fib[i-1] + fib[i-2];
    }
}

mint get(int len) {
    return fib[max(1, len)];
}

int main() {
    int N; cin >> N;
    vi a(N); rep(i, N) cin >> a[i];
    init();

    mint ans = 0;
    rep(i, N) {
        int left = i, right = N-i;
        ans += get(left) * get(right) * a[i];
        if (i > 0) {
            ans -= get(left-1) * get(right-1) * a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, n, now, ans = 0, t;
  scanf("%lld", &n);
  for(i = 1; i <= n; ++i) {
    t = 1;
    now = i;
    while(now) {
      if(now % 8 == 7) {
        t = 0;
        break;
      }
      now /= 8;
    }
    now = i;
    while(now) {
      if(now % 10 == 7) {
        t = 0;
        break;
      }
      now /= 10;
    }
    ans += t;
  }
  printf("%lld", ans);
  return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,a,b) for (int i = (a); i < (b); ++i)
#define erep(i,a,b) for (int i = (a); i <= (b); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),rend()
#define yn(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define fore(i,a) for(auto &i:a)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}

template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}

int main() {
  string s;
  cin >>s;
  reverse(all(s));
  fore(a,s) {
    if(a=='6') cout << '9';
    else if(a=='9') cout << '6';
    else cout << a;
  }
  cout << endl;
  return 0;
}

#include <iostream>
#include <cstring>
using namespace std;
int main() {
char s[100001];
cin>>s;
int n;
n=strlen(s);
for(int i=n-1;i>=0;i--){
if(s[i]=='6'){
cout<<'9';
}
else if(s[i]=='9'){
cout<<'6';
}
else{
cout<<s[i];
}
}
}


#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, k, m;
    cin >> n >> k >> m;
    vector<int> a(n);
    rep(i, n-1)cin >> a.at(i);
    int ans = accumulate(all(a), 0);
    m *= n;
    if(m <= ans)cout << 0;
    else {
        if(m-ans <= k)cout << m-ans;
        else cout << -1;
    }
}

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

#define rep(i,a,b) for(int i=a; i<b; i++)
#define repe(i,a,b) for(int i=a; i<=b; i++)
#define ll long long
#define ui unsigned int
#define pb push_back
#define deb(x) cout << #x << '=' << x << endl
#define deb2(x,y) cout << #x << '=' << x << << #y << '=' << y << endl
#define all(x) x.begin(), x.end()
#define endl "\n"
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define hcf(x,y)     __gcd(x,y)
#define lcm(x,y)     (x*y)/(__gcd(x,y))
#define CountOne(x)  __builtin_popcount(x)
#define parity(x)    __builtin_parity(x)           //Funtion return (true) if number of set bits is odd(odd parity) else false..
#define LeadZero(x)  __builtin_clz(x)             //Counts leading zero in binary representation of x ....
#define TrailZero(x) __builtin_ctz(x)

#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef map<int, int> mii;
typedef unordered_map<int, int> umap_ii;
typedef unordered_map<int, int> umap_ii;
typedef unordered_map<string, int> umap_si;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
//alt + ctrl + N

//===============================================================================//
ll power(ll x, ll y) {
ll v = 1; while (y > 0) { if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

bool isPowerOfTwo(ll x){
    return x && (!(x & (x-1)));     //check if the number is power of two or not
}
ll ceil(ll a,ll b){ return (a+b-1)/b; }
//===============================================================================//

int main(){
    fastIO;
srand(chrono::high_resolution_clock::now().time_since_epoch().count());

#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif

    ll test = 1;
    //cin >> test;
    while(test--){
        vi a(4);
        rep(i,0,4) cin >> a[i];
        cout << *min_element(all(a)) << endl;
    }
return 0;
}


#include<map>
#include<cmath>
#include<list>
#include<queue>
#include<bitset>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define ll long long
#define lbw 1000000009
#define inf 2147483647
using namespace std;
ll read(){ll ans=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')ans=ans*10+c-'0',c=getchar();return ans*f;}
ll n,m,v[100005],first[100005],cnt,fa[100005],root=1,dp[100005][2],x,y,z,now,now_val;
struct edge{
	ll to,nxt;
}e[200005];
void add(ll x,ll y){
	e[++cnt].nxt=first[x];
	e[cnt].to=y;
	first[x]=cnt;
}
void dfs(ll now,ll f){
	dp[now][1]=1;
	for(int i=first[now],v;i;i=e[i].nxt){
		v=e[i].to;
		if(v==f)continue;
		dfs(v,now);
		dp[now][0]+=dp[v][1];
		dp[now][1]+=min(dp[v][1],dp[v][0]);
	}
}
ll sum(ll n){
	return n*(n+1)/2;
}
int main(){
	n=read();ll ans=0;
	for(int i=1;i<=n;i++){
		ll l=read(),r=read();
		ans+=sum(r)-sum(l-1);
	}
	cout<<ans;
	return 0;
}

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

int main(){
  ll n;cin >> n;
  ll ans = 0;
  rep(i,n){
    ll a,b;cin >> a >> b;
    ans += b*(b+1)/2 - (a-1)*a/2;
  }
  cout << ans << endl;
  return 0;
}


#include "bits/stdc++.h"

using namespace std;

constexpr int N = 5005;
constexpr long long MOD = 998244353;

int n, m, k;
vector< string> s;
long long dp[N][N];

long long power(long long a, int b) {
    long long rv = 1;
    while (b) {
        if (b & 1) rv = rv * a % MOD;
        (a *= a) %= MOD;
        b /= 2;
    }
    return rv;
}

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

    cin >> n >> m >> k;
    s.resize(n, string(m, '.'));

    for (int i = 0; i < k; i++) {
        int x, y; char c;
        cin >> x >> y >> c;
        x--; y--;
        s[x][y] = c;
    }

    dp[0][0] = power(3, n * m - k);
    long long val = 2 * power(3, MOD - 2) % MOD;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i == 0 && j == 0) continue;

            if (j > 0) {
                if (s[i][j - 1] == 'R' || s[i][j - 1] == 'X') dp[i][j] += dp[i][j - 1];
                if (s[i][j - 1] == '.') dp[i][j] += dp[i][j - 1] * val % MOD;
            }
            if (i > 0) {
                if (s[i - 1][j] == 'D' || s[i - 1][j] == 'X') dp[i][j] += dp[i - 1][j];
                if (s[i - 1][j] == '.') dp[i][j] += dp[i - 1][j] * val % MOD;
            }
            dp[i][j] %= MOD;
        }
    }

    cout << dp[n - 1][m - 1] << endl;
}

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

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

struct edge {int to, cost; };

int main(){
  int h, w, n, m;
  cin >> h >> w >> n >> m;
  vector<vector<int>> mp1(h, vector<int>(w,0));
  vector<vector<int>> mp2(h, vector<int>(w,0));
  vector<P> a;
  for(int i=0; i<n; i++){
    int x, y;
    cin >> x >> y;
    x--; y--;
    a.push_back(make_pair(x,y));
  }
  for(int i=0; i<m; i++){
    int x, y;
    cin >> x >> y;
    x--; y--;
    mp1[x][y] = -1;
    mp2[x][y] = -1;
  }
  for(int i=0; i<n; i++){
    int x, y;
    x = a[i].first;
    y = a[i].second;
    if(mp1[x][y] == 1) continue;
    for(int j=x; j<h; j++){
      if(mp1[j][y] == -1) break;
      mp1[j][y] = 1;
    }
    for(int j=x; j>=0; j--){
      if(mp1[j][y] == -1) break;
      mp1[j][y] = 1;
    }
  }
  for(int i=0; i<n; i++){
    int x, y;
    x = a[i].first;
    y = a[i].second;
    if(mp2[x][y] == 1) continue;
    for(int j=y; j<w; j++){
      if(mp2[x][j] == -1) break;
      mp2[x][j] = 1;
    }
    for(int j=y; j>=0; j--){
      if(mp2[x][j] == -1) break;
      mp2[x][j] = 1;
    }
  }
  int ans = 0;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(mp1[i][j]>0 || mp2[i][j]>0) ans++;
    }
  }
  cout << ans << endl;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;

#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//insert,find_by_order,order_of_key,lower_bound,upper_bound;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

//////////////////////////////code//////////////////////////////

const int N = 2e5 + 5;

int ans , n;
int dp[N];
vpii adj[N];

void dfs(int node,int p,int w)
{
      dp[node] = w;

      for(auto &c :adj[node])
      {
            if(c.ff == p)
              continue;

            dfs(c.ff , node , c.ss ^ dp[node]);

      }
}

void solve()
{
      cin >> n;

      for(int i = 0;i < n - 1; i++)
      {
              int u , v , w;
              cin >> u >> v >> w;
              adj[u].pb({v , w});
              adj[v].pb({u , w});
      }

      ans = 0;

      dfs(1 , -1 , 0);

      int bit[62] = {};

      for(int i = 1;i <= n ; i++)
      {
              int num = dp[i];
              int j = 0;

              while(num)
              {
                    if(num&1)
                      bit[j]++;

                    num>>=1;
                    j++;
              }
      }

      int curr = 1;

      for(int i = 0;i < 62 ; i++)
      {
            int now = bit[i];
            now *= (n - bit[i]);
            now%=mod;
            int p = curr%mod;
            now*=p;
            now%=mod;
            ans += now;
            ans%=mod;

           // deb(ans, now);

            curr<<=1;
      }

      db(ans)

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

     #ifndef ONLINE_JUDGE
     freopen("INP.txt", "r", stdin);
     freopen("out.txt", "w", stdout);
     #endif

    int t = 1;
   //cin >> t;

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef   long long int ll;
typedef long double db;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define pi 3.14159265358979323846264338327950288419716939937510
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(i=n-1;i>=0;i--)
#define rep(i,n) for(i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define at(s,pos) *(s.find_by_order(pos))
#define set_ind(s,val) s.order_of_key(val)
long long int M = 1e9 + 7 ;
long long int inf = 9 * 1e18;
//CLOCK
ll begtime = clock();
#define time() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//CLOCK ENDED
ll n, m;
// modular exponentiation
ll binpow(ll val, ll deg)
{
	if (deg < 0)
		return 0;
	if (!deg)
		return 1 % M;
	if (deg & 1)
		return binpow(val, deg - 1) * val % M;
	ll res = binpow(val, deg >> 1);
	return (res * res) % M;
}
//binomial
ll modinv(ll n) {
	return binpow(n, M - 2);
}

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

bool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g) {
	g = gcd(abs(a), abs(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;
}
void shift_solution(ll & x, ll & y, ll a, ll b, ll cnt) {
	x += cnt * b;
	y -= cnt * a;
}

ll find_all_solutions(ll a, ll b, ll c, ll minx, ll maxx, ll miny, ll maxy) {
	ll x, y, g;
	if (!find_any_solution(a, b, c, x, y, g))
		return inf;
	a /= g;
	b /= g;

	ll sign_a = a > 0 ? +1 : -1;
	ll sign_b = b > 0 ? +1 : -1;

	shift_solution(x, y, a, b, (minx - x) / b);
	if (x < minx)
		shift_solution(x, y, a, b, sign_b);
	if (x > maxx)
		return inf;
	ll lx1 = x;

	shift_solution(x, y, a, b, (maxx - x) / b);
	if (x > maxx)
		shift_solution(x, y, a, b, -sign_b);
	ll rx1 = x;

	shift_solution(x, y, a, b, -(miny - y) / a);
	if (y < miny)
		shift_solution(x, y, a, b, -sign_a);
	if (y > maxy)
		return inf;
	ll lx2 = x;

	shift_solution(x, y, a, b, -(maxy - y) / a);
	if (y > maxy)
		shift_solution(x, y, a, b, sign_a);
	ll rx2 = x;

	if (lx2 > rx2)
		swap(lx2, rx2);
	ll lx = max(lx1, lx2);
	ll rx = min(rx1, rx2);

	if (lx > rx)
		return inf;
	return lx;
}
int main() {
	// your code goes here
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	cin >> t;
	while (t--) {
		ll p, q;
		cin >> x >> y >> p >> q;
		ll a = 2 * (x + y), b = -(p + q);
		ll mn = inf;
		for (i = x; i < x + y; i++) {
			for (j = p; j < p + q; j++) {
				ll c = j - i;
				z = find_all_solutions(a, b, c, 0, 1e17, 0, 1e17);
				if (z != inf) {
					mn = min(mn, a * z + i);
				}
			}
		}
		if (mn == inf) cout << "infinity\n";
		else cout << mn << '\n';
	}

	return 0;

}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int32> a(3);
  REP(i,3)cin >> a[i];
  sort(all(a));
  Yes(a[1] - a[0] == a[2] - a[1]);
  return 0;
}

#include<cstdio>
#include<cstring>
#define N 300001
using namespace std;
bool chose[N];
int a[N],answer;
int n,left[N],right[N];
void dfs(int k)
{
	if (k==n)
	{
		int num=1;
		left[num]=1;
		for (int i=1;i<n;i++)
		{
			if (chose[i])
			{
				right[num]=i;
				left[++num]=i+1;
			}
		}
		right[num]=n;
		int ans=0;
		for (int i=1;i<=num;i++)
		{
			int cnt=0;
			for (int j=left[i];j<=right[i];j++) cnt|=a[j];
			ans^=cnt;
		}
		if (ans<answer) answer=ans;
		return;
	}
	chose[k]=false;
	dfs(k+1);
	chose[k]=true;
	dfs(k+1);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	memset(chose,false,sizeof(chose));
	answer=2e9;
	dfs(1);
	printf("%d\n",answer);
}


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

int main() {
  string a, b;
  cin >> a >> b;
  auto f = [&](string s) {
    int res = 0;
    for (char c : s) res += c-'0';
    return res;
  };
  int ans = max(f(a), f(b));
  cout << ans << '\n';
  return 0;
}

/**
*
* @Author : Sindys
* Language  : C++
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <limits>//numeric_limits<int>::max() ... numeric_limits<int>::min()
#include <cmath>
#include <bitset>
#include <tuple>
#include <deque>
#include <stack>

using namespace std;
#define ll                  long long
#define pii                 pair<int, int>
#define vpii                vector<pii>
#define vi                  vector<int>
#define vd                  vector<double>
#define vll                 vector<ll>
#define INF                 1000000000
#define pb                  push_back
#define FOR(i,a,b,p)          for (int i = a; i < b; i += p)
#define ROF(i,b,a,p)          for (int i = b-1; i >= a; i -= p)
#define mp                  make_pair
#define f                   first
#define s                   second
#define FORX(a,b,n)         for (; a < b; a += n)//for every +n operation
#define ROFX(a,b,n)         for (; a > b; a -= n)//for every -n operation
const int M = 1000000007;

//memset(memo, -1, sizeof memo); // initialize DP memoization table with -1
//memset(arr, 0, sizeof arr); // to clear array of integers
// index = (index + 1) % n; // index++; if (index >= n) index = 0;
// index = (index + n - 1) % n; // index--; if (index < 0) index = n - 1;
// int ans = (int)((double)d + 0.5); // for rounding to nearest integer
ll sumdig(int a){
    ll res = 0;
    while(a>0) {
        res += a%10;
        a /= 10;
    }
    return res;
}

void solve() {
        int a, b;
        cin>>a>>b;
        if (sumdig(a) > sumdig(b)) {
            cout<<sumdig(a)<<'\n';
        }
        else {
            cout<<sumdig(b)<<'\n';
        }

}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}
/*stuff you should look for:
-->overflow,array bounds
-->special cases n=1..
-->use printf for precision or setprecision on cout*/


#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2e5 + 100;

int n, q;
int fa[N], clas[N];
map<int, map<int, int>> son_num;

int Find(int x) {
    // return fa[x] == x ? fa[x] : fa[x] = Find(fa[x]);
    if (fa[x] == x) return fa[x];
    else return fa[x] = Find(fa[x]);
}

void Union(int x, int y) {
    x = Find(x);
    y = Find(y);
    if (x != y) {
        if (son_num[x].size() >= son_num[y].size()) {
            fa[y] = x;
            for (const auto &[_class, num] : son_num[y]) {
                son_num[x][_class] += num;
            }
        } else {
            fa[x] = y;
            for (const auto &[_class, num] : son_num[x]) {
                son_num[y][_class] += num;
            }
        }
    }
}

void Init() {
    for (int i = 0; i < N; i++) {
        fa[i] = i;
    }
}

int main() {
    // freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Init();
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        cin >> clas[i];
        son_num[i][clas[i]] = 1;
    }
    for (int i = 0; i < q; i++) {
        int op, x, y;
        cin >> op >> x >> y;
        if (op == 1) {
            Union(x, y);
        } else {
            cout << son_num[Find(x)][y] << "\n";
        }
    }
    return 0;
}

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

// #define int long long
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while (!isdigit(c)) { if (c == '-') f = - f; c = getchar(); }
    while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
    return x * f;
}

const int inf = 1e9 + 1e7, N = 2e5 + 1e1;
const long long INF = 1e18 + 1e9;

struct Edge { int nxt, to; } e[N << 1];
struct Node { int ls, rs, w; } ;
int head[N], fa[N], rt[N], c[N], n, q, tot;

struct WSegmentTree {
    #define ls(x) tree[x].ls
    #define rs(x) tree[x].rs
    Node tree[N << 5];
    int nodecnt;

    void Pushup(int x) { tree[x].w = tree[ls(x)].w + tree[rs(x)].w; return ; }

    void Insert(int l, int r, int p, int &x) {
        if (!x) x = (++ nodecnt);
        if (l == r) tree[x].w = 1;
        else {
            int mid = l + r >> 1;
            if (p <= mid) Insert(l, mid, p, ls(x));
            else Insert(mid + 1, r, p, rs(x)); Pushup(x);
        } return ;
    }

    void Merge(int l, int r, int u, int &x) {
        if (!u || !x) { x += u; return ; }
        if (l == r) tree[x].w += tree[u].w;
        else {
            int mid = l + r >> 1;
            Merge(l, mid, ls(u), ls(x)), Merge(mid + 1, r, rs(u), rs(x)), Pushup(x);
        } return ;
    }

    int Query(int l, int r, int p, int x) {
        if (!x) return 0;
        if (l == r) return tree[x].w;
        else {
            int mid = l + r >> 1, res = 0;
            if (p <= mid) res += Query(l, mid, p, ls(x));
            else res += Query(mid + 1, r, p, rs(x));
            return res;
        } return 0;
    }
} wst;

void Addedge(int u, int v) { e[++ tot] = (Edge){ head[u], v }, head[u] = tot; return ; }

int Find(int x) { return (fa[x] == x ? x : fa[x] = Find(fa[x])); }

signed main() {

    n = read(), q = read();
    for (int i = 1; i <= n; i ++) fa[i] = i, c[i] = read();
    for (int i = 1; i <= n; i ++) wst.Insert(1, n, c[i], rt[i]);
    while (q --) {
        int op = read(), x = read(), y = read();
        if (op == 1) {
            int u = Find(x), v = Find(y);
            if (u != v) wst.Merge(1, n, rt[u], rt[v]), fa[u] = v;
        }
        else printf("%d\n", wst.Query(1, n, y, rt[Find(x)]));
    }

    return 0;
}


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

int N, K;
vector<pair<long long, long long>> AB;

long long solve() {
    long long tmp = 0;
    long long balance = K;
    rep(i, N) {
        long long A = AB[i].first; long long B = AB[i].second;
        if (A > tmp + balance) return tmp + balance;
        balance -= A - tmp;
        tmp = A; balance += B;
    }
    return tmp + balance;
}

int main() {
    cin >> N >> K; AB.resize(N);
    rep(i, N) cin >> AB[i].first >> AB[i].second;
    sort(AB.begin(), AB.end());
    cout << solve() << endl;
}

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

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

    string S;
    string T;
    cin >> S >> T;

    int Szero = 0;
    int Tzero = 0;
    rep(i,0,N){
        if(S.at(i) == '0') Szero++;
        if(T.at(i) == '0') Tzero++;
    }

    if(Szero != Tzero){
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    Szero = 0;
    Tzero = 0;
    rep(i,0,N){
        if(Szero == Tzero && S.at(i) == '0' && T.at(i) == '0') ans--;
        if(S.at(i) == '0') Szero++;
        if(T.at(i) == '0') Tzero++;
    }
    ans += Szero;

    cout << ans << endl;

    return 0;
}


#include <iostream>
int main(){
    int A, B, W, Wg;
    int min=1000001, max=0;
    std::cin >> A >> B >> W;
    Wg = W * 1000;
    for (int i = 1; i <= 1000000; i++) {
        if ((A * i <= Wg) && (B * i >= Wg)) {
            if (i < min) min = i;
            if (i > max) max = i;
        }
    }
    if (min == 2001 || max == 0) {
        std::cout << "UNSATISFIABLE" << std::endl;
    } else {
        std::cout << min << " " << max << std::endl;
    }
}

/*
As fire is shrouded in smoke, a mirror by dust and a child by the womb,
      so is the universe enveloped in desire.

It is the wise man’s constant enemy; it tarnishes the face of wisdom.
        It is as insatiable as a flame of fire.

It works through the senses, the mind and the reason;
         and with their help destroys wisdom and confounds the soul.

Therefore, O Arjuna, first control thy senses and then slay desire,
            for it is full of sin, and is
                the destroyer of knowledge and of wisdom.

                                                  -- "SHRI BHAGVAT GITA"
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define popb pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll >
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size
#define len length
#define se second
//const ll mod=998244353;
const ll mod = 100000000000000000+7;
const ll N=10000000+6;
#define M_PI           3.14159265358979323846
//-------------

void ps(string st)
{
    int n = st.size();
    int z = 0 , d = 0;
    for(char l : st)
      if(l == '0')
        z++;
      else
        if(l == '-')
        d++;

    if(d + z < n)
    {
          for(char k : st)
              if(k != '-')
                cout << k;

          return;
    }

    cout << 0;
}
//--------------------------------------------
bool remone(int mo , string &st){

  int n = st.size();
  for(int i = n-1; i >= 0 ; i--)
  {
      int v = st[i] - '0';
      if(v % 3 == mo)
      {
          st[i] = '-';
          return true;
      }
  }

  return false;
}

bool remtwo(int mo , string &st)
{
  int f = 0;
    for(int i = st.size() - 1 ; i >= 0; i--)
    {
        int v = st[i] - '0';
        if(v % 3 == mo)
        {
            st[i] = '-';
            f++;
        }
        if(f == 2) break;
    }

    if(f == 2)
      return true;
    return false;
}
bool ans(int a , int b , int c){
  if(a == (b + c))
    return true;
  return false;
}
//============================================
int main() {
    ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
    #ifndef ONLINE_JUDGE
       freopen ("INPUT.txt" , "r" , stdin);
       freopen ("OUTPUT.txt", "w" , stdout);
    #endif

    int a , b ,c ;
    cin >> a >> b >> c;

    if(ans(2*a , b , c) || ans(2*a , c , b) || ans(2*b , a , c) || ans(2*b , c , a) || ans(2*c , a , b) || ans(2*c , b , a) )
      cout << "Yes";
    else
      cout << "No";

return 0;
}


#line 1 "c.cpp"
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
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;
}
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define FOR(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void Case(int i) { cout << "Case #" << i << ": "; }
#pragma endregion Macros

#line 1 "/home/siro53/kyo-pro/compro_library/math/ceil_floor_div.hpp"
template<class T>
T ceil_div(T a, T b) {
    if(b < 0) a = -a, b = -b;
    return (a >= 0 ? (a + b - 1) / b : a / b);
}

template<class T>
T floor_div(T a, T b) {
    if(b < 0) a = -a, b = -b;
    return (a >= 0 ? a / b : (a - b + 1) / b);
}
#line 70 "c.cpp"

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 1;
    FOR(g, 1, 200000 + 1) {
        int l = (A-1)/g;
        int r = B/g;
        if(r - l >= 2) chmax(ans, g);
    }
    cout<<ans<<endl;
}

// Problem: C - Max GCD 2
// Contest: AtCoder - Japanese Student Championship 2021
// URL: https://atcoder.jp/contests/jsc2021/tasks/jsc2021_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

// Problem: C. The Sports Festival
// Contest: Codeforces - Codeforces Round #715 (Div. 2)
// URL: https://codeforces.com/contest/1509/problem/C
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)

/*
    authored by
    aden_frost
    on 07-03-2021
    Go Corona Corona Go!!
    hurray! mission - 1 - completed;
    mission - 2
    ____________

    40 more to go
*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define lli long long int
#define MOD1 998244353
#define MOD 1000000007
using namespace std;
using namespace std::chrono;
void fastaf(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
void solve(void)
{
	lli A,B;
	cin>>A>>B;
	map<lli,lli> mp;
	lli maxx=INT_MIN;
	for(lli i=A;i<=B;i++)
	{
		for(lli j=1;j<=sqrt(i);j++)
		{
			if(i%j==0)
			{
				if(i/j==j)
				{
					if(mp.find(j)!=mp.end())
						maxx=max(maxx,j);
					mp[j]++;
				}
				else
				{
					if(mp.find(j)!=mp.end())
						maxx=max(maxx,j);
					if(mp.find(i/j)!=mp.end())
						maxx=max(maxx,i/j);
					mp[j]++;
					mp[i/j]++;
				}
			}
		}
	}
	cout<<maxx;
}
/*
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
int main()
{
    fastaf();
    // int Testcases;
    // cin>>Testcases;
    // //freopen("input.txt","r",stdin);
    // //freopen("output.txt","w",stdout);
    // while(Testcases--)
    // {
        solve();
        cout<<"\n";
    // }
    return 0;
}


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

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

	int A[3];
	for (int i = 0; i < 3; ++i)
		cin >> A[i];
	sort(A, A + 3);
	if (A[0] + A[2] - 2 * A[1] == 0)
		cout << "Yes\n";
	else
		cout << "No\n";
}

#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
#include <stdio.h>
using namespace std;

#define mod 1000000007
#define mod2 998244353
#define ten5 100005
#define ten52 200005
#define ten53 300005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)

#define _debug 1
#if _debug
#endif // _debug

typedef long long int ll;
typedef unsigned long long int ull;

ll num[100];

void solve()
{
    for(int i=0;i<3;i++)
    {
        for(int j=i+1;j<3;j++)
        {
            if(num[i] > num[j])
                swap(num[i],num[j]);
        }
    }
}

int main(void)
{
    ll m,n,i=0,j=0,k=1;
    while(i<3)
    {
        cin>>num[i++];
    }

    solve();
    if(num[2] - num[1] == num[1] - num[0]) cout<<"Yes";
    else cout<<"No";
    return 0;
}