#include<bits/stdc++.h>
using namespace std;
#define en      '\n'
#define endl    '\n'
#define ll      long long signed
#define pb      push_back
#define append  push_back
#define all(v)  (v).begin(),(v).end()
#define FOR(i,a,b,k) for(int i=a; k>0?i<b:i>b; i+=k)
#define fori(a) for(int i=0; i<a; i++)
#define forj(a) for(int j=0; j<a; j++)
#define fork(a) for(int k=0; k<a; k++)
#define MOD     1000000007
#define MAX     1000010
#define mset(a,s,k) memset(a,k,s*sizeof(a[0]))
#define ff      first
#define ss      second
#define __      <<" "<<
#define _       <<en
#define int ll
ll pow_(ll a,ll e,ll m=MOD){ll r=1;while(e){if(e&1)r=r*a%m;a=a*a%m;e>>=1;}return r;}
int inv(ll a) {return (int)(pow_(a,MOD-2,MOD));}int add(ll a, ll b){return (a+b+MOD)%MOD;} int mul(ll a, ll b)
{return (MOD+a*b%MOD)%MOD;}int di(ll a, ll b){return mul(a,inv(b));}ll  ceil(ll a,ll b){return a/b+(a%b!=0);}
template<typename T1,typename T2>ostream&operator<<(ostream&O,pair<T1,T2>a){O<<"( ";O<<a.ff<<", "<<a.ss;O<<" )";return O;}
template<typename T>ostream&operator<<(ostream&O,vector<T>V){O<<"[ ";fori(V.size())O<<V[i]<<(i==V.size()-1?"":", ");O<<" ]";return O;}
template<typename T>ostream&operator<<(ostream&O,set<T>S){O<<"{ ";for(T i:S)O<<i<<", ";O<<" }";return O;}
template<typename T1,typename T2>ostream&operator<<(ostream&O,map<T1,T2>S){O<<"{ ";for(auto i:S)O<<i<<", ";O<<" }";return O;}
template<typename T=int>class print{public:vector<T>V;print(vector<T>v){V=v;cout<<" <"<<V<<"> ";}
print(T*x,int N){fori(N)V.push_back(x[i]);cout<<" <"<<V<<"> ";}friend ostream&operator<<(ostream&O,print p){return O;}};

#define vi vector<int>
#define tp pair<int,int>

int arr[MAX]; int N,M;
void reset();
vector<int> G[MAX];
int mi[MAX];

int dfs(int x){
    int &r=mi[x];
    if(r==INT_MIN){
        for(auto i: G[x]){
            r=max(r,dfs(i));
        }
    }
    return max(r,arr[x]);
}

int solve(){
    cin>>N>>M;
    reset();
    fori(N){ cin>>arr[i];}
    fori(M){
        int a,b;
        cin>>a>>b;
        G[a-1].push_back(b-1);
    }
    int res=INT_MIN;
    fori(N){
        dfs(i);// res=max(res, dfs(i,INT_MAX));
    }
    // cout<<print(mi,N) _;
    fori(N){
        if(mi[i]!=INT_MIN)
            res=max(res,mi[i]-arr[i]);
    }
    cout<<res;
    return 0;
}

void reset(){
    fori(N) {
        G[i].clear();
        mi[i]=INT_MIN;
    }

    // Clear Vectors, maps, sets
    // Set default values of arr
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    while(t--){
        solve();
        // cout<<solve()<<en;
        // cout<<(solve()?"Yes":"No")<<endl;
    }
    return 0;
}

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

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...);}

#define MOD		1000000007
#define INF     (ll)1e15
#define ll		long long int
#define pll		pair<ll, ll>
#define vll     vector<ll>
#define vpll    vector<pll>
#define pb		push_back
#define endl	'\n' // Remove if interactive
#define ff 		first
#define ss 		second
#define fastio 	ios_base::sync_with_stdio(false);cin.tie(NULL)
//#define all(v)  v.begin(), v.end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

ll power(ll x, ll y) { ll ans = 1; x %= MOD; while (y) {if (y & 1)ans = (x * ans) % MOD; x = (x * x) % MOD; y >>= 1;} return ans;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//#include <algorithm>
//#include <map>
//#include <queue>
//#include <cstring>

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

vll max_cost;
vll cost;
vector<vll> edges;

ll dfs(ll si) {
    if(max_cost[si] != -1)
        return max_cost[si];
    max_cost[si] = cost[si];
    for(ll ei : edges[si]) {
        max_cost[si] = max(max_cost[si], dfs(ei));
    }
    return max_cost[si];
}

void solve() {
    ll n, m;
    cin >> n >> m;
    max_cost.resize(n, -1);
    cost.resize(n);
    edges.resize(n);

    for(int i = 0; i < n; i++) {
        cin >> cost[i];
    }

    for(int i = 0; i < m; i++) {
        ll x, y;
        cin >> x >> y;
        --x,--y;
        edges[x].pb(y);
    }

    for(int i = 0; i < n; i++) {
        dfs(i);
    }

    ll ans = -INF;

    //debug(max_cost);

    for(int i = 0; i < n; i++) {
        for(ll ei : edges[i]) {
            ans = max(ans, max_cost[ei] - cost[i]);
        }
    }

    cout << ans << endl;
}

int main() {
    fastio;
    solve();
}

//4
//3
//100 200 300 450
//1 2
//2 3
//3 4

// 2 1 10 20 2 1


#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)
#define hmap gp_hash_table<ll, ll>

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

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
  FAST/**/

  ll n;
  cin>>n;

  ll tot = 0;
  ll cr = 1;
  while(tot < n)
  {
      tot += cr;
      if(tot >= n)
      {
          cout<<cr<<'\n';
          return 0;
      }
      cr++;
  }

  return 0;
}

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

char a[15],c[5]="ZONe";
int ans;

int main()
{
    scanf("%s",a+1);
    for(int i=1;i<=12;++i) {
        int flag=1;
        for(int j=0;j<4;++j) if(a[i+j]!=c[j]) flag=0;
        ans+=flag;
    }
    cout<<ans;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define INF LONG_MAX/3
//#define DIV 1000000007
//#define DIV 998244353

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//Aがindexの時に対応するB
ll A[210];
ll B[210];
set<ll> nums;

bool dp[205];

bool check(ll start, ll end) {
	ll l = end - start + 1;
	l/=2;

	for(ll i = start; i + l <= end; i++) {
		ll s = i;
		ll e = s + l;

		if(nums.count(s) && nums.count(e)) {
			if(A[s] == e && B[e] == s) continue;
			return false;

		} else if(nums.count(s)) {
			if(A[s] == 0) return false;

			if(A[s] == -1) continue;//ok

			if(A[s] != e) {
				return false;
			}

		} else if(nums.count(e)) {
			if(B[e] == 0) return false;

			if(B[e] == -1) continue;//ok

			if(B[e] != s) {
				return false;
			}
		} else {
			//-1, -1 ok

		}
	}
	return true;
}

int main(){
	ll N; cin >> N;
	rep(i, 210) A[i] = 0;
	rep(i, 210) B[i] = 0;

	rep(i, N) {
		ll a, b;
		cin >> a >> b;
		A[a] = b;
		B[b] = a;

		if(a != -1) {
			if(nums.count(a)) {
				cout << "No" << endl;
				return 0;
			}
			nums.insert(a);
		}

		if(b != -1) {
			if(nums.count(b)) {
				cout << "No" << endl;
				return 0;
			}
			nums.insert(b);
		}
	}

	dp[0] = true;

	for(ll i = 0; i <= 2*N; i++) {
		if(!dp[i]) continue;
		ll start = i + 1;
		for(ll end = start + 1; end <= 2*N; end += 2) {
			if(check(start, end)) {
				dp[end] = true;
			}
		}
	}
	if(dp[2*N]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#pragma GCC optimize("Ofast")
using namespace         std;
#define                 int long long
#define                 double long double
#define                 fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ArrayFill(arr,a)       memset(arr,a,sizeof arr)
#define                 endl '\n'
#define countBit(x)     __builtin_popcountll(x)
#define all(x)          x.begin() , x.end()
#define ln              cout<<'\n';
using namespace std;
using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> oset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

int ceil(int a,int b){return (a+b-1)/b;}
#define sim template < class c
#define ris return * this
#define dor > debug_ & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug_&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug_ {~debug_() { cerr << endl; }eni(!=) cerr << boolalpha << i; ris; }eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d){*this << "[";for (auto it = d.b; it != d.e; ++it)*this << ", " + 2 * (it == d.b) << *it;ris << "]";}};
#define db(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define debug(x) debug_() << db(x)
int modulo(int a,int b,int c){
    int x=1,y=a%c;
    while(b > 0){
        if(b%2 == 1)
            x=(x*y)%c;
        y = (y*y)%c;
        b = b>>1;
    }
    return  x%c;
}

// const int mod = 1e9 + 7ll;
const int mod = 998244353ll;
const int N = 505;
const int inf = 1e10;

string input[N];

void solve(){
    int n,m;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        cin >> input[i];
    }
    map<int,vector<char>>mp;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            mp[i+j].push_back(input[i][j]);
        }
    }
    int ans=1;
    for(auto &p:mp){
        int r{0},b{0},d{0};
        for(auto& i:p.second){
            if(i == 'R')r++;
            else if(i == 'B')b++;
            else d++;
        }
        if(r==0 && b==0){
            ans = (ans*2ll)%mod;
        }
        else if(r != 0 && b != 0){
            ans = 0;
        }
    }
    cout << ans;
}

signed main(){
    fast;
    int tt{1};
    // cin >> tt;
    for(int ii=1;ii<=tt;ii++){
        // cout << "Case #" << ii << ": ";
        solve();
        ln;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define MOD1 998244353
#define ceil(x, y) ((x)%(y))==0? ((x)/(y)) : ((x)/(y)+1)
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int 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 dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("in7.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int T=1;
    // cin >> T;
    FOR1(tt, T){
        // cout << "Case #" << tt << ": ";
        int N, C; cin >> N >> C;
        /*The only points where some changes happen are ai and bi + 1
        We need to do range update with compressed coordinates
        */
        set<int> st;
        int a[N+1], b[N+1], c[N+1];
        FOR1(i, N){
            cin >> a[i] >> b[i] >> c[i];
            st.insert(a[i]); st.insert(b[i] + 1);
        }

        // coordinate compression
        int idx = 0;
        map<int, int> m;
        for(int pt : st){
            m[pt] = idx;
            idx++;
        }

        // range update on the compressed array -- days
        /*But what does days[i] denote?
        Index i corresponds to some uncompressed point, p. i+1 corresponds to the next point
        to the right of p, say q.
        days[i] will denote the cost(w/o prime) to avail services in [p, q)
        */
        int compressed_size = idx;
        assert(m.size() == compressed_size);
        vector<int> days(compressed_size);
        for(int i = 1; i <= N; i++){
            days[m[a[i]]] += c[i];
            if(m[b[i] + 1] < compressed_size) days[m[b[i] + 1]] -= c[i];
        }

        // take prefix-sum and calculate ans
        for(int i = 1; i < compressed_size; i++){
            days[i] += days[i-1];
        }

        int ans = 0;
        /* create a vector from the set of points
        In the compressed days array, we only have the cost values
        but we need to know their duration too i.e decompression
        */
        vector<int> tmp(st.begin(), st.end());
        for(int i = 0; i + 1 < compressed_size; i++){
            int span = tmp[i+1] - tmp[i];
            ans += min(days[i], C) * span;
        }
        cout << ans;
        cout << '\n';
    }
    return 0;
}

//全力以赴
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;

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

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

ll extGcd(ll a, ll b, ll &x, ll &y) { // solves for x and y where ax+by=gcd(a,b)
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

ll modInv(ll a, ll p) { // solve for x=a^-1 where ax + py = 1 % p
    if(gcd(a, p) != 1) return -1; // modInv only exists if a and p are coprime (gcd(a, p) = 1)
    ll x, y;
    extGcd(a, p, x, y);
    x = (x % p + p) % p;
    return x;
}

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

/*
a^b:
if b is even -> a^b = a^(b/2) * a^(b/2)
if b is odd -> a^b  = a * a^(b-1/2) * a^(b-1/2)
*/
ll modPow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
    }
    return res;
}

int ask(int i, int j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    int v;
    cin >> v;
    return v;
}

int msbPos(int n) {
    if(n == 0) return 0;
    int msbPos = 0;
    n /= 2;
    while(n != 0) {
        n /= 2;
        msbPos++;
    }
    return msbPos;
}

void solve() {
    int n;
    ll C;
    cin >> n >> C;
    vector<pair<ll, ll>> events;
    for(int i=0;i<n;i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        events.push_back({a, +c});
        events.push_back({b + 1, -c});
    }
    sort(events.begin(), events.end());
    ll res = 0, now = 0, cost = 0;
    int m = events.size();
    for(int i=0;i<m;i++) {
        ll dt = events[i].first - now;
        ll dc = events[i].second;
        res += dt * min(C, cost);

        cost += dc;
        now += dt;
    }
    cout << res << endl;
}

int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) solve();
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define V vector
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define sz(x) int(x.size())
#define pcnt __builtin_popcountll
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template <typename T> void print(T a) {cout << a << ' ';}
template <typename T> void printe(T a) {cout << a << endl;}
template <typename T> void printv(T a) {rep(i, sz(a))print(a[i]); cout<<endl;}
template <typename T> void printp(pair<T, T> a) {print(a.first); cout<<a.second<<endl;}
template <typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
template <typename T> using vc = vector<T>;
template <typename T> using vv = vc<vc<T>>;
template <typename T> using vvv = vc<vv<T>>;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using vi = vc<int>;
using vvi = vv<int>;
using vl = vc<ll>;
using vvl = vv<ll>;
vi di = {-1, 1,  0, 0, -1, -1,  1, 1};
vi dj = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    int n; cin >> n;
    int m = 5;
    vvi a(n, vi(m)); rep(i, n) rep(j, m) cin >> a[i][j];
    vi MX(m, 0);
    rep(i, n) rep(j, m) chmax(MX[j], a[i][j]);
    int ans = 0;
    rep(i, n) {
        rep(j, i) {
            vi mx(m); // i,jさんの最大値
            rep(k, 5) mx[k] = max(a[i][k], a[j][k]);
            int mn = 2e9, im = -1;
            rep(k, 5) if (chmin(mn, mx[k])) im = k;
            mx[im] = MX[im];
            int res = 2e9;
            rep(k, 5) chmin(res, mx[k]);
            chmax(ans, res);
        }
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
#define speedup                                                       \
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr), \
		cout.precision(16)
using namespace std;
using ll = long long;
#define pb push_back
#define all(x) (x).begin(), (x).end()
using ld = long double;

void solve() {
	int n;
	cin>>n;
	vector<vector<ll>> ar(n,vector<ll>(5));
	for(auto& it:ar) {
		for(auto& iit:it) {
			cin>>iit;
		}
	}
	ll l=0,r=1e10;
	while(l<r) {
		ll md=(l+r)>>1;
		vector<int> cnt(32);
		for(auto& it:ar) {
			int msk=0;
			for(int i=0;i<5;++i) {
				if(it[i]>=md) {
					msk|=1<<i;
				}
			}
			++cnt[msk];
		}
		int ok=false;
		for(int i=0;i<32;++i) {
			for(int j=0;j<32;++j) {
				for(int k=0;k<32;++k) {
					int tmp=0;
					if(cnt[i]>0) tmp|=i;
					if(cnt[j]>0) tmp|=j;
					if(cnt[k]>0) tmp|=k;
					if(tmp==31) {
						ok=true;
						break;
					}
				}
			}
		}
		if(ok) l=md+1;
		else r=md;
	}
	cout<<r-1<<'\n';
}

int main() {
	speedup;
	//int t;
	//cin >> t;
	//while (t--)
		solve();
}


//================code===================//

//#define TLE

#ifdef TLE
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#endif

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <ctime>
#include <random>
#include <chrono>
//#include <stdint.h>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define ld long double
#define fa(i,a,b) for(LL i=(a);i<(LL)(b);++i)
#define fd(i,a,b) for(LL i=(a);i>(LL)(b);--i)
#define setp pair<int,ld>
#define setl pair<LL,LL>

#define micro 0.000000000001

using namespace std;

LL gcd(LL a, LL b)
{
	if (!(a && b)) return max(a, b);
	return a % b ? gcd(b, a % b) : b;
}

#ifdef OHSOLUTION
#define ce(t) cerr<<t
#define AT cerr << "\n=================ANS=================\n"
#define AE cerr << "\n=====================================\n"
#define DB(a) cerr << __LINE__ << ": " << #a << " = " << (a) << endl;
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#define LLL LL
#else
#define AT
#define AE
#define ce(t)
#define LLL __int128
#endif

pair <int, int> vu[9] = { {0,1},{1,0},{0,-1} ,{-1,0},{-1,0},{-1,-1}, {0,-1} , {1,-1},{-1,-1} }; //RDLU EWSN

template<typename T, typename U> void ckmax(T& a, U b) { a = a < b ? b : a; }
template<typename T, typename U> void ckmin(T& a, U b) { a = a > b ? b : a; }
struct gcmp { bool operator()(LL a, LL b) { return a < b; } bool operator()(setl& a, setl& b) { return a.second < b.second; } };
struct lcmp { bool operator()(LL a, LL b) { return a > b; } bool operator()(setl& a, setl& b) { return a.second > b.second; } };

const int max_v = 2e3+ 7;
const int max_k = 5e2 + 7;
const int bsz = (1ll << 10) + 7;
const int INF = 1e9 + 7;
const LL LNF = (LL)5e18 + 7ll;
LL mod =  998244353;//1e9 + 7;
template<typename T, typename U> void MOD(T& a, U b) { a += b; if (a >= mod) a -= mod; };

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

	int n; ci(n);
	vector<LL> vi(n);

	LL sum = 0;
	for (auto& x : vi) ci(x), sum+=x;

	vector<bool> dp(sum + 7, 0);

	dp[0] = 1;
	LL cmax = 0;

	for (auto& x : vi)
	{
		fd(i, cmax, -1) if(dp[i])
		{
			dp[i + x] = 1;
		}
		cmax += x;
	}

	LL ans = LNF;
	fa(i, 0, sum + 1) if(dp[i]) ckmin(ans, max(i, sum - i));
	co(ans);

	return 0;
}


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

const int INF=(1<<30);

struct graph{
    vvl edges;
    vvl cost;
    vl dist;
    graph(int n):edges(n), cost(n), dist(n, INF){}

    void add_edge(int from, int to, int c){
        edges[from].push_back(to);
        cost[from].push_back(c);
    }

    void dijkstra(int start){
        priority_queue<P,vector<P>,greater<P>> q;
        dist[start]=0;
        q.push(P(0,start));
        while (q.size()!=0)
        {
            P p=q.top();
            q.pop();
            int v=p.second;
            if(dist[v]<p.first)continue;
            for (int i = 0; i < edges[v].size(); i++){
                int to=edges[v][i];
                ll tmp_cost=dist[v]+cost[v][i];
                if(dist[to]>tmp_cost){
                    dist[to]=tmp_cost;
                    q.push(P(dist[to],to));
                }
            }
        }
    }
};
int R,C;
int id(int r, int c){return r*C + c;}
int main() {
    cin>>R>>C;
    int goal = id(R-1, C-1);
    vvl A(R, vl(C-1)), B(R-1, vl(C));
    for (int i = 0; i < R; i++)for (int j = 0; j < C-1; j++)cin>>A[i][j];
    for (int i = 0; i < R-1; i++)for (int j = 0; j < C; j++)cin>>B[i][j];

    graph g(R*C);
    for (int r = 0; r < R; r++){
        for (int c = 0; c < C; c++){
            if(c+1<C)g.add_edge(id(r,c), id(r,c+1), A[r][c]);
            if(c>0)g.add_edge(id(r,c), id(r,c-1), A[r][c-1]);
            if(r+1<R)g.add_edge(id(r,c), id(r+1,c), B[r][c]);
            for (int dr = 1; r-dr >= 0; dr++){
                g.add_edge(id(r,c), id(r-dr,c), dr+1);
            }
            // if(r>0)g.add_edge(id(r,c), id(r-1,c), 1);
        }
    }

    g.dijkstra(0);

    cout<<g.dist[goal]<<endl;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){

    int R, C; cin>>R>>C;
    vector<vec_int> A(R, vec_int(C-1));
    rep(i,R)rep(j,C-1)cin>>A.at(i).at(j);

    vector<vec_int> B(R-1, vec_int (C));
    rep(i,R-1)rep(j,C)cin>>B.at(i).at(j);

    vector<vec_int> visited(R, vec_int(C, 0));

    priority_queue<T2, vector<T2>, greater<T2>> pq;
    pq.emplace(0, 0, 0, 0);

    while(!pq.empty()){
        int cost, r, c, type; tie(cost, r, c, type)=pq.top(); pq.pop();
        if(visited.at(r).at(c)==1)continue;
        if(r==R-1&&c==C-1){
            cout<<cost<<endl;
            return 0;
        }
        visited.at(r).at(c) = 1;
        if(c<C-1){
            if(visited.at(r).at(c+1)==0){
                pq.emplace(cost+A.at(r).at(c), r, c+1, 1);
            }
        }
        if(c>0){
            if(visited.at(r).at(c-1)==0){
                pq.emplace(cost+A.at(r).at(c-1), r, c-1, 1);
            }
        }
        if(r<R-1){
            if(visited.at(r+1).at(c)==0){
                pq.emplace(cost+B.at(r).at(c), r+1, c, 0);
            }
        }
        if(type==1){
            for(int i=0;i<r;i++){
                if(visited.at(i).at(c)==0){
                    pq.emplace(cost+(r-i+1), i, c, 0);
                }
            }
        }
    }

    return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define sz(A) (int)A.size()
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> oset;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).

#define in input_int()
#define ins input_string()
bool sb(int a,int i){return (a&(1LL<<i))>0;}
int p2(int a){return (1LL<<a);}
int input_int(){int a;cin>>a;return a;}
string input_string(){string s;cin>>s;return s;}
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int ceil(int a,int b){return (a+b-1)/b;}
int ct,visited[N],ans;
vi adj[N];
int n,m,k,a,b,c,d,x,y,arr[N];
void clr()
{
    forn(i,0,n+10)adj[i].clear(),visited[i]=0,arr[i]=0;
}

string s;
void solve()
{
    cin>>n;
    int sum=0;
    forn(i,1,n)
    {
        cin>>arr[i];
        sum+=arr[i];
    }

    sort(alln(arr));

    int ans=0;

    forn(i,1,n)
    {
        sum-=arr[i];
        ans-=(n-i)*arr[i];
        ans+=sum;
    }
    cout<<ans;
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        //cout<<":Case #"<<i<<": ";
        solve();
        nl;
    }

    return 0;

}
//       clang++ c.cpp ; ./a.out < a.txt ;

#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";

using namespace std;

ll n;
string stroka;
ll ans=0;
int main(){
FLASH;
cin>>n;
cin>>stroka;
for(ll i=0;i<n;i++)
{
  ll a=0,t=0,c=0,g=0;
  for(ll j=i;j<n;j++)
  {
    if(stroka[j]=='A')a++;
    else if(stroka[j]=='G')g++;
    else if(stroka[j]=='C')c++;
    else t++;
    if(a==t && g==c)ans++;
  }
}
cout<<ans<<endl;

return 0;
}


#include<iostream>
#include<map>
#include<set>
#include<cstdio>
using namespace std;
const int BUF = 1500005;

int nVal, range;
int val[BUF];

void read() {
    scanf("%d%d", &nVal, &range);
    for (int i = 0; i < nVal; ++i) {
        scanf("%d", &val[i]);
    }
}

void add(int v, int v2cnt[BUF], set<int> &candi) {
    if (++v2cnt[v] == 1) {
        candi.erase(candi.find(v));
    }
}

void remove(int v, int v2cnt[BUF], set<int> &candi) {
    if (--v2cnt[v] == 0) {
        candi.insert(v);
    }
}

void work() {
    set<int> candi;
    for (int i = 0; i < BUF; ++i) {
        candi.insert(i);
    }

    static int v2cnt[BUF] = {};
    for (int i = 0; i < range; ++i) {
        add(val[i], v2cnt, candi);
    }

    int minV = *candi.begin();
    for (int i = range; i < nVal; ++i) {
        add(val[i], v2cnt, candi);
        remove(val[i - range], v2cnt, candi);
        minV = min(minV, *candi.begin());
    }

    cout << minV << endl;
}

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

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

using namespace std;
using namespace __gnu_pbds;

#define endl "\n"
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr);

const int N = 105;

set<int> st;

int main() {
    IOS;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        set<int> temp;
        for (int x : st) {
            temp.insert(x + a);
        }
        st.insert(a);
        for (int x : temp) {
            st.insert(x);
        }
    }
    int sum = *st.rbegin();
    int ans = 1e9;
    for (int x : st) {
        ans = min(ans, max(sum - x, x));
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long ll;

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

    set<ll> memo;
    for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            memo.insert(i);
            memo.insert(n/i);
        }
    }
    for(auto x : memo){
        cout<<x<<endl;
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
#define YN(e) ((e)?"Yes":"No")
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    ll N;
    cin >> N;
    ll m = sqrt(N) + 10;
    vector<ll> d, a;
    ll i=1;
    for (; i<m; ++i) {
        if (N % i == 0 && i*i <= N) {
            d.push_back(i);
        }
    }
    a = d;
    rep(i, (int)d.size()) {
        a.push_back(N / d[i]);
    }
    sort(begin(a), end(a));
    a.erase(unique(begin(a), end(a)), end(a));
    rep(i, (int)a.size())
        cout << a[i] << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define Please return
#define AC 0
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	cout << fixed << setprecision(10);
 double n; cin >> n;
 double ans = 0;
 rep(i,1,n+1){
	 ans += 1 / (n-i+1);
 }
 cout << n * ans - 1 << endl;

	Please AC;
}

#include <bits/stdc++.h>

using namespace std;
using ll =unsigned long long;
typedef pair<ll,ll> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
void mswap(ll &a, ll &b){ if(a >= b) swap(a,b); }
void rswap(ll &a, ll &b){ if(a <= b) swap(a,b); }

const int dy[] = {0,0,1,-1};
const int dx[] = {1,-1,0,0};
const ll mod = 1e9+7;
const ll MOD = 998244353;
const double PI=3.14159265358979323846;
const int inf = 1001001001;
const ll INF = 1e18;
//Write From this Line
int main()
{
	int n;
	cin >> n;
	double ans = 0;
	int tmp = n-1;
	rep(i,n-1){
		ans += double((double)n/(double)tmp);
		tmp--;
	}
	cout << setprecision(15);
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N, M;
  cin >> N >> M;

  if (M == 0){
    cout << 1 << endl;
    return 0;
  }
  if (N == M){
    cout << 0 << endl;
    return 0;
  }

  vector <ll> A(M);
  rep(i,M){
    cin >> A[i];
    A[i]--;
  }
  sort(all(A));

  vector <ll> sa;
  if (A[0] != 0){
    sa.push_back(A[0]);
  }
  rep(i,M-1){
    if (A[i+1] - A[i] >= 2){
      sa.push_back(A[i+1] - A[i] - 1);
    }
  }
  if(A[M-1] != N-1){
    sa.push_back(N-1 - A[M-1]);
  }
  ll hanko = *min_element(all(sa)); // 使うハンコの大きさ

  ll ans = 0;
  rep(i,sa.size()){
    ans += (hanko + sa[i] - 1) / hanko;
  }
  cout << ans << endl;
  //rep(i,sa.size()) cout << sa[i] << endl;
  return 0;
}

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

#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 mod(x) (x % MOD + MOD) % MOD
#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");
}

void solve(int tc) {
	int n, m;
	read(n, m);
	vector<int> arr(m);
	readContainer(arr);

	if (m == 0) {
		write(1);
		return;
	}

	sort(arr.begin(), arr.end());
	vector<int> stamps;

	if (arr[0] > 1) {
		stamps.push_back(arr[0] - 1);
	}

	for (int i = 1; i < m; i++) {
		if (arr[i] - arr[i - 1] - 1 > 0) {
			stamps.push_back(arr[i] - arr[i - 1] - 1);
		}
	}

	if (arr[m - 1] < n) {
		stamps.push_back(n - arr[m - 1]);
	}

	if (stamps.size() == 0) {
		write(0);
		return;
	}

	sort(stamps.begin(), stamps.end());
	int ans = 0, w = stamps[0];

	for (int i = 0; i < stamps.size(); i++) {
		if (stamps[i] % w == 0) {
			ans += stamps[i] / w;

		} else {
			ans += ((stamps[i] / w) + 1);
		}
	}

	write(ans);
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	int tc = 1;
	// read(tc);

	for (int curr = 1; curr <= tc; curr++) solve(curr);

	return 0;
}


//
#include "bits/stdc++.h"
using namespace std;
#define pr1(a) for(auto b : a) cout << b << " ";cout << endl;
#define pr2(a) for(auto b : a){for(auto c:b) cout << c << " ";cout << endl;}
#define prc(...) for(auto b:{ __VA_ARGS__ }) cout << b << " ";cout << endl;

const int NN=200000;
vector<vector<int>> g(NN+1,vector<int>());
vector<bool> visited(NN+1,false);
long long ans=0;

void dfs(int p){
    for(auto e:g[p]){
        if (visited[e]==false){
            ans++;
            visited[e]=true;
            dfs(e);
        }
    }
}

void solve()
{
    fill(g.begin(),g.end(),vector<int>());
    fill(visited.begin(),visited.end(),false);
    ans=0;
    int a,b,n,val;
    cin >> n ;
    vector<int> d(n);
    for(int &i:d) cin>>i;
    for(int i=0;i<n/2;i++){
        int v1=d[i], v2=d[n-i-1];
        if (v1!=v2){
            g[v1].push_back(v2);
            g[v2].push_back(v1);
        }
    }
    for(int i=0;i<=NN;i++){
        if (visited[i]==false)
            visited[i]=true;
            dfs(i);
    }

    cout<<ans<<endl;
}

int main()
{
    ios_base::sync_with_stdio(0);    cin.tie(0);    cout.tie(0);
#ifndef ONLINE_JUDGE
    stringstream in(R"(3
8
1 5 3 2 5 2 3 1
7
1 2 3 4 1 2 3
1
200000
)"); //ans 2 1 0
    std::cin.rdbuf(in.rdbuf());
#endif
    int tn = 1;
    //cin >> tn;
    while (tn--)
        solve();
}

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

ll max(ll a,ll b){
    if(a>b){
        return a;
    }
    return b;
}

ll min(ll a,ll b){
    if(a<b){
        return a;
    }
    return b;
}

void solve(){
    string s;
    cin >> s;
    ll n = s.size();
    map<char,ll> mp;
    ll ans=0;
    mp[s[n-1]]++;
    for(int i=n-2;i>=1;i--){
        if(s[i]==s[i-1]&&s[i-1]!=s[i+1]){
            ans+=(n-i-mp[s[i]]-1);
            mp.clear();
            mp[s[i]]=(n-i);
        }
        else{
            mp[s[i]]++;
        }
    }
    cout << ans;
}

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


#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i ++ )
#define N 100010

struct Node
{
  string s;
  int x;
  bool operator< (const Node &W) const{
    return x > W.x;
  }
}a[N];

int main(void)
{
  int n; cin >> n;
  rep(i, n) cin >> a[i].s >> a[i].x;
  sort(a, a + n);
  cout << a[1].s << endl;
  return 0;
}

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

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

#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, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int n;
    cin >> n;

    vector<pair<int, string>> ts(n);
    REP(i, n) {
        string tmp_s;
        int tmp_i;

        cin >> tmp_s >> tmp_i;
        ts[i] = make_pair(tmp_i, tmp_s);
    }

    sort(ALL(ts), greater<>());

    cout << ts[1].second << endl;

    return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
    #include "../../Library/DebugTool.cpp"
#endif
using namespace std;
#define ll long long
#define pii pair<int,int>
//const ll MOD = 1000000007;
const ll MOD = 998244353;
ll INF_int = 1e9+11;ll INF_ll = 1e18 + 13;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define per(i,n) for(int i = n-1;i>=0;i--)
#define mp make_pair
#define All(a) a.begin(),a.end()

void in(){}
template<typename Head,typename ...Tail>void in(Head&& head,Tail&& ...tail){cin >> head;in(std::forward<Tail>(tail)...);}
template<typename T>void vecin(vector<T> &vec){int n = vec.size();rep(i,n) cin >> vec[i];}
void out(){cout << "\n";}
template<typename Head,typename ...Tail>void out(Head&& head,Tail&& ...tail){cout << head << " ";out(std::forward<Tail>(tail)...);}
template<typename T>void vecout(vector<T> a){for(auto x:a)cout << x << " ";cout << endl;}
template<typename T>bool umax(T &x,const T &y){if(x<y){x=y;return true;}return false;}
template<typename T>bool umin(T &x,const T &y){if(x>y){x=y;return true;}return false;}

int main(){
    ll n,m;in(n,m);
    ll t = 1;
    ll tmp = 10;
    while(n>0){
        if(n%2==1){
            t*=tmp;t%=(m*m);
        }
        tmp*=tmp;tmp%=(m*m);
        n/=2;
    }
    out(t/m);
}

#include<bits/stdc++.h>
using namespace std;
#define lli               long long int
#define ulli              unsigned long long int
#define vi                vector<int>
#define ii                pair<int,int>
#define all(v)            v.begin(),v.end()
#define getunique(v)      {v.erase(unique(v.begin(),v.end()),v.end());}
#define pb                push_back
#define ff                first
#define ss                second
#define endl              "\n"
#define fast_io           ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MS=1000001;
const lli INF=1e9+7;

template<typename T>
 bool comp(T a, T b){
  if(a<b)
    return true;
  return false;
 }
 //vector<int> t;
 int n;
 void print(vi v){
  cout<<v.size()<<" ";
  for(int i=0; i<v.size(); i++){
   cout<<v[i]+1<<" ";
  }
  cout<<endl;
 }
int main(){
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
   fast_io;
   cin>>n;
   vector<lli> v(n);
   for(int i=0; i<n; i++)
    cin>>v[i];
  n=min(n,8);
  int mask=(1<<n);
  vector<vector<int> > t(200,vi(0));
  for(int i=0; i<mask; i++){
    lli sum=0;
    vi mine;
    for(int j=0; j<n; j++){
      int her=(1<<j);
      if(her&i)
        sum=(sum+v[j])%200,mine.pb(j);
    }
    if(t[sum].size()>0){
      cout<<"yes"<<endl;
      print(t[sum]);
      print(mine);
      return 0;
    }
    t[sum]=mine;

  }
 cout<<"no";

}


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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  cout << n - a + b << endl;
}


#include <bits/stdc++.h>
#define ll long long int
#define db double
#define pb push_back
#define mpr make_pair
#define andl "\n"
#define f first
#define s second
#define mset(x,y) memset(x,y,sizeof(x))
#define fr(i,n) for(long long int i=0;i<n;i++)
#define trace(it,x) for(auto it = (x).begin(); it != (x).end(); it++)
#define mod 1000000007
#define fastio ios::sync_with_stdio (false); cin.tie (0); cout.tie (0);
#define runtime cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
using namespace std;

// convert number to string to_string(x);
// convert string to number stoi();

// ll mulmod(ll x,ll y)
// {
//     return ((x%mod)*(y%mod))%mod;
// }

// ll binpow(ll x, ll y)
// {
//     ll z = 1;
//     while(y > 0)
//     {
//         if(y % 2 == 1)
//             z = mulmod(z, x);
//         x = mulmod(x, x);
//         y /= 2;
//     }
//     return z;
// }

// ll ncr(ll n,ll r)
// {
//     return mulmod(fact[n],binpow(mulmod(fact[n-r],fact[r]),mod-2));
// }

// ll pwr(ll n,ll m)
// {
//   if(n==1 || m==0)
//     return 1;

//   ll x=pwr(n,m/2);
//   if(m%2==0)
//     return x*x;
//   else
//     return n*x*x;
// }

// ll pwr(ll n,ll m,ll b)
// {
//   if(n==1 || m==0)
//     return 1;

//   ll x=pwr(n,m/2,b);
//   if(m%2==0)
//     return ((x%b)*(x%b))%b;
//   else
//     return ((n%b)*(((x%b)*(x%b))%b))%b;
// }
vector<pair<ll,ll>>cd,ball;

ll ans(vector<ll>v,ll i,ll k)
{
	if(i==k)
	{
		ll anss=0;
		ll ab[101]={0};
		fr(i,v.size())
		ab[v[i]]=1;

		fr(i,cd.size())
		if(ab[cd[i].f]+ab[cd[i].s]==2)
			anss++;
		return anss;
	}

	ll x,y;
	v.pb(ball[i].f);
	x=ans(v,i+1,k);
	v.pop_back();
	v.pb(ball[i].s);
	y=ans(v,i+1,k);
	return max(x,y);
}

void solve()
{
	ll n,m,x,y;
	cin >> n >> m;

	fr(i,m)
	{
		cin >> x >> y;
		cd.pb({x,y});
	}
	ll k;
	cin >> k;
	vector<ll>v;
	fr(i,k)
	{
		cin >> x >> y;
		ball.pb({x,y});
	}
	ll i=0;
	cout << ans(v,i,k);
  return ;
}

int main()
{
  fastio

  ll t=1;
  // cin >> t;

  while(t--)
    solve();

  runtime
}

#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<list>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define vvll vec<vll>
#define vbo vec<bool>
#define vvbo vec<vbo>
#define vin(a) rep(i,0,a.size())cin>>a[i];
#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,b,a) for(ll i=(b);i>=(a);i--)
#define repset(itr,a) for(auto itr=a.begin();itr!=a.end();itr++)
#define repnck(bit,n,k) for(ll bit=(1ll<<(k))-1;bit<(1ll<<(n));bit=(bit==0?(1ll<<(n)):nec(bit)))
#define bi1(bit,i) ((bit)&1ll<<(i)?true:false)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define kai "\n"
#define prque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define bis binary_search
#define nep next_permutation
#define MOD 1000000007ll
#define MAX 2147483647ll
#define MIN 0.0000000001l
#define equal(a,b) (abs((a)-(b))<MIN)
using namespace std;
void solve();
struct ll2{ll x,y;bool operator<(const ll2 &l)const{return x!=l.x?x<l.x:y<l.y;};};
struct ll3{ll x,y,z;bool operator<(const ll3 &l)const{if(x!=l.x)return x<l.x;if(y!=l.y)return y<l.y;return z<l.z;};};

class ufset{
public:
	ufset(ll n) {rank.resize(n,0);rep(i,0,n)p.pub(i);}
	bool same(ll i,ll j){return find(i)==find(j);}
	void unite(ll i,ll j){link(find(i),find(j));}
	ll find(ll i){if(i!=p[i])p[i]=find(p[i]);return p[i];}
private:
  vll p,rank;
	void link(ll i,ll j){if(rank[i]>rank[j])p[j]=i;else{p[i]=j;if(rank[i]==rank[j])rank[j]++;}}
};

class nck{
public:
	nck(ll maxn,ll mod=MOD){
		NUM=maxn+1;p=mod;
		fac.resize(NUM);finv.resize(NUM);inv.resize(NUM);
		fac[0]=fac[1]=finv[0]=finv[1]=inv[1]=1;
		rep(i,2,NUM){fac[i]=fac[i-1]*i%p;inv[i]=p-inv[p%i]*(p/i)%p;finv[i]=finv[i-1]*inv[i]%p;}
	}
	ll c(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%p)%p;}
private:
  ll NUM,p;
	vll fac,finv,inv;
};

ll gcd(vector<ll> a){rep(i,1,a.size()){ll k=a[i-1]%a[i];while(k!=0){a[i-1]=a[i];a[i]=k;k=a[i-1]%a[i];}}return a.back();}
ll lcm(vector<ll> a){ll n;rep(i,1,a.size()){n=a[i-1]*a[i];ll k=a[i-1]%a[i];while(k!=0){a[i-1]=a[i];a[i]=k;k=a[i-1]%a[i];}n/=a[i];a[i]=n;}return n;}
ll pow2(ll a,ll b,ll p=MOD){if(b==-1)return pow2(a,p-2,p);ll res=1;if(b>0){res=pow2(a,b/2,p);if(b%2==0)res=res*res%p;else res=res*res%p*a%p;}return res;}
ll nec(ll bit){ll x=bit&-bit,y=bit+x;return (((bit&~y)/x)>>1)|y;}
ll bisz(ll bit){ll size=0;while(bit>0){bit/=2;size++;}return size;}
ll ransu(){static unsigned int TX=123456789, TY=362436069, TZ=521288629, TW=88675123;unsigned int tt=(TX^(TX<<11));TX=TY;TY=TZ;TZ=TW;return (TW=(TW^(TW>>19))^(tt^(tt>>8)));}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
ll n;
ll f(ll r,ll l){
	ll m=(l+r+1)/2;
	if(r==l)return r;
	if(m<=MAX&&2*n+2>=(1+m)*m)return f(m,l);
	else return f(r,m-1);
}
void solve(){
	cin>>n;
	ll k=f(1,n);
	cout<<n-k+1<<kai;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
template <typename T1, typename T2> bool mini(T1 &a, T2 b) {
	if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maxi(T1 &a, T2 b) {
	if (a < b) {a = b; return true;} return false;
}
const int N = 1e5 + 5;
const int oo = 1e9;
const int mod = 1e9 + 7;

void add(int &a, int b) {
	a += b;
	if (a >= mod)
		a -= mod;
}

struct mat {
	int n;
	vector <vector <int>> f;

	mat(int _n) {
		n = _n;
		f.assign(n, vector <int> (n, 0));
	}

	mat operator * (const mat &m) {
		mat res(n);
		for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
		for (int k = 0; k < n; k++)
			add(res.f[i][k], (long long) f[i][j] * m.f[j][k] % mod);
		return res;
	}

	mat one() {
		mat res(n);
		for (int i = 0; i < n; i++)
			res.f[i][i] = 1;
		return res;
	}

	mat binpow(int k) {
		mat n = (*this);
		mat res = one();
		for (; k; k >>= 1, n = n * n)
			if (k & 1)
				res = res * n;
		return res;
	}

	void print() {
		for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cerr << f[i][j] << " \n"[j == n];
	}
};

int deg[N];
int n,m,k;

int binpow(int x, int k) {
	int res = 1;
	for (; k; k >>= 1, x = (long long) x * x % mod)
		if (k & 1)
			res = (long long) res * x % mod;
	return res;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> k;
	mat base(n);
	for (int i = 0; i < n; i++)
		cin >> base.f[0][i];

	mat mul(n);
	int dv = binpow(2 * m, mod - 2);
	for (int i = 1; i <= m; i++) {
		int u,v;
		cin >> u >> v;
		u--;
		v--;
		deg[u]++;
		deg[v]++;
		mul.f[u][v] = mul.f[v][u] = dv;
	}

	for (int i = 0; i < n; i++) {
		mul.f[i][i] = (1 - (long long) deg[i] * dv) % mod;
		add(mul.f[i][i], mod);
	}

	base = base * mul.binpow(k);
	for (int i = 0; i < n; i++)
		cout << base.f[0][i] << "\n";
	return 0;
}

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

#define rep( i, a, b ) for( int i = (a) ; i <= (b) ; i ++ )
#define per( i, a, b ) for( int i = (a) ; i >= (b) ; i -- )

typedef long long LL;

const int mod = 998244353;
const int MAXN = 105, MAXS = 1e4 + 5;

template<typename _T>
void read( _T &x )
{
    x = 0; char s = getchar(); int f = 1;
    while( s < '0' || '9' < s ) { f = 1; if( s == '-' ) f = -1; s = getchar(); }
    while( '0' <= s && s <= '9' ) { x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar(); }
    x *= f;
}

template<typename _T>
void write( _T x )
{
    if( x < 0 ) putchar( '-' ), x = -x;
    if( 9 < x ) write( x / 10 );
    putchar( x % 10 + '0' );
}

template<typename _T>
inline _T MAX( const _T a, const _T b )
{
	return a > b ? a : b;
}

template<typename _T>
inline _T MIN( const _T a, const _T b )
{
	return a < b ? a : b;
}

template<typename _T>
inline _T ABS( const _T a )
{
	return a < 0 ? -a : a;
}

int dp[2][MAXN][MAXS << 1];

int fac[MAXN];
int W[MAXN];
int N;

inline int Mul( int x, int v ) { return 1ll * x * v % mod; }
inline int Sub( int x, int v ) { return ( x -= v ) < 0 ? x + mod : x; }
inline int Add( int x, int v ) { return ( x += v ) >= mod ? x - mod : x; }
inline void Upt( int &x, const int v ) { x = Add( x, v ); }

int main()
{
	read( N ); int su = 0;
	rep( i, 1, N ) read( W[i] ), su += W[i];
	fac[0] = 1; rep( i, 1, N ) fac[i] = Mul( fac[i - 1], i );
	int pre = 1, nxt = 0;
	dp[nxt][0][su] = 1;
	rep( i, 0, N - 1 )
	{
		pre ^= 1, nxt ^= 1;
		rep( j, 0, N ) rep( k, 0, su << 1 ) dp[nxt][j][k] = 0;
		rep( j, 0, i ) rep( k, 0, su << 1 ) if( dp[pre][j][k] )
		{
			Upt( dp[nxt][j][k - W[i + 1]], dp[pre][j][k] );
			Upt( dp[nxt][j + 1][k + W[i + 1]], dp[pre][j][k] );
		}
	}
	int ans = 0;
	rep( i, 1, N )
		ans = Add( ans, Mul( dp[nxt][i][su], Mul( fac[i], fac[N - i] ) ) );
	write( ans ), putchar( '\n' );
	return 0;
}


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

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

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define imn (ll)-1e16
#define imx (ll)1e16

ld pi=3.14159265358979323846;

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...) 20
#endif

ll mod=1e9+7;
ll power(ll a,ll b,ll m)
{
    a%=m;
    if(b==1)
    return a;
    if(b==0)
    return 1LL;
    ll ret=power(a,b/2,m);
    ret=(ret*ret)%m;
    if(b&1)
    ret=(ret*a)%m;
    return ret;
}

ll power(ll a,ll b)
{
    if(b==1)
    return a;
    if(b==0)
    return 1LL;
    ll ret=power(a,b/2);
    ret=(ret*ret);
    if(b&1)
    ret=(ret*a);
    return ret;
}

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

struct DSU
{
    ll connected;
    vector<ll> par, sz;

    void init(ll n)
    {
        par = sz = vector<ll> (n + 1, 0);
        for(ll i = 1; i <= n; i++)
            par[i] = i, sz[i] = 1;
        connected = n;
    }

    ll getPar(ll u)
    {
        while(u != par[u])
        {
            par[u] = par[par[u]];
            u = par[u];
        }
        return u;
    }

    ll getSize(ll u)
    {
        return sz[getPar(u)];
    }

    void unite(ll u, ll v)
    {
        ll par1 = getPar(u), par2 = getPar(v);

        if(par1 == par2)
            return;

        connected--;

        if(sz[par1] > sz[par2])
            swap(par1, par2);

        sz[par2] += sz[par1];
        sz[par1] = 0;
        par[par1] = par[par2];
    }
};

void answer_nikaal()
{
    ll n,i;
    cin>>n;
    ll a[n+1];
    for(i=1;i<=n;i++){
        cin>>a[i];
    }
    DSU d;
    d.init(200005);
    for(i=1;i<=n/2;i++){
        if(a[i]!=a[n-i+1]){
            d.unite(a[i],a[n-i+1]);
        }
    }
    ll ans=0;
    for(i=1;i<200005;i++){
        ans+=max(0LL,d.sz[i]-1);
    }
    cout<<ans<<endl;
}

int main()
{
    make_it_fast;
    int TEST_CASES=1;
    // cin>>TEST_CASES;
    while(TEST_CASES--)
    {
        answer_nikaal();
    }
    return 0;
}

#include <bits/stdc++.h>
#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <int, ll> pil;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=2e5+100;
const int N=1e6+100;
const int M=(1<<20)+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    int T;cin>>T;
    while(T--)
    {
        map<int,int>mp;
        int n;cin>>n;
        rep1(i,n)
        {
            int x;cin>>x;mp[x]++;
        }
        if(n&1) cout<<"Second\n";
        else{
            int flag=0;
            for(pii v:mp) if(v.Y&1) flag=1;
            if(flag) cout<<"First\n";
            else cout<<"Second\n";
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define T third
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<pair<int,int>> vp;
typedef vector<long long> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvll;
const int C=1e9+7;
void yes(){
    cout<<"YES\n";
}
void no(){
    cout<<"NO\n";
}
ll binpow(ll a, ll b, ll m=C) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
//Variables********************************************

//Functions********************************************

//*****************************************************
void solve(){
	        string s; cin>>s;
    int co{},cx{},cq{};
    for(int i=0;i<10;i++){
        if(s[i]=='o') co++;
        else if(s[i]=='x') cx++;
        else if(s[i]=='?') cq++;
    }
    if(co+cq==0||co>4){
        cout<<0<<endl;
        return;
    }
    int f=co+cq;
    int T=f*f*f*f;
    int x{};
    int prevf=1;
    int p=1;
    for(int i=1;i<=co;i++){
    	x+=p*(prevf*(co-i+1)/i)*(f-i)*(f-i)*(f-i)*(f-i);
    	prevf=prevf*(co-i+1)/i;
    	p*=-1;
    }
    cout<< T-x<<endl;

}

signed main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t=1;// cin>>t;
    int x{};
    while(t--){
    	//cout<<"Case #"<<x<<": "; x++;
        solve();
    }
}

#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define efo(i,q) for(int i=0;i<(int)B[q].size();++i)
using namespace std;
typedef long long LL;
const int N=200500,mo=998244353;
int read(int &n)
{
	bool q=0;n=0;char ch=' ';
	for(;ch!='-'&&(ch<'0'||ch>'9');ch=getchar());
	if(ch=='-')ch=getchar(),q=1;
	for(;ch>='0'&&ch<='9';ch=getchar())n=(n<<3)+(n<<1)+ch-48;
	return q?n=-n:n;
}
int n,m,ans;
vector<int>B[N];
void link(int q,int w)
{
	B[q].push_back(w);
	B[w].push_back(q);
}
bool z[N];
void dfs(int q)
{
	z[q]=1;
	efo(i,q)if(!z[B[q][i]])dfs(B[q][i]);
}
int main()
{
	int q,w,_;
	read(n);
	fo(i,1,n)
	{
		read(q);
		link(q,i);
	}
	fo(i,1,n)if(!z[i])
	{
		++ans;
		dfs(i);
	}
	LL t=1;
	fo(i,1,ans)t=(t<<1)%mo;
	printf("%lld\n",t-1);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>
#include<cassert>

using namespace std;

#define ll long long
#define reps(i, a, b) for(int i = a; i < b; i++)
#define rreps(i, a, b) for(int i = a-1; i >= b; i--)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) rreps(i, n, 0)
#define P pair<int, int>
#define vec vector<int>
#define mat vector<vec>

const ll mod = 1000000007;
const int INF = 1001001001;

int n, m;

int node(int x, int y) {
    return x * n + y;
}

P node_inv(int u){
    return P(u/n, u%n);
}

struct edge {
    int u, v;
    char c;
    edge(int u_, int v_, char c_){
        u = u_; v = v_; c = c_;
    }
};

int main(){
    cin >> n >> m;
    vector<edge> e;
    rep(i, m){
        int a, b;
        char c;
        cin >> a >> b >> c;
        a--; b--;
        e.push_back(edge(a, b, c));
    }
    mat g(n*n);
    rep(i, e.size()){
        rep(j, e.size()){
            if(e[i].c == e[j].c){
                int u1 = node(e[i].u, e[j].u);
                int v1 = node(e[i].v, e[j].v);
                int u2 = node(e[i].u, e[j].v);
                int v2 = node(e[i].v, e[j].u);
                g[u1].push_back(v1);
                g[v1].push_back(u1);
                g[u2].push_back(v2);
                g[v2].push_back(u2);
                // cout << u1 << " " << v1 << " " << u2 << " " << v2 << endl;
            }
        }
    }

    // rep(i, n*n){
    //     P p = node_inv(i);
    //     cout << p.first << " " << p.second << endl;
    //     rep(j, g[i].size()){
    //         cout << g[i][j] << " ";
    //     }cout << endl;
    //     cout << endl;
    // }

    // 奇数距離
    queue<P> que;
    que.push(P(node(0, n-1), 0));
    vec dist(n*n, INF);
    dist[node(0, n-1)] = 0;
    int ans = INF;
    while(que.size() > 0){
        int u = que.front().first;
        int d = que.front().second;
        que.pop();
        rep(i, g[u].size()){
            int v = g[u][i];
            if(dist[v] <= d+1) continue;
            dist[v] = d+1;
            que.push(P(v, d+1));
            P p = node_inv(v);
            if(p.first == p.second){
                ans = min(ans, (d+1) * 2);
            }
        }
        // cout << node_inv(u).first+1 << " " << node_inv(u).second+1 << " " << d << endl;
    }

    // 偶数距離
    rep(i, e.size()){
        ans = min(ans, dist[node(e[i].u, e[i].v)]*2+1);
        ans = min(ans, dist[node(e[i].v, e[i].u)]*2+1);
    }

    if(ans == INF) ans = -1;
    cout << ans << endl;
}

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

int main() {
  int N, ans;
  string s;
  cin >> N >> s;
  ans = N;

  auto itr = s.begin();
  while (distance(itr, s.end()) >= 3) {
    if (*itr=='f' && *(itr+1)=='o' && *(itr+2)=='x') {
      ans -= 3;
      s.erase(itr, itr+3);
      itr--; itr--;
    }
    else itr++;
  }
  cout << ans << endl;
}


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

int main() {
  string s;
  cin >> s;
  int i = 0,c = 0;
  for(i = 0; i < s.size() ; i++){
    if(s.substr(i, 4) == "ZONe") c++;
  }
  cout << c ;
}

/*------------------------------------------
    Author : Suyash Chavan
    Walchand College of Engineering, Sangli
--------------------------------------------*/
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target ("sse4")

#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 ll                          long long
#define ld                          long double
#define endl                        "\n"
#define Endl                        "\n"
#define pb                          push_back
#define mp                          make_pair
#define eb                          emplace_back
#define ff                          first
#define ss                          second
#define loop(i,a,b)                 for(ll i=a;i<b;i++)
#define rloop(i,a,b)                for(ll i=a;i>=b;i--)
#define fill(a,v)                   memset(a, v, sizeof a)
#define all(a)                      a.begin(), a.end()
#define rall(vec)                   vec.rbegin(),vec.rend()
#define sortv(a)                    sort(a.begin(),a.end())
#define set_bits(a)                 __builtin_popcount(a)
#define ordered_set                 tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define fast_map(mp)                mp.reserve(1024);\
                                    mp.max_load_factor(0.25)
#define fast_io                     ios_base::sync_with_stdio(false);\
                                    cin.tie(NULL)
#define file_in                     freopen("input.txt", "r", stdin)
#define file_out                    freopen("output.txt", "w", stdout)
#define file_io                     file_in;\
                                    file_out
#define PI                          3.1415926535897932384626
#define INF                         1e18
#define EPS                         1e-9
#define change                      show = !show

bool show = true;

const int fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, { -1, 0}};
const int fxx[8][2] = {{0, 1}, {0, -1}, {1, 0}, { -1, 0}, {1, 1}, {1, -1}, { -1, 1}, { -1, -1}};

template <typename T1, typename T2>
inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
{
    return os << "(" << p.first << ", " << p.second << ")";
}
template<typename T>
inline std::ostream &operator << (std::ostream & os, const std::vector<T>& v)
{
    bool first = true;
    if (show)
        os << "[";
    for (unsigned int i = 0; i < v.size(); i++)
    {
        if (!first)
        {
            if (show)
                os << ", ";
            else
                os << " ";
        }
        os << v[i];
        first = false;
    }
    if (show)
        return os << "]\n";
    else
        return os << "\n";
}
template<typename T>
inline std::ostream &operator << (std::ostream & os, const std::set<T>& v)
{
    bool first = true;
    os << "[";
    for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if (!first)
            os << ", ";
        os << *ii;
        first = false;
    }
    return os << "]";
}
template<typename T1, typename T2>
inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v)
{
    bool first = true;
    os << "[";
    for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if (!first)
            os << ", ";
        os << *ii ;
        first = false;
    }
    return os << "]";
}

/*--------------------------- CODE STARTS FROM HERE---------------------------*/

int solve()
{
    string s;
    cin >> s;

    ll ans = 0;

    loop(i, 0, s.size() - 3)
    {
        if (s[i] == 'Z' && s[i + 1] == 'O' && s[i + 2] == 'N' && s[i + 3] == 'e')
            ans++;
    }

    cout << ans << endl;

    return 0;
}

int main()
{
    fast_io;

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

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define lld long double
#define inf 1000000000
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define mod2 998244353
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define w(x)  int x; cin>>x; while(x--)
#define in(a) for(auto &x: a)cin>>x;
int h,w,a,b,cnt=0;
pair<int,int> nxt(int i,int j,vector<vector<bool>> &mat){
	int I=-1,J=-1;
	for(int I=i;I<h;I++){
		for(int J=0;J<w;J++){
			if(I==i && J<=j)continue;
			if(mat[I][J])continue;
			return {I,J};
		}
	}
	return {-1,-1};
}
void fun(int i,int j,vector<vector<bool>> &mat,int x,int y){
	if(x==0 && y==0){cnt++;return;}
	if(j+1<w && mat[i][j+1]==0 && x){
		mat[i][j]=mat[i][j+1]=1;
		pii nx=nxt(i,j,mat);
		fun(nx.fi,nx.se,mat,x-1,y);
		mat[i][j]=mat[i][j+1]=0;
	}
	if(i+1<h && mat[i+1][j]==0 && x){
		mat[i][j]=mat[i+1][j]=1;
		pii nx=nxt(i,j,mat);
		fun(nx.fi,nx.se,mat,x-1,y);
		mat[i][j]=mat[i+1][j]=0;
	}
	if(y){
		mat[i][j]=1;
		pii nx=nxt(i,j,mat);
		fun(nx.fi,nx.se,mat,x,y-1);
		mat[i][j]=0;
	}

}
signed main(){
    cin>>h>>w>>a>>b;
    vector<vector<bool>> mat(h,vector<bool>(w,false));
    fun(0,0,mat,a,b);
    cout<<cnt;
    return 0;
}

#include<bits/stdc++.h>
#include<chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds;
#define ll long long int
#define ull unsigned long long int
#define FOR(I,a,b) for(int I=a;I<b;I++)
#define FORit(it,a) for(auto it=a.begin();it!=a.end();it++)
#define ROF(I,a,b) for(int I=a;I>=b;I--)
#define vec vector
#define vi vec<int>
#define vll vec<ll>
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define testcases ll t;cin>>t;while(t--)
#define mem(a,k) memset(a,k,sizeof(a))
#define FF first
#define SS second
#define MP(x,y) make_pair(x,y)
#define rt return
#define br break
#define ct continue
#define elif else if
#define ii pair<int,int>
#define vecin(a,n,index) for(int I=index;I<n;I++)cin>>a[I]
#define vecout(a,n,index) for(int I=index;I<n;I++)cout<<a[I]<<" ";cout<<endl;
//ll mod = 1000000007;
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> using omset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
	int n;
	cin >> n;
	vll v(n);
	vecin(v, n, 0);
	vll p = v;
	FOR(i, 1, n)p[i] += p[i - 1];
	ll maxe = 0, ans = 0, cur = 0;
	FOR(i, 0, n) {
		maxe = max(maxe, p[i]);
		ans = max(ans, maxe + cur);
		cur += p[i];
	}
	cout << ans << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	// START FROM HERE :)
	solve();
}


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h = 0, w = 0, x = 0, y = 0;
    cin >> h >> w >> x >> y; --x; --y;
    vector<string> s(h);
    for (auto &i : s)
        cin >> i;
    int res = 0;
    for (int i = y; i < w && s[x][i] != '#'; ++i)
        ++res;
    for (int i = y; i >= 0 && s[x][i] != '#'; --i)
        ++res;
    for (int i = x; i < h && s[i][y] != '#'; ++i)
        ++res;
    for (int i = x; i >= 0 && s[i][y] != '#'; --i)
        ++res;
    cout << res - 3;
}

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

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

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}

vi par(200005);
vector<map<ll, ll> > v;

ll getP(ll s){
    if(par[s]==s) return s;
    else return (par[s]=getP(par[s]));
}

void unite(ll x, ll y){
    ll a=getP(x);
    ll b=getP(y);

    if(a==b) return;

    if(v[a].size()<v[b].size()) swap(a,b);
    par[b]=a;

    for(auto h:v[b]){
        if(v[a].find(h.ff)==v[a].end()) v[a].insert(mp(h.ff,0ll));
        v[a][h.ff]+=h.ss;
    }

    v[b].clear();

}

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

    int T=1;
    //cin >> T;
    while(T--){
        ll n,q;
        cin>>n>>q;

        ll c[n+1];
        rep(i,n) cin>>c[i+1];

        rep(i,200005) par[i]=i;
        v.assign(n+1, map<ll,ll>());

        rep_a(i,1,n+1) v[i].insert(mp(c[i],1ll));

        ll t,x,y;

        rep(i,q){
            cin>>t>>x>>y;
            if(t==1) unite(x,y);
            else{
                t = getP(x);
                if(v[t].find(y)==v[t].end()) cout<<0<<el;
                else cout<<v[t][y]<<el;
            }
        }

    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << '\n'; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    vector<ll> a(n), b(n);
    rep(i, 0, n) {
        cin, a[i];
    }
    rep(i, 0, n) {
        cin, b[i];
    }
    ll max1 = 0, max2 = 0;
    rep(i, 0, n) {
        chmax(max1, a[i]);
        chmax(max2, max1 * b[i]);
        print(max2);
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
ll I=167167167167167167;
ll Q=1e9+7;

int main() {
	ll N;
	cin>>N;
	vector<ll> a(N),b(N);
	for(int i=0;i<N;i++) cin>>a[i];
	for(int i=0;i<N;i++) cin>>b[i];
	ll A=0,B=0;
	for(int i=0;i<N;i++){
		A=max(A,a[i]);
		b[i]*=A;
		B=max(B,b[i]);
		cout<<B<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FOREACH(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define SIZE(v) ((int)(v).size())
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define llint long long
#define pii pair<int, int>
#define UNVISITED -1

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

const int MAX = 1001000;
int a[MAX];

int main() {
    int T; scanf("%d", &T);
    REP(t, T) {
        int N; scanf("%d", &N);
        REP(i, N) scanf("%d", a + i);
        if(N%2 == 1) {
            printf("Second\n");
        }
        else {
            map<int, int> dic;
            REP(i, N) dic[a[i]]++;
            bool q = true;
            for(auto x : dic) if(x.second%2 == 1) q = false;
            if(q) printf("Second\n");
            else {
                printf("First\n");
            }
        }
    }
}

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

int main() {
    int q;
    cin >> q;
    while (q-- ) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0;i < n;++i) cin >> a[i];
        bool fi = false;
        if (n%2 == 0) {
            sort(a.begin(),a.end());
            for (int i = 0;i < n/2;++i) if (a[i*2] != a[i*2+1]) {
                fi = true;
                break;
            }
        }
        cout << (fi ? "First" : "Second") << newl;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll mo = 1000000007;
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };

int main()
{
ll h , w ;
cin >> h >> w ;
vector<vector<ll>> v(h, vector<ll>(w,0) );
vector<vector<ll>> vv(h, vector<ll>(w,0) );
vector<ll> vh(w,0);
vector<ll> vw(h,0);
vector<ll> vhw(h+w+1,0);

rep(i,h)rep(j,w){
  char a;
  cin >> a ;
  if(a=='#')v[i][j]=1;
}
vv[0][0]=1;
vw[0]=1;
vh[0]=1;
vhw[w]=1;
rep(i,h)rep(j,w){
  if(i==0&&j==0)continue;
  if(v[i][j]==1){
    vw[i]=0;
    vh[j]=0;
    vhw[w+i-j]=0;
  }
  else{
    vv[i][j]=mod(vw[i]+vh[j]+vhw[w+i-j]);
    vw[i]=mod(vw[i]+vv[i][j]);
    vh[j]=mod(vh[j]+vv[i][j]);
    vhw[w+i-j]=mod(vhw[w+i-j]+vv[i][j]);
  }
}
cout << vv[h-1][w-1] << endl;
return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define srep(i, s, n) for (int i = s; i < (n); ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using T3 = tuple<int, int, int>;
template<typename T>void print(vector<T> a) { for (T t : a) { cout << t << " "; } cout << endl; }
template<typename T>void print2(T a, T b) { cout << a << " " << b << endl; }
const ll LINF = 1LL << 60;
const int INF = 1 << 30;
const int mod = 1e9 + 7;

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

    string ans;
    if (a >= 0 && b >= 0) {     // +, +
        if (a > b) { ans = ">"; }
        else if (a < b) { ans = "<"; }
        else { ans = "="; }
    } else if (a >= 0) {        // +, -
        b = abs(b);
        if (c % 2 != 0) { ans = ">"; }  // odd
        else if (a > b) { ans = ">"; }
        else if (a < b) { ans = "<"; }
        else { ans = "="; }
    } else if (b >= 0) {        // -, +
        a = abs(a);
        if (c % 2 != 0) { ans = "<"; }  // odd
        else if (a > b) { ans = ">"; }
        else if (a < b) { ans = "<"; }
        else { ans = "="; }
    } else {                    // -. -
        if (c % 2 != 0) {
            if (a > b) { ans = ">"; }
            else if (a < b) { ans = "<"; }
            else { ans = "="; }
        } else {
            if (a > b) { ans = "<"; }
            else if (a < b) { ans = ">"; }
            else { ans = "="; }
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

    if(a >= 0 && b >= 0){
        if(a > b) puts(">");
        else if(a == b) puts("=");
        else puts("<");
    }
    else if(a < 0 && b >= 0){
        if(c%2 == 0){
            if(abs(a) > abs(b)){
                puts(">");
            }
            else if(abs(a) == abs(b)){
                puts("=");
            }
            else{
                puts("<");
            }
        }
        else{
            puts("<");
        }
    }
    else if(b < 0 && a >= 0){
        if(c%2 == 0){
            if(abs(b) > abs(a)){
                puts("<");
            }
            else if(abs(a) == abs(b)){
                puts("=");
            }
            else{
                puts(">");
            }
        }
        else{
            puts(">");
        }
    }else{
        if(c%2 == 0){
            if(abs(a) > abs(b)) puts(">");
            else if(a==b) puts("=");
            else puts("<");
        }
        else{
            if(a > b) puts(">");
            else if(a == b) puts("=");
            else puts("<");
        }
    }
}


#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int t;
    long long int c;
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>c;
        if(c%4==0)cout<<"Even";
        else if(c%2==0)cout<<"Same";
        else cout<<"Odd";
        cout<<endl;
    }
}

//Bismillahir Rahmanir Raheem
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)
#define fr1(i,a) for(int i=1;i<=a;i++)
#define iter(x)  x.begin(),x.end()
#define Memset(a,x,n) for(int i=0;i<n;i++)a[i]=x;
#define fi first
#define si second
//lower_bound returns an iterator pointing to the first element in the range [first,last) which has a value not less than ‘val’.
//upper_bound returns an iterator pointing to the first element in the range [first,last) which has a value greater than ‘val’.
typedef pair<lli,lli>pll;
void solve()
{
    lli n;
    cin>>n;
    if(n%2==1)
    {
        cout<<"Odd"<<endl;
        return;
    }
    lli c=0;
    while(n%2==0)
    {
        n/=2;
        c++;
    }

    if(c==1)
    {
        cout<<"Same"<<endl;
    }
    else
    {
        cout<<"Even"<<endl;
    }

}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
}


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

ll max(int a, ll b)
{
    if (a < b)
    {
        return b;
    }
    else
    {
        return a;
    }
}

ll min(int a, int b)
{
    return a > b ? a : b;
}

int main()
{
    ll N;
    cin >> N;
    vector<vector<ll>> xyz(N, vector<ll>(3));
    rep(i, N)
    {
        cin >> xyz[i][0] >> xyz[i][1] >> xyz[i][2];
    }

    vector<vector<ll>> dist(N, vector<ll>(N));
    rep(i, N) rep(j, N)
    {
        dist[i][j] = abs(xyz[j][0] - xyz[i][0]) + abs(xyz[j][1] - xyz[i][1]) + max(0, xyz[j][2] - xyz[i][2]);
    }

    vector<ll> pow2(N + 1, 1);
    for (int i = 1; i < N + 1; i++)
    {
        pow2[i] = pow2[i - 1] * 2;
    }

    vector<vector<ll>> dp(pow2[N], vector<ll>(N, INF));
    rep(i, N)
    {
        dp[1 << i][i] = dist[i][0];
    }

    rep(i, pow2[N]) rep(j, N)
    {
        if ((i >> j & 1) != 1)
            continue;
        rep(k, N)
        {
            if ((i >> k & 1) == 1)
                continue;
            dp[i | (1 << k)][k] = min(dp[i | 1 << k][k], dp[i][j] + dist[k][j]);
        }
    }
    cout << dp[pow2[N] - 1][0] << endl;
}

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

// #define LOCAL 1;
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

template<typename T>
ostream& operator<< (ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ", ";
  }
  out << "]";
  return out;
}

template<typename F, typename S>
ostream& operator<< (ostream& out, const pair<F,S>& p) {
  out << "[" << p.first << ", " << p.second << "]";
  return out;
}

template< typename T >
struct edge {
  int src, to;
  T cost, kbai;

  edge(int to, T cost, T kbai) : src(-1), to(to), cost(cost), kbai(kbai) {}

  edge(int src, int to, T cost, T kbai) : src(src), to(to), cost(cost), kbai(kbai) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
int n,m,x,y;
template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  // vector< T > dist_kbai(g.size(), INF);
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  // dist_kbai[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    // dbg(idx);
    // dbg(cost);
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      T tcost = cost;
      tcost += (e.kbai - tcost%e.kbai)%e.kbai;
      auto next_cost = tcost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;

      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

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

  cin >> n >> m >> x >> y;
  --x;--y;
  WeightedGraph< ll > g(n);
  rep(i,m) {
    ll a, b, t, k;
    cin >> a >> b >> t >> k;
    --a;--b;
    g[a].emplace_back(b, t, k);
    g[b].emplace_back(a, t, k);
  }
  auto dist  = dijkstra(g, x);

  if(dist[y]==numeric_limits<ll>::max()) cout << -1 << endl;
  else cout << dist[y] << endl;

  return 0;

}


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

int main(){
	int n, m;
	vector<int> t(1001, 0);
	cin >> n >> m;
	for(int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		t[tmp]++;
	}
	for(int i=0; i<m; i++){
		int tmp;
		cin >> tmp;
		t[tmp]++;
	}

	for(int i=1; i<1001; i++){
		if(t[i] == 1){
			cout << i;
			if(i == 1000){
				cout << endl;
			}else{
				cout << " ";
			}
		}
	}

	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>

template<typename Container>
Container SetAnd(const Container &a, const Container &b){
  Container res;
  std::set_intersection(
    std::begin(a), std::end(a),
    std::begin(b), std::end(b),
    std::inserter(res, std::end(res))
  );
  return res;
}
template<typename Container>
Container SetOr(const Container &a, const Container &b){
  Container res;
  std::set_union(
    std::begin(a), std::end(a),
    std::begin(b), std::end(b),
    std::inserter(res, std::end(res))
  );
  return res;
}
template<typename Container>
Container SetXor(const Container &a, const Container &b){
  Container res;
  std::set_symmetric_difference(
    std::begin(a), std::end(a),
    std::begin(b), std::end(b),
    std::inserter(res, std::end(res))
  );
  return res;
}
template<typename Container>
Container SetDiff(const Container &a, const Container &b){
  Container res;
  std::set_difference(
    std::begin(a), std::end(a),
    std::begin(b), std::end(b),
    std::inserter(res, std::end(res))
  );
  return res;
}

int main() {
  int n, m; std::cin >> n >> m;
  std::vector<int> a(n), b(m);
  for(auto &x : a) std::cin >> x;
  for(auto &x : b) std::cin >> x;
  auto c = SetXor(a,b);
  for(auto &x : c) std::cout << x << '\n';
}


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

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

typedef long long LL;

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

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

int n, m;
int a[maxn];
LL inv[maxn], c[maxn], f[20][maxn];
int b[20];

int main() {
    // freopen("my.txt", "w", stdout);
    read(n, m);
    inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = (modu - (modu/i))*inv[modu%i]%modu;
    c[0] = 1;
    for (int i = 1; i <= n; ++i)
        c[i] = (n-i+1)*inv[i]%modu*c[i-1]%modu;
    int nb = 0;
    while (m) {
        b[nb++] = m%2;
        m /= 2;
    }
    memset(f, 0, sizeof(f));
    f[nb-1][0] = 1;
    int tot = b[nb-1];
    for (int i = nb-2; i >= 0; --i) {
        for (int j = 0; j <= tot*2 + b[i]; ++j) if (j%2 == 0) {
            for (int k = 0; k <= j && k <= n; k += 2)
                f[i][j] = (f[i][j] + f[i+1][(j-k)/2]*c[k]) % modu;
        }
        tot = tot*2 + b[i];
    }
    printf("%lld\n", f[0][tot]);
	return 0;
}

#include <bits/stdc++.h>
#pragma GCC optimize(3)
#define int long long
#define ri register
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define is insert
#define es erase
using namespace std;
const int N = 200010;
inline int read()
{
    int s = 0, w = 1;
    ri char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
    return s * w;
}
int n, a[N], pos[N], book[N];
vector<int> Ans;
signed main()
{
    n = read();
    for (ri int i = 1; i <= n; i++)
        a[i] = read(), pos[a[i]] = i;
    for (ri int i = 1; i <= n; i++)
    {
        while (i < pos[i])
        {
            if (book[pos[i]])
                return puts("-1") & 0;
            book[pos[i]] = 1;
            Ans.eb(pos[i]);
            int x = a[pos[i]], y = a[pos[i] - 1];
            int p = pos[i], q = pos[i] - 1;
            swap(a[pos[i]], a[pos[i] - 1]);
            pos[x] = q, pos[y] = p;
        }
    }
    if ((int)Ans.size() != n - 1)
        return puts("-1") & 0;
    for (auto i : Ans)
        printf("%lld\n", i - 1);
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
long long x,y;
int n,m;
int main()
{
	scanf("%d %d",&n,&m);
	string temp;
	for(int a=1;a<=n;a++)
	{
		int t=0;
		cin>>temp;
		for(int b=0;b<temp.size();b++)
		t+=temp[b]-'0';
		if(t%2==0) x++;
		else y++;
		//printf("%d\n",t);
	}
	printf("%lld",x*y);
	return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i,L,R) for(ll i=L;i<R;i++)
#define f(n) rep(i,0,n)
#define vll vector<ll>
#define pll pair<ll,ll>
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define PI 3.141592653589
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
#define sq(X) ((X)*(X))
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define mod 1000000007ll
const ll INF = 1e18l+10, MAX = 3e5+10;

void solve()
{
    ll n,j,m,i,c = 0;
    cin >> n >> m;
    string s;
    f(n)
    {
        cin >> s;
        ll t = 0;
        rep(j,0,m) if(s[j]=='1') t++;
        if(t%2) c++;
    }
    cout << c * (n - c) <<"\n";
}

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


#include<iostream>
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (C % 2 == 1) {
		if (A <= 0 && B > 0) {
			cout << "<";
		}
		else if (B <= 0 && A > 0) {
			cout << ">";
		}
		else if (A > 0 && B > 0) {
			if (A > B) cout << ">";
			else if (A < B) cout << "<";
			else cout << "=";
		}
		else if (A <= 0 && B <= 0) {
			if (A > B) cout << ">";
			else if (A < B) cout << "<";
			else cout << "=";
		}
	}
	else {
		if (A <= 0 && B > 0) {
			if (A + B > 0)cout << "<";
			else if (A + B < 0)cout << ">";
			else cout << "=";
		}
		else if (B <= 0 && A > 0) {
			if (A + B > 0)cout << ">";
			else if (A + B < 0)cout << "<";
			else cout << "=";
		}
		else if (A > 0 && B > 0) {
			if (A > B) cout << ">";
			else if (A < B) cout << "<";
			else cout << "=";
		}
		else if (A <= 0 && B <= 0) {
			if (A > B) cout << "<";
			else if (A < B) cout << ">";
			else cout << "=";
		}
	}
}

/* Author :
	Drigesh Anuragi
*/

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define repl(i,n) for(ll i=0;i<n;i++)
#define repl1(i,n) for(ll i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define revl(i,n) for(ll i=n-1;i>=0;i--)
#define repn(i,n) for(int i=0;i<=n;i++)
#define repln(i,n) for(ll i=0;i<=n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define si set<int>
#define sll set<ll>
#define mpi map<int,int>
#define mpll map<ll,int>

#define trav(t) t.begin(),t.end()

#define lb lower_bound
#define up upper_bound
#define pb push_back
#define Mod 1000000007

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

int prime_factors(int n) // Use int instead of ll to avoid TLE
{
	int res=0;
	while (n % 2 == 0)
	{
		res++;
		n = n/2;
	}
	for (int i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			res++;
			n = n/i;
		}
	}
	if (n > 2)
		res++;
	return res;
}

/////////////////////////////////////////////////////////// Solve here //////////////////////////////////////////////////////

ll ncr(ll n,ll r){
	if(r==0) return 1;
	return n* ncr(n-1,r-1) / r ;
}

void solve(){

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

	if(c%2){
		if(a==b) cout<<"=";
		else if(a<b) cout<<"<";
		else cout<<">";
	}
	else{
		ll aa = a;
		aa=abs(aa);
		ll bb = b;
		bb=abs(bb);
		if(aa==bb) cout<<"=";
		else if(aa<bb) cout<<"<";
		else cout<<">";
	}

	return ;
}

/////////////////////////////////////////////////////////////// MAIN FUNCTION //////////////////////////////////////////////////

int main(){
    fastio;
    int tc;
    tc=1;
    // cin>>tc;
    while(tc--){
    	solve();
    	if(tc) cout<<"\n";
    }

    return 0;
}