// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
// #include <unordered_map>
#include <set>
// #include <unordered_set>

#define debug(var)  do{std::cout << #var << " :";std::cout << std::endl;view(var);}while(0)
template<typename T> void view(T e){ std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){ int c = v.size(); std::cout << "{"; for(const auto& e : v){ std::cout << e; if (--c) std::cout << ", "; } std::cout << "}" << std::endl; }
template<typename T, typename U> void view(const std::pair<T, U>& v){ std::cout << v.first << ", " << v.second << std::endl; }
template<typename T> void view(const std::set<T>& v){ int c = v.size(); std::cout << "{"; for(const auto& e : v){ std::cout << e; if (--c) std::cout << ", "; } std::cout << "}" << std::endl; }
template<typename T, typename U> void view(const std::map<T, U>& v){ std::cout << "{" << std::endl; for(const std::pair<T, U>& e : v){ std::cout << e.first << ", " << e.second << std::endl; } std::cout << "}" << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv){ std::cout << "{" << std::endl; for(const auto& v : vv){ view(v); } std::cout << "}" << std::endl; }

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pii;
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; }
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
// const double PI = acos(-1);

int main() {
    vector<int> A(3);
    rep(i, 3) cin >> A[i];

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

    if (A[0] == A[1]) {
        cout << A[2] << endl;
    } else if (A[1] == A[2]) {
        cout << A[0] << endl;
    } else {
        cout << 0 << endl;
    }
}

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define MOD 1000000007LL
#define PI acos(-1)

template <typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
using max_heap = priority_queue<T>;

template <class T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename... T>
void read(T &...args) {
    ((cin >> args), ...);
}

template <typename... T>
void write(T &&...args) {
    ((cout << args), ...);
}

template <typename T>
void readContainer(T &t) {
    for (auto &e : t) {
        read(e);
    }
}

template <typename T>
void writeContainer(T &t) {
    for (const auto &e : t) {
        write(e, " ");
    }
    write("\n");
}

auto speedup = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    return nullptr;
}();

void solve(int tc) {
    long double A, B;
    read(A, B);
    long double ans = ((A - B) / A) * 100.0;
    cout << fixed << setprecision(16) << ans << "\n";
}

signed main() {
    int tc = 1;
    // read(tc);
    for (int curr = 1; curr <= tc; ++curr) {
        solve(curr);
    }
    return 0;
}


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

ll n,q;
vector<vector<ll>> G;
vector<P> edge;

int main(){
    cin>>n;
    G.resize(n);
    edge.resize(n-1);
    rep(i,n-1){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
        edge[i]={a,b};
    }
    vector<ll> depth(n,-1);
    depth[0]=0;
    queue<ll> que;
    que.push(0);
    while(!que.empty()){
        ll v=que.front(); que.pop();
        for(auto x:G[v]){
            if(depth[x]==-1){
                depth[x]=depth[v]+1;
                que.push(x);
            }
        }
    }
    vector<ll> s(n);
    cin>>q;
    rep(i,q){
        ll t,e,x;
        cin>>t>>e>>x;
        e--;
        ll a=edge[e].first,b=edge[e].second;
        if(t==1){
            if(depth[a]<depth[b]){
                s[0]+=x;
                s[b]-=x;
            }else{
                s[a]+=x;
            }
        }else{
            if(depth[a]>depth[b]){
                s[0]+=x;
                s[a]-=x;
            }else{
                s[b]+=x;
            }
        }
    }
    que.push(0);
    while(!que.empty()){
        ll v=que.front(); que.pop();
        for(auto x:G[v]){
            if(depth[x]>depth[v]){
                s[x]+=s[v];
                que.push(x);
            }
        }
    }
    rep(i,n) cout<<s[i]<<endl;
}

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

const int N = 17;
const int mod = 1e9+ 7;

int dp[(1<<N)][N];

int fx(vector<array<int,3>>&v, int mask , int last ){

    if(dp[mask][last] != -1){
      return dp[mask][last];
    }

    int n = v.size();

    if(mask == ((1<<n) -1)){

      int c = 0;
       for(int j =0;j<3;j++){

          if(j == 2){
             c += max(0LL,v[last][j] - v[0][j]);
          }else{
             c += abs(v[last][j] - v[0][j]);
          }

        }

       return c;
    }

    int ans = INT_MAX;

    for(int i = 1; i < n ; i ++){
       if( (mask&(1<<i)) == 0){
            int c = 0;
            for(int j =0;j<3;j++){

              if(j == 2){
                 c += max(0LL,v[last][j] - v[i][j]);
              }else{
                 c += abs(v[last][j] - v[i][j]);
              }

            }

            int nca = c + fx(v,mask|(1 << i) ,i);
            ans = min(ans,nca);

       }
    }

    return (dp[mask][last] = ans);
}

signed main(){

  int n;
  cin>>n;

  vector<array<int,3>>v;

  for(int i=0;i<n;i++){
    int x,y,z;
    cin>>x>>y>>z;
    v.push_back({x,y,z});
  }

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

  int ans = fx(v,1,0);
  cout<<ans<<endl;

  return 0;
}

// //
// n = 2;
// 1 2 3 4 5 ... n

// (1+2) / 2 = > 1

// n = 3
// 1 2 3

// (1+3)/2 => 2
// (2+2)/2 => 2

// n= 4
// ()

// 1 3 3
// 2 3

// 1 2 3
// 1 3
// 2

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


#include <bits/stdc++.h>

#define LL long long

#define ull unsigned long long

#define F(i, j, k) for(int i = j; i <= k; i++)

#define DF(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

template <typename T> inline void read(T &n) {
	T w = 1;
	n = 0;
	char ch = getchar();
	while (!isdigit(ch) && ch != EOF) {
		if (ch == '-') w = -1;
		ch = getchar();
	}
	while (isdigit(ch) && ch != EOF) {
		n = (n << 3) + (n << 1) + (ch & 15);
		ch = getchar();
	}
	n *= w;
}

template <typename T> inline void write(T x) {
	T l = 0;
	ull y = 0;
	if (!x) {
		putchar(48);
		return;
	}
	if (x<0) {
		putchar('-');
		x = -x;
	}
	while (x) {
		y = y * 10 + x % 10;
		x /= 10;
		l++;
	}
	while (l) {
		putchar(y % 10 + 48);
		y /= 10;
		l--;
	}
}

template <typename T> inline void writes(T x) {
	write(x);
	putchar(' ');
}

template <typename T> inline void writeln(T x) {
	write(x);
	puts("");
}

template <typename T> inline void checkmax(T &a,T b) { a = a > b ? a : b; }

template <typename T> inline void checkmin(T &a,T b) { a = a < b ? a : b; }

int num[26];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	string st;
	cin >> st;
	int l = st.size();
	LL ans = 0;
	DF(i, l - 1, 1) {
		if (st[i] == st[i - 1]) {
			if (i != l - 1 && st[i] != st[i + 1]) ans += l - 1 - i - num[int(st[i]) - 97];
		}
		if (i != l - 1 && st[i] == st[i + 1]) {
			F(j, 0, 25) num[j] = 0;
			num[int(st[i]) - 97] = l - i - 1;
		}
		++num[int(st[i]) - 97];
	}
	writeln(ans);
	return 0;
}

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

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

  ll N; cin >> N;
  string S; cin >> S;

  vector<vector<ll>> cnt(N + 1, vector<ll>(4, 0));
  for (ll i = 0; i < S.size(); i++) {
    for (ll j = 0; j < 4; j++) {
      cnt[i + 1][j] = cnt[i][j];
    }
    if (S[i] == 'A') cnt[i + 1][0]++;
    if (S[i] == 'T') cnt[i + 1][1]++;
    if (S[i] == 'C') cnt[i + 1][2]++;
    if (S[i] == 'G') cnt[i + 1][3]++;
  }

  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    for (ll j = i + 1; j <= N; j++) {
      vector<ll> temp(4, 0);
      for (ll k = 0; k < 4; k++) {
        temp[k] = cnt[j][k] - cnt[i][k];
      }
      if (temp[0] == temp[1] && temp[2] == temp[3]) ans++;
    }
  }
  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 MAX 300100
#define MAXLG 20
const int inf = 0x3f3f3f3f;
const ll mod = 998244353;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const int N = 300100;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//knapstack
ll fat[MAX+100];
ll ifat[MAX+100];

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

void init(){
	fat[0] = 1;
	for(ll i=1;i<=MAX;i++){
	  fat[i] = (fat[i-1]*i)%mod;
	}
	ifat[MAX] = power(fat[MAX], mod-2, mod);
	for(ll i=MAX-1;i>=0;i--) ifat[i] = (ifat[i+1]*(i+1))%mod;
}

ll choose(int x, int y){
	if(y < 0 || y > x || x < 0) return 0;
	return fat[x]*(ifat[y]*ifat[x-y]%mod)%mod;
}

int n, m;
int dp[5010][20];
int vis[5010][20];

int sol(int x, int y){
	if(y == 17){
		if(x) return 0;
		return 1;
	}
	if(vis[x][y]) return dp[x][y];
	vis[x][y] = 1;
	int &c = dp[x][y];
	for(int i=0;i<=n;i+=2){
		if( (1<<y)*i > x) break;
		c = (c + sol(x - (1<<y)*i, y+1)*choose(n, i)%mod)%mod;
	}
	return c;
}

void solve(){
	init();
	cin>>n>>m;
	cout<<sol(m, 0)<<"\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>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
//#define int long long
typedef long long ll;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define done(x) {cout << x << endl;return;}
#define mini(x,y) x=min(x,y)
#define maxi(x,y) x=max(x,y)
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;
uniform_int_distribution<int> rng(1,1e9);

//DEBUG FUNCTIONS START
#define cerr cout
void __print(int x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
//#define deb(x...) cerr << "[" << #x << "] = "; _print(x)
#define deb(x...)  _print(x)
#else
#define deb(x...)
#endif
// DEBUG FUNCTIONS END

int N = 2e5+5;

void solve(){

	int n, m, t;
	cin >> n >> m >> t;
	N = n;
	vpii a(m);
	rep(i,0,m)
		cin >> a[i].fi >> a[i].se;

	int prev = 0;
	rep(i,0,m){
		n -= (a[i].fi - prev);
		if(n <= 0)
			done("No");
		n += a[i].se - a[i].fi;
		mini(n, N);
		prev = a[i].se;
	}

	if(n > t - prev)
		done("Yes");

	done("No");

}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

int powm(int a, int b){
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b % mod, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


#include <iostream>
#include <vector>
#include <utility>
#include<algorithm>
#include <string>
#include <map>
#include <cmath>
#include <random>
#include <tuple>
#include <set>
#include <queue>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod % 1000000007

using namespace std;

int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  ll kk = k;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
  }
  vector<vector<ll>> x(n,vector<ll>(n,0));
  rep(i,n){
    x[i][i] = 2*m;
  }
  rep(i,m){
    ll c,d;
    cin >> c >> d;
    x[c-1][d-1] = 1;
    x[d-1][c-1] = 1;
    x[c-1][c-1] --;
    x[d-1][d-1] --;
  }
  while(k != 0){
    if(k % 2 != 0){
      vector<ll> b(n,0);
      rep(i,n){
        rep(j,n){
          b[i] = (b[i]+a[j]*x[j][i])mod;
        }
      }
      a = b;
    }
    k = k/2;
    vector<vector<ll>> b(n,vector<ll>(n,0));
    rep(i,n){
      rep(j,n){
        rep(h,n){
          b[i][j] = (b[i][j] + x[h][j] * x[i][h])mod;
        }
      }
    }
    x = b;
  }
  ll t = 1;
  ll s = 1;
  ll d = 2*m;
  k = kk;
  while(k != 0){
    if(k % 2 == 1){
      s = (s*d)mod;
    }
    d = (d*d)mod;
    k = k/2;
  }
  ll rem = 1000000005;
  while(rem != 0){
    if(rem % 2 == 1){
      t = (t*s) mod;
    }
    s = (s*s)mod;
    rem = rem/2;
  }
  rep(i,n){
    ll z = (a[i]*t)mod;
    cout << z << endl;
  }

  return 0;
}

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

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

const int mod = 1e9 + 7;
int dp[3][100][100];
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M, K;
	cin >> N >> M >> K;
	int A[100];
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, N) dp[0][i][i] = 1;
	rep(i, N) dp[1][i][i] = 1;
	int are = modpow(2 * M, mod - 2);

	rep(i, M) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		(dp[0][x][x] += mod - are) %= mod;
		(dp[0][x][y] += are) %= mod;
		(dp[0][y][x] += are) %= mod;
		(dp[0][y][y] += mod - are) %= mod;
	}

	auto mae = dp[1], ato = dp[2];
	rep(i, 30) {
		rep(x, N) rep(y, N) {
			ll tmp = 0;
			rep(z, N) {
				tmp += mae[x][z] * (ll)mae[z][y] % mod;
			}
			ato[x][y] = tmp % mod;
		}
		swap(mae, ato);

		if (K >> 29 - i & 1) {
			rep(x, N) rep(y, N) {
				ll tmp = 0;
				rep(z, N) {
					tmp += mae[x][z] * (ll)dp[0][z][y] % mod;
				}
				ato[x][y] = tmp % mod;
			}
			swap(mae, ato);
		}
	}

	rep(i, N) {
		ll kotae = 0;
		rep(j, N) kotae += (ll)mae[i][j] * A[j] % mod;
		co(kotae % mod);
	}

	Would you please return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=(a); i<(n); i++)
#define rrep(i,a,n) for(int i=(a); i>=(n); i--)
#define all(n) begin(n),end(n)
#define rall(n) rbegin(n),rend(n)
//#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> inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;}
template <typename T> inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;}
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }

void _main() {
    int a,b;
    cin>>a>>b;
    vl e(a+b);
    if(a >= b) {
        rep(i,0,a) e[i] = i+1;
        rep(i,a,a+b-1) e[i] = -(i+1-a);
        rep(i,0,a+b-1) e[a+b-1] -= e[i];
    }else{
        rep(i,0,a-1) e[i] = i+1;
        rep(i,a,a+b) e[i] = -(i+1-a);
        rep(i,0,a+b){
            if(i != a-1) e[a-1] -= e[i];
        }
    }
    rep(i,0,a+b){
        if(i) cout<<" ";
        cout<<e[i];
    }
    cout<<endl;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  long long a = 0;
  if(A > B){
    for(int i = 1; i <= A; i++){
      cout << i << " ";
      a += i;
    }
    for(int i = 1; i < B; i++){
      cout << -i << " ";
      a -= i;
    }
    cout << -a << endl;
  }else if(A < B){
    for(int i = 1; i <= B; i++){
      cout << -i << " ";
      a += i;
    }
    for(int i = 1; i < A; i++){
      cout << i << " ";
      a -= i;
    }
    cout << a << endl;
  }else{
    for(int i = 1; i <= A; i++){
      cout << i << " " << -i;
      if(i != A){
        cout << " ";
      }else{
        cout << endl;
      }
    }
  }
}


#include <bits/stdc++.h>
// #include <atcoder/all>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using pii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
using db = double;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define V vector
#define pi 3.14159265358979
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define cii(x) int x;cin >> x
#define cci(x,y) int x,y;cin >> x >> y
#define co(x) cout << x << endl
void chmax(int &x,int y){x=max(x,y);}
void chmin(int &x,int y){x=min(x,y);}

int main(){
  cci(n,m);
  int n2=n/2;

  vi mi(n2),ma(n2),v(n);
  rep(i,0,n)ci(v[i]);

  vi tc(m);
  rep(i,0,m)ci(tc[i]);

  sort(all(v));
  sort(all(tc));
  rep(i,0,n-1)(i%2?ma:mi)[i/2]=v[i+1]-v[i];
  // rep(i,0,n2)cout<<mi[i]<<" ";

  vi smi(n2+1,0),sma(n2+1,0);
  rep(i,1,n2+1)smi[i]=smi[i-1]+mi[i-1];
  rep(i,0,n2)sma[n2-i-1]=sma[n2-i]+ma[n2-i-1];
// co("v");for(int x:v)cout<<x<<" ";co("");
// co("tc");for(int x:tc)cout<<x<<" ";co("");
// co("smi");for(int x:smi)cout<<x<<" ";co("");
// co("sma");for(int x:sma)cout<<x<<" ";co("");

  int ans=1001001001;
  rep(i,0,m){
    int nx=lower_bound(all(v),tc[i])-v.begin();
    nx/=2;
    int dis=abs(v[nx*2]-tc[i]);
    int now=smi[nx]+dis+sma[nx];
    chmin(ans,now);
  }
  co(ans);
}

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

#define dbg(v) cout << __LINE__ << ": " << #v << " = " << v << endl

const int N = 1e5 + 5;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    vector <int> h(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }
    sort(h.begin(), h.end());
    vector <long long> pre(n), suf(n);
    for (int i = 1; i < n; i += 2) {
        pre[i] = h[i] - h[i - 1];
        if (i > 1) {
            pre[i] += pre[i - 2];
        }
    }
    for (int i = n - 2; i >= 0; i -= 2) {
        suf[i] = h[i + 1] - h[i];
        if (i + 2 < n) {
            suf[i] += suf[i + 2];
        }
    }
    long long ans = LLONG_MAX;
    for (int it = 0; it < m; it++) {
        int w;
        scanf("%d", &w);
        int pos = lower_bound(h.begin(), h.end(), w) - h.begin();
        long long now;
        if (pos & 1) {
            now = w - h[pos - 1];
            if (pos - 2 >= 0) {
                now += pre[pos - 2];
            }
            if (pos < n) {
                now += suf[pos];
            }
        }
        else {
            now = h[pos] - w;
            if (pos - 1 >= 0) {
                now += pre[pos - 1];
            }
            if (pos + 1 < n) {
                now += suf[pos + 1];
            }
        }
        ans = min(ans, now);
    }
    printf("%lld\n", ans);
    return 0;
}


#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
using namespace std;
const int BUF = 200005;
const int INF = 1 << 30;

class SegTree{
public:
  vector<long long> v;
  vector<long long> cnt;

  SegTree(){
    v = vector<long long>(BUF * 4, 0);
    cnt = vector<long long>(BUF * 4, 0);
  }

  pair<long long, int> get(int node, int L, int R, int LQ, int RQ){
      if(R<LQ || RQ<L) return make_pair(0, 0);
      if(LQ<=L && R<=RQ) return make_pair(v[node], cnt[node]);
      pair<long long, int> s = get(node*2+1,L,(L+R)/2,LQ,RQ);
      pair<long long, int> t = get(node*2+2,(L+R)/2+1,R,LQ,RQ);
      return make_pair(s.first + t.first, s.second + t.second);
  }

  pair<long long, int> update(int node, int L, int R, int Q, int chVal){
      if(R<Q || Q<L) return make_pair(v[node], cnt[node]);
      if(L==R) {
          v[node] += chVal;
          if (chVal > 0) ++cnt[node];
          if (chVal < 0) --cnt[node];
          return make_pair(v[node], cnt[node]);
      }
      pair<long long, int> s = update(node*2+1,L,(L+R)/2,Q,chVal);
      pair<long long, int> t = update(node*2+2,(L+R)/2+1,R,Q,chVal);
      v[node] = s.first + t.first;
      cnt[node] = s.second + t.second;
      return make_pair(v[node], cnt[node]);
  }
};

int row, col, nQuery;
int query[BUF][3];

void read() {
    cin >> row >> col >> nQuery;
    for (int i = 0; i < nQuery; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> query[i][j];
        }
        --query[i][1];
    }
}

void work() {
    static int row2val[BUF] = {};
    static int col2val[BUF] = {};

    vector<int> vList;
    vList.push_back(-1);
    vList.push_back(0);
    vList.push_back(INF);
    for (int i = 0; i < nQuery; ++i) {
        vList.push_back(query[i][2]);
    }
    sort(vList.begin(), vList.end());
    vList.erase(unique(vList.begin(), vList.end()), vList.end());

    map<int, int> val2idx;
    for (int i = 0; i < vList.size(); ++i) {
        val2idx[vList[i]] = i;
    }

    SegTree rowStree = SegTree();
    SegTree colStree = SegTree();

    long long ans = 0;
    for (int loop = 0; loop < nQuery; ++loop) {
        int type = query[loop][0], idx = query[loop][1], val = query[loop][2];

        if (type == 1) {
            // row
            int pre = row2val[idx];

            ans -= 1LL * col * pre;
            ans += colStree.get(0, 0, BUF - 1, val2idx[0], (--val2idx.find(pre))->second).first;
            ans += 1LL * colStree.get(0, 0, BUF - 1, val2idx[pre], val2idx[INF]).second * pre;

            ans += 1LL * col * val;
            ans -= colStree.get(0, 0, BUF - 1, val2idx[0], (--val2idx.find(val))->second).first;
            ans -= 1LL * colStree.get(0, 0, BUF - 1, val2idx[val], val2idx[INF]).second * val;

            row2val[idx] = val;
            rowStree.update(0, 0, BUF - 1, val2idx[val],  val);
            rowStree.update(0, 0, BUF - 1, val2idx[pre], -pre);
        } else {
            // col
            int pre = col2val[idx];

            ans -= 1LL * row * pre;
            ans += rowStree.get(0, 0, BUF - 1, val2idx[0], (--val2idx.find(pre))->second).first;
            ans += 1LL * rowStree.get(0, 0, BUF - 1, val2idx[pre], val2idx[INF]).second * pre;

            ans += 1LL * row * val;
            ans -= rowStree.get(0, 0, BUF - 1, val2idx[0], (--val2idx.find(val))->second).first;
            ans -= 1LL * rowStree.get(0, 0, BUF - 1, val2idx[val], val2idx[INF]).second * val;

            col2val[idx] = val;
            colStree.update(0, 0, BUF - 1, val2idx[val],  val);
            colStree.update(0, 0, BUF - 1, val2idx[pre], -pre);
        }

        cout << ans << endl;
    }
}

int main() {
    read();
    work();
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const long long N=2e6+6;
ll a[N],b[N];
long long n,m,q,ans;
struct segment {
	long long siz[N<<2],sum[N],ls[N<<2],rs[N<<2],cnt=0,root=0;
	void change(ll l,ll r,ll &p,ll x,ll k) {
		if(!p) p=++cnt;
		if(l==r) {
			sum[p]+=k*x;
			siz[p]+=k;
			return;
		}
		ll mid=(l+r)>>1;
		if(x<=mid) change(l,mid,ls[p],x,k);
		else change(mid+1,r,rs[p],x,k);
		sum[p]=sum[ls[p]]+sum[rs[p]];
		siz[p]=siz[ls[p]]+siz[rs[p]];
	}
	ll query1(ll l,ll r,ll p,ll x) {
		if(!p) return 0;
		if(r<=x) return siz[p];
		ll mid=(l+r)>>1;
		if(x<=mid) return query1(l,mid,ls[p],x);
		else return siz[ls[p]]+query1(mid+1,r,rs[p],x);
	}
	ll query2(ll l,ll r,ll p,ll x) {
		if(!p) return 0;
		if(l>x) return sum[p];
		ll mid=(l+r)>>1;
		if(x<=mid) return sum[rs[p]]+query2(l,mid,ls[p],x);
		else return query2(mid+1,r,rs[p],x);
	}
} A,B;
signed main() {
	scanf("%lld %lld %lld",&n,&m,&q);
	A.change(0,1e8,A.root,0,n),B.change(0,1e8,B.root,0,m);
	for(long long i=1;i<=q;i++) {
		long long opt,t,x,y;
		cin>>opt>>x>>y;
		if(opt==1) {
			ans=ans-B.query1(0,1e8,B.root,a[x])*a[x]-B.query2(0,1e8,B.root,a[x]);
			A.change(0,1e8,A.root,a[x],-1);
			A.change(0,1e8,A.root,y,1);
			a[x]=y;
			ans+=B.query1(0,1e8,B.root,y)*y+B.query2(0,1e8,B.root,y);
		}
		else {
			ans=ans-A.query1(0,1e8,A.root,b[x])*b[x]-A.query2(0,1e8,A.root,b[x]);
			B.change(0,1e8,B.root,b[x],-1);
			B.change(0,1e8,B.root,y,1);
			b[x]=y;
			ans+=A.query1(0,1e8,A.root,y)*y+A.query2(0,1e8,A.root,y);
		}
		cout<<ans<<endl;
	}
	return 0;
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
#include<map>
#include<complex>
#include<functional>
#include<stack>
#include<queue>
#include<set>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long ll;
typedef long double ld;
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; }
const ll INF = 1e18;
ll mod = 1e9 + 7;
int main() {
    int n, d, s,x,y; cin >> n >> s >> d;
    bool ok = 0;
    rep(i, n) {
        cin >> x >> y;
        if (x<s && y>d)ok = 1;
    }if (ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lop ios; ll t; cin>>t; while(t--)
#define pb push_back
#define vi vector<ll>
#define vivi vector<vector<ll>>
#define vipa vector<pair<ll,ll>>
#define F first
#define S second
#define M 1000000007
#define kl "\n"
#define all(v) v.begin(),v.end()
typedef long long ll;
ll lcm(ll x, ll y){ll k=x*y; k/=(__gcd(x,y)); return k;}
ll power(ll x,ll y){ ll r= 1;x = x % M;if(x==0) return 0; while(y>0) {if(y&1) r=(r*x)%M; y=y>>1; x=(x*x)%M;} return r;}

void solve()
{
    ll n,s,d;
    cin>>n>>s>>d;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        if(a < s and b > d){
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}
int main()
{

    // lop
    solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int k;
        cin>>k;
        int ans=0;
        for(int i=1;i<=k;i++){
          for(int j=1;j<=k;j++){
             int x=i*j;
             if(x>k){
              break;
             }
             else{
              ans=ans+k/x;
             }
          }
        }
        cout<<ans<<endl;
        return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define RREP(i, n) for(int i=(n);i>=0;--i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, b) for(int i=(a);i>=(b);--i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}

template<class T>
void debug(const vector<T> &v) {
  cout << "[";
  REP(i, SZ(v)) {
    if (i) cout << ", ";
    cout << v[i];
  }
  cout << "]" << endl;
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << " " << p.second;
}

template<class T, class U>
void debug(const pair<T, U> &p) {
  cout << "(" << p.first << " " << p.second << ")" << endl;
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int inf = INT_MIN;
const ll linf = LLONG_MIN;
const ld eps = 1e-9;

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

  ll n;
  cin >> n;

  ll cnt = 0;
  ll l = 1, r = n+1;
  while (r - l > 1) {
    ll mid = (l + r) / 2;
    if (LINF / mid < mid + 1) {
      r = mid;
      continue;
    }
    ll su = mid * (mid + 1) / 2;
    if (su <= n + 1) {
      l = mid;
    } else {
      r = mid;
    }
  }

  cnt = l - 1;

  cout << n - cnt << endl;

  return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>;
using vb = vector<bool>;
using ll = long long; //約9.0*10^18
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll =vector<vvll>;
using std::reverse;
const double PI=3.14159265358979323846;
const ll inf=9223372036854775807;

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

ll fac(ll n) {ll ans=1;rep0(i,n){ans=ans*(n-i);};return ans;}//n!
ll conb(ll n,ll m){return fac(n)/fac(m)/fac(n-m);}//nCm

//小数点以下を指定したい時　　→→→→  cout << fixed << setprecision();
//int→string　　string str = to_string(num);
//string→int   int num = atoi(numStr.c_str());
//複数のvector管理→;vector<tuple<string, int, int>> SP(N);
//int max = *max_element(all(A));最大値
//int min = *min_element(all(B));最小値
//floor(x)=[x]
// *max_element(a.begin(),a.begin()+5);aの最初から6番目までの最大値/計算量に不安あり
// *min_element(,);
// sort は昇順１２３４５
//普通の割り算がしたい→cout<<(double)3/2/2<<endl;
//ll A = lower_bound(a,a+n,x) - a;xになった瞬間のi
//ll B = upper_bound(c,c+n,x) - c;xを超えた瞬間のi

//ll n;cin>>n;vll a(n);rep0(i,n){cin>>a[i];}

int main() {
    ll n;cin>>n;
    vll a(n);
    rep0(i,n){
        cin>>a[i];
    }
    sort(all(a));
    ll ans = 0;
    rep0(i,n){
        ans+=(2*i-n+1)*a[i];
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		printf("%d %d\n",(i*2-1)%n+1,(i*2)%n+1);

	return 0;
}


/*
    author : aryan57
    created : 16-May-2021 18:55:19 IST
*/
#include <bits/stdc++.h>
using namespace std;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

#define int long long
#define X first
#define Y second
#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define F(i, a, b) for (int i = a; i <= b; i++)
#define RF(i, a, b) for (int i = a; i >= b; i--)

const int mxn = 1e5;
const long long INF = 2e18;
const int32_t M = 1000000007;
// const int32_t M = 998244353;
const long double pie = acos(-1);

int same(vector <int> &a,vector <int> &b)
{
    map<int,int> mp;

    mp[0]=1;
    int pa=0;
    int pb=0;
    for(int i=0;i<min(sz(a),sz(b));i++)
    {
        pa+=a[i];
        pb+=b[i];
        mp[pa-pb]++;
    }

    int cnt=0;

    for(pair <int,int> p : mp)
    {
        int num=p.Y;

        cnt+=(num)*(num-1)/2;
    }

    return cnt;
}
int other(vector <int> &a,vector <int> &b)
{
    map<int,int> mp1;
    int n=min(sz(a),sz(b));
    vector <int> pa(n+1);
    vector <int> pb(n+1);
    mp1[0]=1;
    for(int i=1;i<=n;i++)
    {
        pa[i]=pa[i-1]+a[i-1];
        pb[i]=pb[i-1]+b[i-1];
        mp1[pa[i]-pb[i]]++;
    }
    mp1[pa[n]-pb[n]]--;
    int cnt=0;
    // dbg(a);
    // dbg(b);
    // dbg(mp1);

    if(sz(a)>sz(b))
    {
        int dif=pa[n]+a[n]-pb[n];
        // dbg(dif,n,a[n],pa[n],pb[n]);
        cnt+=mp1[dif];
    }

    for(int i=n;i>=2;i--)
    {
        mp1[pa[i-1]-pb[i-1]]--;
        int dif=pa[i]-pb[i-1];

        // dbg(i,dif);
        // dbg(mp1);

        cnt+=mp1[dif];
    }

    // dbg(cnt);

    return cnt;
}

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

    vector <int> a(n);
    vector <int> v1e,v1o;
    vector <int> v2e,v2o;
    F(i,0,n-1)
    {
        cin>>a[i];
    }

    for(int i=0;i<n;i+=1)
    {
        if(i%2)v1o.push_back(a[i]);
        else v1e.push_back(a[i]);
    }
    for(int i=1;i<n;i+=1)
    {
        if(i%2)v2e.push_back(a[i]);
        else v2o.push_back(a[i]);
    }

    int cnt=0;

    cnt+=same(v1e,v1o);
    cnt+=same(v2e,v2o);
    // dbg(cnt);
    cnt+=other(v1e,v1o);
    cnt+=other(v2e,v2o);

    cout<<cnt;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif
#ifdef ARYAN_SIEVE
    sieve();
#endif
#ifdef ARYAN_SEG_SIEVE
    segmented_sieve();
#endif
#ifdef ARYAN_FACT
    fact_init();
#endif
    // cout<<fixed<<setprecision(10);
    int _t=1;
    // cin>>_t;
    for (int i=1;i<=_t;i++)
    {
        // cout<<"Case #"<<i<<": ";
        solve_LOG();
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 1000000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    vector<ll> asum(n);
    map<ll,ll> m;
    ll tot = 0;
    REP(i,n) {
        cin >> a[i];
        if (i%2==0) tot+=a[i];
        else tot-=a[i];
        asum[i]=tot+INF;
    }
    REP(i,n) {
        m[asum[i]]++;
    }
    m[INF]++;
    // REP(i,n) cout << asum[i]-INF << " ";
    // cout << endl;
    ll ans = 0;
    for (auto ite=m.begin();ite!=m.end();ite++) {
        ll cnt = ite->second;
        ans += cnt*cnt-cnt;
    }
    cout << ans/2 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 500000
typedef long long ll;
typedef unsigned long long ull;
inline ll read() {
	char ch;
	ll f = 1, res = 0;
	while ((ch = getchar()) < '0' || ch > '9')
		if (ch == '-') f = -1;
	while (ch >= '0' && ch <= '9') {
		res = (res << 1) + (res << 3) + (ch ^ 48);
		ch = getchar();
	}
	return f * res;
}
inline void pt(ll u,ll mod) {
	printf("%lld", u);
	if (mod == 1)
		putchar(' ');
	else if (mod == 2)
		putchar('\n');
}

bool con[1010][1010]={false};
ll mat[1010][1010];
vector<ll>e[M][26];
ll m,n;
ll ans=1e15;
char c;
//struct node {
//	ll x, y;
//};

void dfs(ll inx1,ll inx2,ll v ) {
//	pt(inx1,inx2);
	if (v >= ans)
		return;
	mat[inx1][inx2] = v;
	if (con[inx1][inx2]) {
		if (inx1 == inx2)
			ans = v;
		else
			ans = v + 1;
	}
	for (ll i = 0; i < 26; i++) {
		for (auto u:e[inx1][i])
			for (auto p:e[inx2][i]) {
				if (mat[u][p] > v + 2)
					dfs(u, p, v + 2);
			}
	}
}
int main() {
	//freopen("../in", "r", stdin);
	//freopen("../out", "w", stdout);
	memset(mat, 0x3f, sizeof(mat));
	m = read(), n = read();
	ll a, b;
	for (ll i = 0; i < n; i++) {
		a = read(), b = read();
		scanf("%c", &c);
		con[a][b] = true;
		con[b][a] = true;
		e[a][c - 'a'].push_back(b);
		e[b][c - 'a'].push_back(a);
	}
	for (ll i = 1; i <= m; i++)
		con[i][i] = true;
	dfs(1, m, 0);
	if (ans > 1e14)
		pt(-1, 2);
	else
		pt(ans, 2);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define setbits(n) __builtin_popcountll(n)
#define mkunique(a) sort(a.begin(),a.end()); a.resize(unique(a.begin(),a.end())-a.begin());
#define print(s) for(ll u: s) cout<<u<<" "; cout<<"\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;

const int N=1e5+10;
vector<pair<ll,pair<ll,ll>>> a[N];

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll TT=clock();

    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m;i++){
        ll u,v,c,d;
        cin>>u>>v>>c>>d; u--,v--;
        a[u].pb({v,{c,d}});
        a[v].pb({u,{c,d}});
    }
    vector<ll> d(n,mod*mod);
    d[0] = 0;
    set<pair<ll,ll>> s;
    s.insert({0,0});
    while(!s.empty()){
        ll v = s.begin()->ss;
        s.erase(s.begin());
        for(auto ed: a[v]){
            ll u = ed.ff, c = ed.ss.ff, dd = ed.ss.ss;
            ll t = d[v];
            ll cost = t + c + dd/(t+1);
            ll opt = max(t,(ll)sqrt(dd) - 1);
            cost = min(cost, opt + c + dd/(opt+1));
            opt++;
            cost = min(cost, opt + c + dd/(opt+1));
            if(cost < d[u]){
                s.erase({d[u],u});
                d[u] = cost;
                s.insert({d[u],u});
            }
        }
    }
    if(d[n-1]==mod*mod)
        cout<<-1;
    else
        cout<<d[n-1];

    cerr<<"\n\nTIME: "<<(long double)(clock()-TT)/CLOCKS_PER_SEC<<" sec\n";
    TT = clock();
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <bitset>
#include <cassert>
#include <math.h>
#include <complex>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#ifdef _OLIMPOLOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1337
#endif
void debug_out() { cout << "\n";}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) { cout << " " << A; debug_out(B...); }
int test = 1;
#define out(x) {cout << x << "\n";return;}
#define all(N) N.begin(),N.end()
#define allr(N) N.rbegin(),N.rend()
template<typename T1>
void pr(vector<T1> V, int add = 0, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = V.size() - 1;
    for (int i = start; i <= end; i++) {
        cout << V[i] + add << ((i == end) ? "\n" : " ");
    }
}
template<typename T1>
T1 chmin(T1 &x, const T1 v) { return x = min(x,v); }
template<typename T1>
T1 chmax(T1 &x, const T1 v) { return x = max(x,v); }

#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define repsr(i, s, n) for (int i = n-1; i >= s; i--)
#define PI pair<int,int>
template<typename T1>
T1 gcd(const T1 &a, const T1 &b) {
    if (a == 0 || b == 0) return a + b;
    return gcd(b, a %b);
}
//-------------------------- ^ DONT TOUCH ^-----------------------------------------------------------------
#define MAX 200001
#define MOD 998244353

int N[21];
int bx, n;

void comb(int i, int xr, int x) {
    if (i == -1) {
        chmin(bx, x ^ xr);
        return;
    }
    if (x > 0) comb(i-1, xr ^ x, N[i]);
    comb(i-1, xr, x | N[i]);
}

void solve() {
    cin >> n;
    rep(i,n) cin >> N[i];
    bx = INT_MAX;
    comb(n-1,0,0);
    out(bx);
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int test = 1;
#ifdef _OLIMPOLOCAL
    cin >> test;
#endif
    rep(testCase, test) {
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl
#define maxn 3e5+50

using namespace std;
typedef long long ll;
typedef long long LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

const ll mod = 1e9+7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

void solve(){
    int n;cin >> n;
    vector<int>a(n);
    for(int i = 0;i<n;i++) cin >> a[i];
    int ans = INT_MAX;
    int start = a[0];
    for(int mask = 0;mask<(1<<(n-1));mask++){
        int tp = start;
        int tp2 = mask;
        int cnt = 1;
        vector<int>b;
        while(tp2){
            if(tp2%2){b.push_back(tp);tp = a[cnt];}
            else tp |= a[cnt];
            cnt++;tp2 /= 2;
        }
        for(int  i = cnt;i<n;i++) tp |= a[i];
        b.push_back(tp);
        int now = b[0];
        for(int i = 1;i<b.size();i++) now ^= b[i];
        ans = min(ans,now);
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
   // freopen("shuffle.in","r",stdin);
   // freopen("shuffle.out","w",stdout);
    solve();
    return 0;
}


//Author- Vaibhav Singh

#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
#define vl vector<ll>
#define vc vector<char>
#define ul unordered_map<ll,ll>
#define uc unordered_map<char,ll>
#define vp vector<pair<ll,ll>>
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }

    }
}
  */

  ll powerm(ll x, unsigned ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
  long long lcm(long long a, long long b){//?????????
   return a * b / gcd(a, b);
}

/*
ll po(ll z,ll z1)
{
    ll rer=0;
    rer=     ((z*(z-1))/2+(z1*(z1-1))/2);
    return rer;

}
*/
/*
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
*/
/*
bool is_prime(ll n){
    for(ll i = 2;i*i<=n;i++){
        if(n%i == 0) return false;
    }
    return true;
}
*/
/*
int inv(int a){
    return powerm(a,mod-2,mod);
}

ll const N=1e5;
ll fact[N], invfact[N];

void precompute(){
    fact[0] = 1;
    for(int i=1;i<N;i++) fact[i] = (fact[i-1]*i)%mod;
    invfact[N-1] = inv(fact[N-1])%mod;
    for(int i=N-2;i>=0;i--) invfact[i] = (invfact[i+1]*(i+1))%mod;
}

ll ncr(ll n, ll r){
    if(n<r) return 0;
    return (((fact[n]*invfact[r])%mod)*invfact[n-r])%mod;
}
*/

//****************************************************************************
//****************************************************************************
//****************************************************************************
//****************************************************************************
//****************************************************************************
//****************************************************************************
//****************************************************************************
//*88888*********5555555555555555******88888888$$$$$$$$$$******!!!!!!!!!!

       int main()
       {
       fast
       ll a,b;
       cin>>a>>b;
       ll x=abs(a-b);
       if(x<=2)
       {
           Yes
       }
       else
       {
           No
       }

//?????????
re}

/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 510;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, lab[MAXN], upperL, upperR, lowerL, lowerR;
II a[MAXN];

int getRoot(int u) {
    while (lab[u] > 0) u = lab[u];
    return u;
}

int same(int u, int v) {
    return getRoot(u) == getRoot(v);
}

void unionFind(int u, int v) {
    u = getRoot(u);
    v = getRoot(v);
    int x = lab[u] + lab[v];
    if (lab[u] < lab[v]) {
        lab[v] = u;
        lab[u] = x;
    }
    else {
        lab[u] = v;
        lab[v] = x;
    }
}

int dist(int i, int j) {
    return (a[i].FI - a[j].FI) * (a[i].FI - a[j].FI) + (a[i].SE - a[j].SE) * (a[i].SE - a[j].SE);
}

bool check(ld r) {
    FOR(i,1,n) lab[i] = -1;
    FOR(i,1,n)
        FOR(j,i+1,n) {
            // cout << i << ' ' << j << ' ' << dist(i, j) << endl;
            if (dist(i, j) <= 4*r*r)
                if (!same(i, j)) {
                    // cout << i << ' ' << j << endl;
                    unionFind(i, j);
                }
        }
    FOR(i,upperL,upperR)
        FOR(j,lowerL,lowerR)
            if (same(i,j)) return false;
    return true;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i].FI >> a[i].SE;
    FOR(i,-100,100) {
        n++;
        if (i == -100) upperL = n;
        if (i == 100) upperR = n;
        a[n] = II(i, 100);
    }
    FOR(i,-100,100) {
        n++;
        if (i == -100) lowerL = n;
        if (i == 100) lowerR = n;
        a[n] = II(i, -100);
    }
    // cout << check(50) << endl;
    ld dau = 0, cuoi = 100;
    FOR(i,1,100) {
        ld mid = (dau + cuoi) / 2;
        if (check(mid)) dau = mid;
        else cuoi = mid;
    }
    cout << fixed << setprecision(9) << dau;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[2000005], b[2000005], tree[4*300000];

void build(ll node, ll lo, ll hi)
{
    if(lo==hi)
    {
        tree[node] =a[lo];
        return;
    }

    ll left = node*2, right = left+1;
    ll mid = (lo+hi)/2;
    build(left, lo, mid);
    build(right, mid+1, hi);

    tree[node] = tree[left]^tree[right];
}

void update(ll node, ll lo, ll hi, ll i, ll val)
{
    if(lo>i||hi<i)
        return;
    if(lo==i&&hi==i)
    {
        tree[node]^=val;
        return;
    }
    ll left = node*2, right = left+1;
    ll mid = (lo+hi)/2;

    update(left, lo,mid, i,val);
    update(right, mid+1, hi, i,val);

    tree[node] = tree[left]^tree[right];

}

ll  query(ll node, ll lo, ll hi, ll i, ll j)
{
    if(lo>j||hi<i)
        return 0LL;
    if(lo>=i&&hi<=j)
    {
        return tree[node];
    }
    ll left = node*2, right = left+1;
    ll mid = (lo+hi)/2;
    ll p = query(left, lo, mid, i,j);
    ll q = query(right, mid+1, hi, i, j);

    return p^q;
}
int main()
{

    ll  n, q;
    cin >> n >> q;
    for(ll i=1;i<=n;i++) cin >> a[i];
    build(1,1,n);

    while(q--)
    {
        ll t, x, y;
        scanf("%lld%lld%lld",&t,&x,&y);
        if(t==1)
        {
            update(1,1,n,x,y);
        }
        else
        {
            ll ans = query(1,1,n,x,y);
            printf("%lld\n",ans);
        }
    }

}

#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ri register int
#define ll long long
#define ui unsigned int
il ll read(){
    bool f=true;ll x=0;
    register char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=false;ch=getchar();}
    while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    if(f) return x;
    return ~(--x);
}
il int read(char *s){
    int len=0;
    register char ch=getchar();
    while(ch==' '||ch=='\n') ch=getchar();
    while(ch!=' '&&ch!='\n'&&ch!=EOF) s[++len]=ch,ch=getchar();
    return len;
}
il void write(const ll &x){if(x>9) write(x/10);putchar(x%10+'0');}
il void print(const ll &x) {x<0?putchar('-'),write(~(x-1)):write(x);putchar('\n');}
il ll max(const ll &a,const ll &b){return a>b?a:b;}
il ll min(const ll &a,const ll &b){return a<b?a:b;}ll n;
string c;
const ll mod =1e9+7;
il ll ksm(ll d,ll t){
    ll res=1;
    for(;t;t>>=1,d=d*d%mod)
        if(t&1) res=res*d%mod;
    return res;
}
struct hmap{
    static const int P=2e6+3,M=3e6+10;
    int hed[M],nxt[M],cnt;ll val[M];ll as[M];
    bool count(ll x){
        int c=hed[x%P];
        while(c){
            if(val[c]==x) return 1;
            c=nxt[c];
        }return 0;
    }
    ll& operator [](ll x){
        int c=hed[x%P];
        while(c){
            if(val[c]==x) return as[c];
            c=nxt[c];
        }
        ++cnt;val[cnt]=x;nxt[cnt]=hed[x%P];hed[x%P]=cnt;
        return as[cnt];
    }
    int size(){return cnt;}
}f;
ll get_f(ll tmp){
    if(f.count(tmp)) return f[tmp]%mod;
    if(tmp&1) return f[tmp]=((get_f(tmp/2+1)*get_f(tmp/2+1)%mod)+(get_f(tmp/2)*get_f(tmp/2)%mod))%mod;
    else return f[tmp]=get_f(tmp/2)*((get_f(tmp/2+1)+get_f(tmp/2-1))%mod)%mod;
}
int main(){
    n=read();
    c="";
    string t;
    t=getchar(),c=c+t,getchar();
    t=getchar(),c=c+t,getchar();
    t=getchar(),c=c+t,getchar();
    t=getchar(),c=c+t,getchar();
    if(n==2||c=="AAAA"||c=="AAAB"||c=="AABA"||c=="AABB"||c=="ABAB"||c=="ABBB"||c=="BBAB"||c=="BBBB"){
        print(1);
        return 0;
    }
    else if(c=="ABAA"||c=="BABA"||c=="BABB"||c=="BBAA"){
        print(ksm(2,n-3));
        return 0;
    }
    else if(c=="BAAA"||c=="ABBA"||c=="BBBA"||c=="BAAB"){
        f[1]=f[2]=1;
        print(get_f(n-1));
        return 0;
    }
    return 0;
}

/*
1000
B
A
A
A

589888339
*/


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

bool b[10000];

int main() {
    int n;
    cin >> n;
    vector<P> a(n);
    for (int i = 0;i < n;++i) cin >> a[i].first;
    for (int i = 0;i < n;++i) a[i].second = i;
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for (int i = 0;i < n;++i) b[i] = false;
    int ans = 0;
    for (int i = 0;i < n;++i) {
        int l = a[i].second,r = l;
        b[l] = true;
        while (l >= 0 && b[l]) l--;
        while (r < n && b[r]) r++;
        ans = max(ans,a[i].first*(r-l-1));
    }
    cout << ans << newl;
}

#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<random>
#include<algorithm>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<cstdio>
#include<cassert>
#include<sstream>
#include<set>

#define int long long int

using namespace std;

signed main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int ans = 0;
    for (int l = 0; l < n; ++l) {
        int minEl = 1e15;
        for (int r = l; r < n; ++r) {
            minEl = min(minEl, a[r]);
            ans = max(ans, (r - l + 1) * minEl);
        }
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
  long long N;
  cin >> N;
  vector<long long> L(N),R(N);
  for(int i=0;i<N;i++) cin >> L[i];
  for(int i=N-1;i>=0;i--) cin >> R[i];

  long long ans = 0;
  vector<long long> V1(N),V2(N);
  for(int i=0;i<N;i++){
    V1[i] = max(L[i],R[i]);
    V2[i] = min(L[i],R[i]);
    ans += V1[i];
  }

  priority_queue<long long> P;
  P.push(V2[0]);
  for(int i=1;i<N;i++){
    long long x = P.top();
    if(V1[i]<x){
      ans += x - V1[i];
      P.pop();
      P.push(V1[i]);
    }
    P.push(V2[i]);
  }

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

#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;

int main() {
	long long N; cin >> N;
	vector<long long> V(2 * N);
	for (int i = 0; i < 2 * N; i++) cin >> V[i];

	multiset<long long> Set;
	long long sum = 0;
	for (int i = 0; i < N; i++) {
		Set.insert(V[N - i - 1]);
		Set.insert(V[N + i]);
		long long a = *Set.begin();
		Set.erase(Set.begin());
		sum += a;
	}

	long long sum_ = 0;
	for (int i = 0; i < 2 * N; i++) sum_ += V[i];

	cout << sum_ - sum << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rev_rep(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int, int>
#define mod = 1e9 + 7

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

/* ************************************ CODE STATRTS HERE  *************************************/

void solve()
{
    int n;
    cin >> n;
    vi v(n);
    ll sum = 0;
    rep(i, 0, n - 1)
    {
    cin >> v[i];
    sum += max(0,v[i]-10);
    }
    cout<<sum<<endl;
}
int main()
{
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

int main() {
	ll N; cin >> N;
	bitset<200001> flag;
	ll Ans=0;
	REP(i,N){
		ll p; cin >> p;
		flag.set(p,1);
		while(flag.test(Ans)==true){
			Ans++;
		}
		cout << Ans << endl;
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int m, n;

int main() {
  cin >> m >> n;
  cout << (n % m ? "No" : "Yes");
  return 0;
}

#include <bits/stdc++.h>
#include <time.h>
#include <math.h>

using namespace std;

// English Motherfucker, Do you speak it?

#define fast                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define nl "\n"

#define l long
#define ll long long
#define dou double
#define ld long double
#define str string
#define vi vector<int>
#define vc vector<char>
#define vll vector<ll>
#define vd vector<dou>
#define vstr vector<str>
#define si stack<int>
#define sc stack<char>
#define sll stack<ll>
#define sd stack<dou>
#define sstr stack<str>
#define qi queue<int>
#define qc queue<char>
#define qll queue<ll>
#define qd queue<dou>
#define qstr queue<str>
#define sei set<int>
#define sec set<char>
#define sell set<ll>
#define sed set<dou>
#define sestr set<str>
#define msi multiset<int>
#define msc multiset<char>
#define msll multiset<ll>
#define msd multiset<dou>
#define msstr multiset<str>
#define mii map<int, int>
#define mcc map<char, char>
#define mllll map<ll, ll>
#define mdd map<dou, dou>
#define mstrstr map<str, str>
#define pii pair<int, int>
#define pcc pair<char, char>
#define pllll pair<ll, ll>
#define pdd pair<dou, dou>
#define pstrstr pair<str, str>

#define pub push_back
#define pob pop_back
#define mp make_pair
#define min3(a, b, c) min(min(a, b), c)
#define max3(a, b, c) max(max(a, b), c)

const ll MOD9 = 1000000007;
const dou pi = acos(-1.0);
const dou PI = 3.1415926535897932384626433832795;
const dou EX = 2.7182818284590452353602875;
const int INFI = 1e9;

ll maxs(set<ll> s)
{
	ll a;
	a=*(--s.end());
	/*for(auto i=s.begin();i!=s.end();++i)
	{
		if((*i)>a)
		{
			a=(*i);
		}
	}*/
	//cout<<a<<" ";
	return a;
}

ll mexs(set<ll> s)
{
	ll a;
	a=0;
	/*while(1)
	{
		if(s.find(a)!=s.end())
		{
			a++;
		}
		else
		{
			break;
		}
	}*/
	if(*(s.begin())!=0)
	{
		a=0;
	}
	else if(maxs(s)==(s.size()-1))
	{
		a=maxs(s)+1;
	}
	else
	{
		ll j=0;
		for(auto i=s.begin();i!=s.end();i++)
		{
			if(*(i)==j)
			{
				j++;
			}
			else
			{
				a=j;
				break;
			}
		}
	}
	return a;
}

void solve()
{
	int m,h;
	cin>>m>>h;
	if(h%m==0)
	{
		cout<<"Yes"<<nl;
	}
	else
	{
		cout<<"No"<<nl;
	}
}

int main()
{
	fast;
	ll t;
	//cin>>t;
	t=1;
	while (t--)
	{
		solve();
	}
	return 0;
}


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

vector<vector<int>> tile(50,vector<int>(50));
vector<vector<int>> pile(50,vector<int>(50));
vector<vector<char>> board(50,vector<char>(50,'-'));
string route;
long long score;

void print(vector<vector<int>> t){

    for (int i=0;i<50;i++){
        for (int j=0;j<50;j++){
            if(j==50-1)
                cout << t[i][j] << endl;
            else
                cout << t[i][j] ;

        }
    }

}

void write(int dx ,int dy){

    if(dx == -1 && dy == 0)
        route.push_back('U');
    else if(dx ==1 && dy == 0)
        route.push_back('D');
    else if(dx == 0 && dy == -1)
        route.push_back('L');
    else
        route.push_back('R');

}

void check_same_tile(int x,int y){

     for(int dx=-1;dx<=1;dx++){
        for(int dy=-1;dy<=1;dy++){
            if(dx!=dy && dx != -dy){
                if(0<=x+dx && x+dx <50  && 0 <= y+dy && y+dy < 50 && tile[x][y] == tile[x+dx][y+dy]){
                    board[x+dx][y+dy] ='*';
                }
            }
        }
    }

}

bool solve(int x,int y){

    score += pile[x][y];

    check_same_tile(x,y);

 //   print(tile);

    for(int dx=-1;dx<=1;dx++){
        for(int dy=-1;dy<=1;dy++){
            if(dx!=dy && dx != -dy){
                if(0<=x+dx && x+dx <50  && 0 <= y+dy && y+dy < 50 && tile[x][y]!=tile[x+dx][y+dy] && board[x+dx][y+dy] != '*'){
                    board[x+dx][y+dy] ='*';
                    write(dx,dy);
                    return solve(x+dx,y+dy);
                }
            }
        }
    }

    return false;
}

int main(){

    int si,sj;
    cin >> si >> sj;

    for (int i=0;i<50;i++){
        for (int j=0;j<50;j++){
            cin >> tile[i][j];
        }
    }

    for (int i=0;i<50;i++){
        for (int j=0;j<50;j++){
            cin >> pile[i][j];
        }
    }

    solve(si,sj);

    cout << route << endl;

}

#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;

template <typename T>
inline void read(T&x){
    x=0; char temp=getchar(); bool f=false;
    while(!isdigit(temp)){if(temp=='-') f=true; temp=getchar();}
    while(isdigit(temp)){x=(x<<1)+(x<<3)+temp-'0'; temp=getchar();}
    if(f) x=-x;
}
template <typename T>
void print(T x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}

typedef long long ll;
const int MAXN = 1e6+5;

//basic
int n;
ll k;

//DP
ll f[4][MAXN*3],prefix[4][MAXN*3];
//f[i][j]=\sigma k=1->n f[i-1][j-k];

int main(){
    read(n),read(k);
    f[0][0]=1; for(register int i=0;i<=n;i++) prefix[0][i]=1;
    for(register int i=1;i<=3;i++){
        for(register int j=i;j<=i*n;j++){
            int temp=j-min(n,j-i+1)-1;
            f[i][j]=prefix[i-1][j-1]-(temp>0? prefix[i-1][temp]:0);
        }
        for(register int j=1;j<=3*n;j++) prefix[i][j]=prefix[i][j-1]+f[i][j];
    }
    int sum=3;
    while(f[3][sum]<k) k-=f[3][sum],sum++;
    for(register int i=1;i<=n;i++){
        int l=max(sum-i-n,1),r=min(sum-i-1,n);
        if(l>r) continue;
        if(k>r-l+1){k-=r-l+1; continue;}
        print(i),putchar(' '),print(l+k-1),putchar(' '),print(sum-i-(l+k-1));
        break;
    }
    return 0;
}


#include<iostream>
#include<stdio.h>
#include<iomanip>
#include<vector>
#include<string>
#include<string.h>
#include<queue>
#include<math.h>
#include<utility>
#include<stack>
#include<unordered_map>
#include<map>
#include<set>
#include<unordered_set>
#include<algorithm>
#include<sstream>
#include<stdlib.h>
#include<bitset>
#define ff first
#define ss second
#define mod 1000000007LL
#define PI 3.14159265
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
void func(vector<pair<int,int>>&p,vector<pair<int,int>>&c,int k,vector<int>&s,int &mx) {
    if(k==p.size()) {
        int a=0;
        for(int i=0;i<c.size();i++) {
            if(s[c[i].ff]>=1&&s[c[i].ss]>=1)
                a++;
        }
        if(a>mx)
            mx=a;
    }
    else {
        s[p[k].ff]++;
        func(p,c,k+1,s,mx);
        s[p[k].ss]++;
        s[p[k].ff]--;
        func(p,c,k+1,s,mx);
        s[p[k].ss]--;
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>>c(m);
    for(int i=0;i<m;i++)
        cin>>c[i].ff>>c[i].ss;
    int k;
    cin>>k;
    vector<pair<int,int>>p(k);
    for(int i=0;i<k;i++)
        cin>>p[i].ff>>p[i].ss;
    vector<int>s(n+1,0);
    int mx=0;
    func(p,c,0,s,mx);
    cout<<mx;
}

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

int main() {
    int H, W, N, M;
    bool l[1600][1600], f[1600][1600], r[1600][1600];
    cin >> H >> W >> N >> M;
    for (int h = 0; h < H; ++h){
        for (int w = 0; w < W; ++w){
            l[h][w] = false;
            f[h][w] = false;
            r[h][w] = false;
        }
    }
    for (int i = 0; i < N; ++i){
        int a, b;
        cin >> a >> b;
        l[a-1][b-1] = true;
    }
    for (int i = 0; i < M; ++i){
        int c, d;
        cin >> c >> d;
        f[c-1][d-1] = true;
    }

    for (int h = 0; h < H; ++h){
        bool light = false;
        for (int w = 0; w < W; ++w){
            if (l[h][w]) {
                light = true;
            }else if(f[h][w]){
                light = false;
            }
            r[h][w] |= light;
        }
    }

    for (int h = 0; h < H; ++h){
        bool light = false;
        for (int w = W-1; w >= 0; --w){
            if (l[h][w]) {
                light = true;
            }else if(f[h][w]){
                light = false;
            }
            r[h][w] |= light;
        }
    }

    for (int w = 0; w < W; ++w){
        bool light = false;
        for (int h = 0; h < H; ++h){
            if (l[h][w]) {
                light = true;
            }else if(f[h][w]){
                light = false;
            }
            r[h][w] |= light;
        }
    }

    for (int w = 0; w < W; ++w){
        bool light = false;
        for (int h = H-1; h >= 0; --h){
            if (l[h][w]) {
                light = true;
            }else if(f[h][w]){
                light = false;
            }
            r[h][w] |= light;
        }
    }

    int res = 0;
    for (int h = 0; h < H; ++h){
        for (int w = 0; w < W; ++w){
            if (r[h][w]) res++;
        }
    }

    cout << res << endl;
    return 0;
}


/*
			Sunday 16 May 2021 05:35:27 PM IST
					@uthor::astrainL3gi0N
*/

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

typedef long long int ll;
typedef std::vector<int> vi;
typedef std::pair<int,int> ii;
typedef std::vector<ii> vii;
typedef std::vector<ll> vl;

#define pb push_back
#define mp make_pair
#define debg(x)	std::cerr<<(#x)<<" => "<<x<<'\n';
#define debgg(x,y)	std::cerr<<(#x)<<" => "<<x<<'\t'<<(#y)<<' '<<y<<'\n';
#define len(a) (int)(a).size()
#define all(x) x.begin(),x.end()

const int mod = 1000000007;
const int modd = 998244353;
const int esc = -1;
const string ys = "Yes\n";
const string no = "No\n";

bool comp (int x, int y) {
    return x > y;
}
void printarr (int arr[], int n) {
    for(int i = 0; i < n; ++i)
        cout<<arr[i]<<(i<n-1?' ':'\n');
}
template < typename T> void  printv (T &a) {
    for (auto it = a.begin(); it != a.end(); ++it)
        cout<<*it<<' ';
    cout<<'\n';
}
int gint() {
    int n;  cin>>n;
    return n;
}
//int t[510][510];
ll ans;

void solve () {
    map <int,int> freq;
    set <int> hsh;
    ans = 0;
    bool ok = false;
    ll n;   cin>>n;
    ll a,b,c;

    ll num = n;
    ll res = 1;
    int cnt = 0;
    ans = n;

    while (num > 0) {
        cnt++;
        res *= 2;
        a = n/res;
        b = cnt;
        c = n - res*a;
        ans = min(ans,a+b+c);

        num /= 2;
    }

    cout<<ans;
    cout<<'\n';
}
void sol () {
    //test
}

int main () {

    //cout << setprecision(15) << fixed;
    int testcases = 1;
    for (int t = 0; t < testcases; ++t) {
        //cout<<"Case #"<<t+1<<": ";
        solve();
    }

    return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    ll m = n;
    ll b2 = 1;
    ll ans = 1e18+1;
    for(int b = 0;b2<=n;b++){
        ll a = n/b2;
        ll c = n%b2;
        ans = min(ans,a+b+c);
        b2 *= 2;
    }
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e3+9;
const int MAX=1e2+9;
const double ep=1e-10;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double inf=1e20;
const double pi=acos(-1);
#define debug1 puts("?");
#define debug(x) cout<<"##"<<(x)<<endl;
#define mk make_pair
#define PII pair<int,int>
#define PDI pair<double,int>
#define PIII pair<int,PII >
#define PIII1 pair<PII,int>
#define PIIII pair<PII,PII >
#define PIL pair<int,ll>
#define PLI pair<ll,int>
#define PLIII pair<PLI,PII >
#define PLL pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define sd(x) scanf("%d",&(x))
#define slld(x) scanf("%lld",&(x))
#define sdd(x,y) scanf("%d%d",&(x),&(y))
#define sc(s) scanf("%s",(s))
#define pd(x) printf("%d\n",(x))
#define plld(x) printf("%lld\n",(x))
#define pdk(x) printf("%d ",(x))
#define plldk(x) printf("%lld ",(x))
#define pdd(x,y) printf("%d %d\n",(x),(y))
#define PR(x) printf("Case %d: ",(x))

/*

*/
ll dp[maxn][maxn],u[maxn],l[maxn],d[maxn];
int n,m;
char s[maxn][maxn];
void solve()
{
	sdd(n,m);
	rep(i,1,n)sc(s[i]+1);
	u[1]=l[1]=d[1]=dp[1][1]=1;
	rep(i,1,n)
	{
		rep(j,1,m)
		{
			if(i==1&&j==1)continue;
			int dd;
			if(j>=i)dd=j-i+1;
			else dd=i-j+1+m;
			if(s[i][j]=='#')
			{
				u[j]=l[i]=d[dd]=0;
				continue;
			}
			dp[i][j]=(l[i]+u[j]+d[dd])%mod;
			l[i]=(l[i]+dp[i][j])%mod;
			u[j]=(u[j]+dp[i][j])%mod;
			d[dd]=(d[dd]+dp[i][j])%mod;
//			cout<<i<<' '<<j<<' '<<l[i]<<' '<<u[j]<<' '<<d[dd]<<dp[i][j]<<endl;
		}
	}
	plld(dp[n][m]);
}
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int T=1;
//    sd(T);
    while(T--)solve();
}

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Pine1999
 */

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

template<int mod>
class Modular {
public:
    int x;
    Modular() : x(0) {}
    Modular(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    Modular &operator+=(const Modular& p) { if ((x += p.x) >= mod) x -= mod; return *this; }
    Modular &operator-=(const Modular& p) { if ((x -= p.x) < 0) x += mod; return *this; }
    Modular &operator*=(const Modular& p) { x = (int) (1LL * x * p.x % mod); return *this; }
    Modular &operator/=(const Modular& p) { *this *= p.Inverse(); return *this; }
    Modular operator-() const { return Modular(-x); }
    Modular operator+(const Modular& p) { return Modular(*this) += p; }
    Modular operator-(const Modular& p) { return Modular(*this) -= p; }
    Modular operator*(const Modular& p) { return Modular(*this) *= p; }
    Modular operator/(const Modular& p) { return Modular(*this) /= p; }
    bool operator==(const Modular& p) { return x == p.x; }
    bool operator!=(const Modular& p) { return x != p.x; }
    friend std::ostream& operator<<(std::ostream& out, const Modular& p) { return out << p.x; }
    friend std::istream& operator>>(std::istream& in, Modular& a) {
        long long t;
        in >> t;
        a = Modular<mod>(t);
        return in;
    }
    Modular Inverse() const {
        int a = x, m = mod, u = 1, v = 0, t;
        while (m > 0) {
            t = a / m;
            std::swap(a -= t * m, m);
            std::swap(u -= t * v, v);
        }
        return Modular(u);
    }
    Modular Pow(long long a, long long b) {
        assert(b >= 0);
        Modular r(1), mul(a);
        while (b > 0) {
            if (b & 1) r *= mul;
            mul *= mul;
            b >>= 1;
        }
        return r;
    }
};
// 入力時に mod を受け取る場合は, template<int& mod> にして,
// static int mod; cin >> mod; using mint = Modular<mod>; で良い.

const int mod = (int) 1e9 + 7;
using mint = Modular<mod>;

void solve(std::istream& in, std::ostream& out) {
    int h, w;
    in >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) in >> s[i];
    vector<vector<mint>> sum1(h, vector<mint> (w)), sum2(h, vector<mint> (w)), sum3(h, vector<mint> (w));
    vector<vector<mint>> dp(h, vector<mint> (w));
    sum1[0][0] = 1;
    sum2[0][0] = 1;
    sum3[0][0] = 1;
    dp[0][0] = 1;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '#') {
                sum1[i][j] = 0;
                sum2[i][j] = 0;
                sum3[i][j] = 0;
                dp[i][j] = 0;
            } else {
                if (i > 0) {
                    dp[i][j] += sum1[i - 1][j];
                }
                if (j > 0) {
                    dp[i][j] += sum2[i][j - 1];
                }
                if (i > 0 && j > 0) {
                    dp[i][j] += sum3[i - 1][j - 1];
                }
                sum1[i][j] = dp[i][j];
                sum2[i][j] = dp[i][j];
                sum3[i][j] = dp[i][j];
                if (i > 0) {
                    sum1[i][j] += sum1[i - 1][j];
                }
                if (j > 0) {
                    sum2[i][j] += sum2[i][j - 1];
                }
                if (i > 0 && j > 0) {
                    sum3[i][j] += sum3[i - 1][j - 1];
                }
            }
        }
    }
    out << dp[h - 1][w - 1] << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solve(in, out);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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 n;
vector<int> a;
int res = (1<<30);
void dfs(int id,int X,int Y){
    if(id==n){
        chmin(res,X^Y);
        return;
    }
    X|=a[id];
    dfs(id+1,0,X^Y);
    dfs(id+1,X,Y);
}
int main(){
    cin >> n;
    a.resize(n);
    rep(i,n) cin >> a[i];
    dfs(0,0,0);
    cout << res << endl;
    return 0;
}

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

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

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 998244353

bool isvowel(char c)
{
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        return true;
        return false;
}
ll isprime(ll n)
{
    ll ans=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return 0;
    }
    return 1;
}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%m;
    ll temp=power(a,b/2,m);
    if(b%2==0)
        return ((temp%m)*(temp%m))%m;
    else
        return ((((temp%m)*(temp%m))%m)*a%m)%m;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void ncrinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long ncr(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll c(ll n, ll k)
{
    ll i, j;
      ll C[n + 1][k + 1];
    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;

            else
                C[i][j] = (C[i - 1][j - 1]%MOD +
                          C[i - 1][j]%MOD)%MOD;
        }
    }
    return C[n][k]%MOD;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {

        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans = (ans%MOD * i%MOD)%MOD;
    }
    return ans;
}
/*-----------------------------------------------------------------------------*/
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    //freopen("1.txt","rt",stdin);
    //freopen("output.txt","wwt",stdout);

    ll t;
    t=1;
    //cin>>t;
    //ll t1=0;
    ll t1=0;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        for(ll i=0;i<n;i++)
         cin>>a[i];
        ll mn=INT_MAX;
        for(ll i=0;i< 1<<(n-1);i++)
        {
            ll or1 = 0;
            ll xor1 =0;
            for(ll j=0;j<=n;j++)
            {
               if(j<n)
                or1=or1|a[j];
               if(j==n||(i>>j)&1)
               {
                   xor1=xor1^or1;
                   or1=0;
               }
            }
            mn=min(mn,xor1);
        }
        cout<<mn<<endl;
    }
}


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

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

  ll s = 0, s2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> ai;
    s += ai;
    s2 += ai * ai;
  }

  cout << n * s2 - s * s << '\n';
}

// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

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

using ll =  long long;
void solve() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	int s = 0;
	vector<ll> as(N);
	ll ans = 0;
	for (size_t i = 0; i < N; i++)
	{
		s += A[i];
		as[i] = s;

		ans +=(ll) A[i] * A[i] * (N - 1);
	}
	for (size_t i = 0; i < N; i++)
	{
		ans -=(ll) 2 * A[i] *  (s-as[i]);
	}

	cout << ans << endl;

}

void solve2() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	ll ans = 0;
	//Aの-200から+200までの範囲を0から400までの配列のindexに変換
	const int MaxA = 200;
	vector<int> ac(MaxA * 2 + 1, 0);
	for (size_t i = 0; i < N; i++)
	{
		/* TLE
		for (size_t j = 0; j < i ; j++)
		{
			ans += (ull)((A[i] - A[j]) * (A[i] - A[j]));
		}
		*/
		for (int aj = MaxA * -1; aj <= MaxA; aj++)
		{
			int c = ac[MaxA + aj];
			int d = A[i] - aj;
			//ans += (ll)(d * d * c); //WA overflow
			ans += (ll)d * d * c;
		}
		ac[MaxA + A[i]]++;

	}
	cout << ans << endl;
}

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

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <math.h>
using namespace std;

#define int long long
const int  N = 200005;

int h, w, m, seg[4 * N];
vector<int> row[N], col[N];

void upd(int idx, int start, int end, int id) {
    if (start > end || end < id || start > id) {
        return;
    }
    else if (start == end) {
        seg[idx] = min(seg[idx] + 1, 1LL);
    }
    else {
        int mid = (start + end) / 2;
        upd(2 * idx + 1, start, mid, id);
        upd(2 * idx + 2, mid + 1, end, id);
        seg[idx] = seg[2 * idx + 1] + seg[2 * idx + 2];
    }
}

int get(int idx, int start, int end, int l, int r) {
    if (start > end || end < l || start > r) {
        return 0;
    }
    else if (start >= l && end <= r) {
        return seg[idx];
    }
    else {
        int mid = (start + end) / 2;
        int x = get(2 * idx + 1, start, mid, l, r);
        int y = get(2 * idx + 2, mid + 1, end, l, r);
        return x + y;
    }
}

int32_t main(int32_t argc, char const *argv[]) {
    cin >> h >> w >> m;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        row[x].push_back(y);
        col[y].push_back(x);
    }
    for (int i = 0; i < N; ++i) {
        sort(row[i].begin(), row[i].end());
        sort(col[i].begin(), col[i].end());
    }
    long long ans = 0;
    for (int i = 1; i <= h; ++i) {
        if (row[i].empty()) {
            ans += w;
        }
        else if (row[i][0] == 1) {
            break;
        }
        else {
            ans += row[i][0] - 1;
        }
    }
    for (int i = 1; i <= w; ++i) {
        if (col[i].empty()) {
            ans += h;
        }
        else if (col[i][0] == 1) {
            break;
        }
        else {
            ans += col[i][0] - 1;
        }
    }

    for (int i = 1; i <= h; ++i) {
        int f = 1;
        for (int &y: row[i]) {
            if (y == 1) {
                f = 0;
                break;
            }
            int sum = get(0, 1, N - 1, y, y);
            if (sum == 0) {
                upd(0, 1, N - 1, y);
            }
        }
        if (f == 0) {
            break;
        }
        int tot, r;
        if (row[i].empty()) {
            tot = r = w;
        }
        else {
            tot = r = row[i][0] - 1;
        }
        int mn, oc = 0;
        if (row[1].empty()) {
            mn = w + 1;
        }
        else {
            mn = row[1][0];
        }
        oc += max(0LL, r - mn);
        tot = tot - get(0, 1, N - 1, 1, min(mn, r)) - oc;
        ans -= tot;
    }
    cout << ans << '\n';
    return 0;
}

#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <functional>
#include <cmath>
using namespace std;
using pos = pair<size_t, size_t>;

template<typename T, typename F>
class SegTree {
	size_t size;
	T zero;
	F f;
	vector<T> elms;

	static size_t calcSize(size_t size) {
		size_t count = size_t(1) << int(ceil(log2(size)));
		while (count < size)
			count <<= 1;
		return count + (count - 1);
	}
	static size_t parent(size_t i) { return (i - 1) / 2; }
	static size_t leftChild(size_t i) { return i * 2 + 1; }
	static size_t rightChild(size_t i) { return i * 2 + 2; }
public:
	SegTree(size_t size_, T zero_, F f_) : size(size_), zero(zero_), f(f_), elms(calcSize(size_), zero_) {}
	void SetAt(size_t i, T val) {
		i = elms.size() / 2 + i;
		while (elms[i] != val) {
			elms[i] = val;
			if (i == 0)
				break;
			i = parent(i);
			val = f(elms[leftChild(i)], elms[rightChild(i)]);
		}
	}
	T GetRangeRight(size_t i) {
		size_t a = 0, b = elms.size() / 2 + 1;
		size_t pos = 0;
		T ret = zero;
		while (i != a) {
			size_t mid = (a + b) / 2;
			if (i < mid) {
				b = mid;
				ret = f(ret, elms[rightChild(pos)]);
				pos = leftChild(pos);
			}
			else {
				a = mid;
				pos = rightChild(pos);
			}
		}
		return f(ret, elms[pos]);
	}
};

template<typename T, typename F>
SegTree<T, F> makeSegTree(size_t size, T zero, F f) {
	return SegTree<T, F>(size, zero, f);
}

int main() {
	size_t h, w, m;
	cin >> h >> w >> m;
	size_t lh = h + 1, lw = w + 1;
	unordered_map<size_t, size_t> xs, ys;
	for (size_t i = 0; i < m; ++i) {
		size_t x, y;
		cin >> x >> y;
		if (x == 1) {
			lw = min(lw, y);
			continue;
		}
		if (y == 1) {
			lh = min(lh, x);
			continue;
		}
		if (x < lh) {
			if (!xs.emplace(x, y).second)
				xs[x] = min(xs[x], y);
		}
		if (y < lw) {
			if (!ys.emplace(y, x).second)
				ys[y] = min(ys[y], x);
		}
	}
	size_t sum = h * w - (h - lh + 2) * (w - lw + 2) + 1;
	vector<pos> xss, yss;
	xss.reserve(xs.size());
	for (auto [x, y] : xs) {
		if (x >= lh)
			continue;
		if (y >= lw)
			sum -= w - y + 1;
		else
			xss.emplace_back(x, y);
	}
	xs.clear();
	yss.reserve(ys.size());
	for (auto [y, x] : ys) {
		if (y >= lw)
			continue;
		if (x >= lh)
			sum -= h - x + 1;
		else
			yss.emplace_back(x, y);
	}
	ys.clear();
	sum -= (w - lw + 1) * xss.size();
	sum -= (h - lh + 1) * yss.size();
	sort(xss.begin(), xss.end());
	sort(yss.begin(), yss.end());
	auto tree = makeSegTree(w, size_t(), plus<size_t>());
	auto last = yss.begin();
	for (auto& e : xss) {
		for (; last != yss.end() && last->first <= e.first; ++last)
			tree.SetAt(last->second - 1, 1);
		sum -= tree.GetRangeRight(e.second - 1);
	}
	cout << sum << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define M 400005
char dr[M];
int a[M],pd[10],ls[M],fc[M],inv[M];
int C(int n,int m){
	if(m==0||m==n)return 1;
	if(ls[n]!=ls[n-m]+ls[m])return 0;
//	cout<<fc[n]<<" "<<inv[m]<<"!!"<<inv[n-m]<<endl;
	return 1ll*fc[n]%3*inv[m]%3*inv[n-m]%3;
}
int main(){
//	freopen("data.in","r",stdin);
//	freopen("pro.out","w",stdout);
	int n;pd[1]=1;pd[2]=2;
	scanf("%d",&n);
	scanf("%s",dr+1);
	for(int i=1;i<=n;++i){
		if(dr[i]=='R')a[i]=0;
		else if(dr[i]=='B')a[i]=1;
		else a[i]=2;
	}
	fc[0]=fc[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=n;++i){
		int t=i;
		while(t%3==0)ls[i]++,t/=3;
		fc[i]=1ll*t*fc[i-1]%3;
		inv[i]=1ll*pd[t%3]*inv[i-1]%3;
	}
	for(int i=1;i<=n;++i)ls[i]+=ls[i-1];
	int ans=0;
	int f=1;
	if((n-1)&1)f=-1;
	for(int i=1;i<=n;++i){
		ans=(ans+1ll*f*C(n-1,i-1)*a[i])%3;
	}ans=(ans%3+3)%3;
	if(ans==0)puts("R");
	else if(ans==1)puts("B");
	else puts("W");
}

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
template<class S, class T> inline S moddw_L(S a, const T b){
  a %= b;
  if(a < 0){
    a += b;
  }
  return a;
}
int N;
char S[400000+2];
int comb(int n, int k){
  int res;
  if(k < 0 || k > n){
    return 0;
  }
  if(n < 3){
    int i;
    res = 1;
    for(i=(0);i<(k);i++){
      res *= n-i;
    }
    for(i=(0);i<(k);i++){
      res /= i+1;
    }
    return res % 3;
  }
  return comb(n/3, k/3) * comb(n%3, k%3);
}
int main(){
  int i;
  int sm = 0;
  rd(N);
  rd(S);
  for(i=(0);i<(N);i++){
    if(S[i]=='B'){
      sm += comb(N-1,i);
    }
    if(S[i]=='R'){
      sm += comb(N-1,i) * 2;
    }
  }
  if(N%2==0){
    sm = -sm;
  }
  (sm = moddw_L(sm,3));
  if(sm==0){
    wt_L("W");
    wt_L('\n');
  }
  else if(sm==1){
    wt_L("B");
    wt_L('\n');
  }
  else{
    wt_L("R");
    wt_L('\n');
  }
  return 0;
}
// cLay version 20210405-1

// --- original code ---
// int N; char S[4d5+2];
//
// int comb(int n, int k){
//   int res;
//   if(k < 0 || k > n) return 0;
//   if(n < 3){
//     res = 1;
//     rep(i,k) res *= n-i;
//     rep(i,k) res /= i+1;
//     return res % 3;
//   }
//   return comb(n/3, k/3) * comb(n%3, k%3);
// }
//
// {
//   int sm = 0;
//   rd(N,S);
//   rep(i,N){
//     if(S[i]=='B') sm += comb(N-1,i);
//     if(S[i]=='R') sm += comb(N-1,i) * 2;
//   }
//   if(N%2==0) sm = -sm;
//   sm %%= 3;
//   wt(if[sm==0, "W", sm==1, "B", "R"]);
// }


#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <bitset>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <unordered_set>
#include <iterator>
// 20210422
// ABC 191以前のを解いていく
using namespace std;
using ll = long long;

void digi()
{
    int H, W;
    cin >> H >> W;
    vector<string> input_(H+1);
    vector<vector<string>> S(H+1, vector<string>(W+1, "."));
    vector<int> count_(H+1);

    for (int i=0 ; i < H; i++)
    {
        cin >> input_.at(i);
    }
    for (int i=0; i< H; i++)
    {
        for (int j=0; j<W; j++)
        {
            S.at(i).at(j) = input_.at(i).at(j);
        }
    }

    // 以下解説を読んで実装する
    // 周囲4マスに注目して頂点ならば自身が#.が3つであることと同値
    // 2マスならば地続きなので頂点ではないことを考える

    int tyouten = 0;
    for (int i = 0; i < H-1 ;i++)
    {
        for (int j = 0; j < W-1; j++)
        {
            int coun = 0;
            if (S.at(i).at(j)=="#")
            {
                coun += 1;
            }
            if (S.at(i+1).at(j)=="#")
            {
                coun += 1;
            }
            if (S.at(i).at(j+1)=="#")
            {
                coun += 1;
            }
            if (S.at(i+1).at(j+1)=="#")
            {
                coun += 1;
            }
            /*
                #.   .#    ..    ..
                ..   ..　  #.    .#   # ga 1ko

                .#   #.    ##    ##
                ##   ##　  .#    #.   # ga 3ko

            のとき中心の点が頂点であるという

            */
            if (coun ==1 || coun == 3)
            {
                tyouten += 1;
            }

        }
    }
    cout << tyouten <<endl;

}

int main()
{

    digi();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
//ll MOD = 1e9 + 7;
ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    ll n;
    cin >> n;
    ll a[n];
    fo(i, n){
        cin >> a[i];
    }
    ll s = 0;
    fo(i, n){
        ll x;
        cin >> x;
        s += x * a[i];
        //cout << s << nl;
    }
    if(s == 0){
        Yes;
    }
    else No;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include <iostream>
#include <string>
#include <vector>

// true : l winner, false : r winner
bool winnerRPS(char l, char r)
{
  return
    l == r ||
    l == 'R' && r == 'S' ||
    l == 'P' && r == 'R' ||
    l == 'S' && r == 'P';
}

int main()
{
  int n, k;
  std::cin >> n >> k;
  std::string s;
  std::cin >> s;

  for (int i = 0; i < k; i++)
  {
    std::string stmp = s;
    if (s.length() % 2 == 1) { stmp += s; }

    s.clear();
    for (int i = 0; i < stmp.size(); i+=2)
    {
      char winnerhand =
        winnerRPS(stmp[i], stmp[i + 1]) ? stmp[i] : stmp[i + 1];
      s.push_back(winnerhand);
    }
  }

  std::cout << s[0] << std::endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    string now,tmp;
    cin>>now;
    while(k--)
    {
        now=now+now;tmp.clear();
        for(int i=0;i<now.size();i+=2)
        {
            if(now[i]=='R'&&now[i+1]=='P')tmp.push_back('P');
            else if(now[i]=='P'&&now[i+1]=='R')tmp.push_back('P');
            else if(now[i]=='R'&&now[i+1]=='S')tmp.push_back('R');
            else if(now[i]=='S'&&now[i+1]=='R')tmp.push_back('R');
            else if(now[i]=='S'&&now[i+1]=='P')tmp.push_back('S');
            else if(now[i]=='P'&&now[i+1]=='S')tmp.push_back('S');
            else tmp.push_back(now[i]);
        }
        swap(tmp,now);
    }
    cout<<now[0];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ld PI = 4*atan((ld)1);
const ll mod = 998244353;
const ll inf = 922337203685477;
const ll nax = 5005;

ll fac[nax], iv[nax];

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

void init(){
	fac[0] = 1;
	for(ll i = 1; i < nax; i++){
		fac[i] = fac[i-1] * i % mod;
	}
	iv[nax-1] = pangkat(fac[nax-1], mod - 2);
	for(ll i = nax - 2; i >= 0; i--){
		iv[i] = iv[i+1] * (i + 1) % mod;
	}
}

ll c(ll x, ll y){
	return fac[x] * iv[y] % mod * iv[x-y] % mod;
}

ll n, m;
ll dp[15][nax];

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

    init();
    cin >> n >> m;
    dp[0][0] = 1;
    for(ll mask = 1; mask <= 13; mask++){
		ll bit = (1 << (mask - 1));
		for(ll i = 0; i <= m; i++){
			for(ll j = 0; j <= n && i + j * bit <= m; j += 2){
				dp[mask][i+j*bit] += dp[mask-1][i] * c(n, j);
				dp[mask][i+j*bit] %= mod;
			}
		}
	}
	cout << dp[13][m] << '\n';
}

#include<vector>
#include<iostream>
#include<fstream>
#include<string>
#include<cassert>
#include<algorithm>
#include<random>
#include<map>
#include<set>
#include <bitset>

using namespace std;

//int mod = 998244353;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<ll>> vvl;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ld, ld>> vpld;
typedef vector<pair<int, int>> vpi;
typedef pair<ld, ld> pld;
#define mp make_pair
#define pb push_back

int mod = 998244353;

int sum(int a, int b)
{
	int c = a + b;
	if (c >= mod)
	{
		c -= mod;
	}
	return c;
}

int dif(int a, int b)
{
	int c = a - b;
	if (c < 0)
	{
		c += mod;
	}
	return c;
}

int mlt(int a, int b)
{
	ll c = a * 1LL * b;
	return c % mod;
}

int ibit(int n, int i)
{
	return ((n >> i) & 1);
}

void outp1(vi &ou, string s)
{
	cout << s << endl;
	for (int i = 0; i < ou.size(); i++)
	{
		cout << ou[i] << ' ';
	}
	cout << endl;
}

void outp2(vvi &ou, string s)
{
	cout << s << endl;
	for (int i = 0; i < ou.size(); i++)
	{
		for (int j = 0; j < ou[i].size(); j++)
		{
			cout << ou[i][j] << ' ';
		}
		cout << '\n';
	}
}

int bp(int x, int y)
{
	if (y == 0)
	{
		return 1;
	}
	int a = 0;
	if (!(y % 2))
	{
		a = bp(x, y / 2);
	}
	return (y % 2) ? mlt(bp(x, y - 1), x) : mlt(a, a);
}

int obr(int x)
{
	return bp(x, mod - 2);
}

const int maxn = 312;
int fact[maxn], ofact[maxn];

void prec()
{
	fact[0] = 1;
	ofact[0] = 1;
	for (int i = 1; i < maxn; i++)
	{
		fact[i] = mlt(fact[i - 1], i);
	}
	//cerr << "sdsds" << endl;
	ofact[maxn - 1] = obr(fact[maxn - 1]);
	for (int i = maxn - 2; i > 0; i--)
	{
		ofact[i] = mlt(ofact[i + 1], i + 1);
	}
}

int c(int a, int b)
{
	return ((a <= b) && (a >= 0)) ? mlt(fact[b], mlt(ofact[a], ofact[b - a])) : 0;
}

void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n, k;
	cin>>n>>k;
	vector<int>pows(k+2);
	for(int i=0;i<n; i++)
	{
		int d;
		cin>>d;
		int val=1;
		for(int i=0; i<pows.size(); i++)
		{
			pows[i]=sum(val, pows[i]);
			val=mlt(val, d);
		}
	}
	//outp1(pows, " ");
	for(int i=1; i<=k; i++)
	{
		int td=0;
		for(int j=0; j<=i; j++)
		{
			int an=1;
			an=mlt(an, c(j, i));
			an=mlt(an, pows[i-j]);
			an=mlt(an, pows[j]);
			td=sum(td, an);
		}
		int bn=pows[i];
		bn=mlt(bn, bp(2,i));
		td=dif(td, bn);
		cout<<mlt(td, bp(2, mod-2))<<endl;
	}
}

int main()
{
	prec();
	solve();
	int n;
	cin >> n;
}