#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define pb push_back
#define mp make_pair
#define FIO  ios::sync_with_stdio(false); cin.tie(0);   cout.tie(0);
#define all(in) in.begin(), in.end()
typedef pair<ll, ll> pll;

void solve(){
    ll n;   cin >> n;
    ll ans = 0;
    vector<ll> a(n), b(n), even, odd;
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];    ans += a[i];
    }
    for(int i = 0 ; i < n ; i++){
        cin >> b[i];
    }
    for(int i = 0 ; i < n ; i++){
        ll x = b[i] - a[i];
        if(i&1){
            even.pb(x);
        }else{
            odd.pb(x);
        }
    }
    sort(all(even));
    sort(all(odd));
    for(int i = even.size()-1 ; i >= 0 ; i--){
        ll x = even[i] + odd[i];
        if(x < 0){
            break;
        }
        ans += x;
    }
    cout << ans << endl;
}

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

#include <bits/stdc++.h>
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

int main() {
  int n;
  scanf("%d",&n);
  vi a(n), b(n);
  cin>>a>>b;
  ll ans = 0;
  rep(i,n) {
    if (i%2) ans += b[i], a[i] = a[i]-b[i];
    else ans += a[i], a[i] = b[i]-a[i];
  }
  sort(rrng(a));
  rep(i,n/2) ans += a[i];
  cout<<ans<<endl;
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define ll long long
using namespace std;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
bool vis[200];
int main(){
    ll t=read(),n=read()-1;
    rep(i,1,100)vis[i*(100+t)/100]=1;
    int c=0;ll ans=0;
    rep(i,1,100+t){
        if(!vis[i]){
            if(c==n%t){
                ans=i;
            }
            c++;
        }
    }
    ans+=1ll*(100+t)*(n/t);
    cout<<ans<<endl;
    return 0;
}

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

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

namespace IntModulo
{
	const int mod = 998244353;

	inline int add(int x, int y, int m = mod)
	{
		if (x + y < m)
			return x + y;
		return x + y - m;
	}

	inline int sub(int x, int y, int m = mod)
	{
		if (x >= y)
			return x - y;
		return x - y + m;
	}

	inline int mult(int x, int y, int m = mod)
	{
		return x * (LL) y % m;
	}

	inline int power(int x, LL y, int m = mod)
	{
		int r = 1;
		while(y)
		{
			if (y & 1)
				r = mult(r, x, m);
			x = mult(x, x, m);
			y >>= 1;
		}

		return r;
	}

	inline int inverse(int x, int m = mod)
	{
		return power(x, m - 2, m);
	}

	inline void ADD(int& x, int y, int m = mod){
		x += y;
		if (x >= m) x -= m;
	}

	inline void SUB(int& x, int y, int m = mod){
		x -= y;
		if (x < 0) x += m;
	}

	inline void MULT(int& x, int y, int m = mod){
		x = (x * (LL) y) % m;
	}
};

using namespace IntModulo;

const int N = 64;
int n, k, a[N][N], f[N];

int solve(vector<vector<int>>& g){
	int C = 0;
	vector<int> used(n, 0);

	function<void(int)> dfs = [&](int v){
		C++;
		used[v] = 1;
		for(auto i: g[v]){
			if (!used[i]){
				dfs(i);
			}
		}
	};

	vector<int> res;
	FOR(i, 0, n) if (!used[i]){
		dfs(i);
		res.PB(C);
		C = 0;
	}

	int ans = 1;
	for(auto i: res){
		MULT(ans, f[i]);
	}

	return ans;
}

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

	f[0] = 1;
	FOR(i, 1, N) f[i] = mult(f[i - 1], i);
	cin >> n >> k;
	FOR(i, 0, n) FOR(j, 0, n) cin >> a[i][j];
	vector<vector<int>> row(n), column(n);
	FOR(i, 0, n){
		FOR(j, 0, i){
			bool ok = true;
			FOR(x, 0, n){
				ok &= a[i][x] + a[j][x] <= k;
			}

			if (ok){
				row[i].PB(j);
				row[j].PB(i);
			}
		}
	}

	FOR(i, 0, n){
		FOR(j, 0, i){
			bool ok = true;
			FOR(x, 0, n){
				ok &= a[x][i] + a[x][j] <= k;
			}

			if (ok){
				column[i].PB(j);
				column[j].PB(i);
			}
		}
	}

	int R = solve(row);
	int C = solve(column);
	cout << mult(R, C) << endl;

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define ET cout << "\n"
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef bbq
#define debug(...) {\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}
#define DB(a,s,e) {for(int _i=s;_i<e;++_i) cerr << a[_i] << " ";cerr << "\n";}
template<typename T>void _do(T &&x){cerr<<x<<endl;}
template<typename T,typename ...S> void _do(T &&x,S &&...t){cerr<<x<<", ";_do(t...);}
template<typename a,typename b> ostream& operator << (ostream &s,const pair<a,b> &p){return s<<"("<<p.X<<","<<p.Y<<")";}
#else
#define debug(...)
#define DB(a,s,e)
#endif

pii edge[20000];
int c[20000], dir[20000], boss[20000], vis[20000], dft;
vector<int> G[20000];

void dfs(int u, int f) {
    vis[u] = ++dft;
    for (int i : G[u]) {
        if (i == f) continue;
        int type, v;
        if (edge[i].X == u)
            type = 1, v = edge[i].Y;
        else
            type = 2, v = edge[i].X;
        if (!vis[v]) {
            dir[i] = type;
            dfs(v, i);
        }
        else if (vis[u] > vis[v])
            dir[i] = type;
    }
}

int finds(int x) {
    if (x == boss[x])
        return x;
    return boss[x] = finds(boss[x]);
}

int main() {
    IOS();
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i)
        cin >> edge[i].X >> edge[i].Y;
    for (int i = 1; i <= n; ++i)
        cin >> c[i], boss[i] = i;
    for (int i = 1; i <= m; ++i)
        if (c[edge[i].X] == c[edge[i].Y]) {
            boss[finds(edge[i].X)] = finds(edge[i].Y);
            G[edge[i].X].pb(i);
            G[edge[i].Y].pb(i);
        }
        else if (c[edge[i].X] > c[edge[i].Y])
            dir[i] = 1;
        else
            dir[i] = 2;
    for (int i = 1; i <= n; ++i)
        if (!vis[finds(i)])
            dfs(finds(i), 0);
    for (int i = 1; i <= m; ++i)
        if (dir[i] == 1)
            cout << "->\n";
        else if (dir[i] == 2)
            cout << "<-\n";
        else
            assert(0);
}

#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 10000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

vi to[maxn+5];
pii e[maxn+5];
int c[maxn+5];

bool ans[maxn+5];
int dep[maxn+5];

void dfs(int now,int fa)
{
    for(auto i: to[now])
    {
        int v=now^e[i].FI^e[i].SE;
        if(c[v]!=c[now] || v==fa) continue;
        if(dep[v]==0)
        {
            if(e[i].FI==now) ans[i]=1;
            dep[v]=dep[now]+1;
            dfs(v,now);
        }
        else if(dep[v]<dep[now])
        {
            if(e[i].FI==now) ans[i]=1;
        }
    }
}

int main()
{
    int n,m; scanf("%d%d",&n,&m);
    rep(i,1,m) scanf("%d%d",&e[i].FI,&e[i].SE),to[e[i].FI].pb(i),to[e[i].SE].pb(i);
    rep(i,1,n) scanf("%d",&c[i]);

    rep(i,1,m) if(c[e[i].FI]>c[e[i].SE]) ans[i]=1;
    rep(i,1,n) if(dep[i]==0) dep[i]=1,dfs(i,0);
    rep(i,1,m) if(ans[i]) puts("->"); else puts("<-");
    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <bitset>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <algorithm>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <ctime>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")
*/

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else
    #define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a, b) for (int i = a; i < b; i++)
#define fj(a, b) for (int j = a; j < b; j++)
#define fk(a, b) for (int k = a; k < b; k++)
#define fi1(a, b) for (int i = a - 1; i >= b; i--)
#define fj1(a, b) for (int j = a - 1; j >= b; j--)
#define fk1(a, b) for (int k = a - 1; k >= b; k--)
#define fx(x, a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, const T2 &y) { if (y < x) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, const T2 &y) { if (x < y) x = y; }

ostream& operator << (ostream &out, const vector<int> &b) {
    for (auto k : b) out << k << ' ';
    return out;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vi g[MX];
int turn[MX];
int c[MX];
vpii edges;
int used[MX];
int dp[MX];

void make(int id, int a, int b) {
	if (edges[id].first == a)
		turn[id] = 0;
	else
		turn[id] = 1;
}

void dfs(int v, int prid =-1) {
	used[v] = 1;
	fx(id, g[v]) {
		if (id == prid) continue;
		int to = edges[id].first ^ edges[id].second ^ v;
		if (c[to] != c[v]) continue;
		if (used[to]) {
			if (dp[to] < dp[v]) {
				make(id, v, to);
			}
		} else {
			dp[to] = dp[v] + 1;
			make(id, v, to);
			dfs(to, id);
		}
	}
}

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

    int n, m;
    cin >> n >> m;
    fi(0, m) {
    	int a, b;
    	cin >> a >> b;
    	--a, --b;
    	g[a].pb(i);
    	g[b].pb(i);
    	edges.pb({a, b});
    	turn[i] = -1;
    }

    vi p(n);
    fi(0, n) {
   		cin >> c[i];
    	p[i] = i;
    }
    sort(all(p), [&](int i, int j) {
    	return c[i] < c[j];
    });
    for (int col = 2; col <= n; ++col) {
    	fi(0, n) {
    		if (!used[i] && c[i] == col) {
    			dfs(i);
    		}
    	}
    }
    fx(v, p) {
    	fx(id, g[v]) {
    		if (turn[id] == -1) {
    			int to = edges[id].first ^ edges[id].second ^ v;
    			assert(c[to] > c[v]);
    			make(id, to, v);
    		}
    	}
    }
    fi(0, m) {
    	assert(turn[i] != -1);
    	if (turn[i] == 0) {
    		cout << "->\n";
    	} else {
    		cout << "<-\n";
    	}
    }
}

#include<bits/stdc++.h>
using namespace std;
#define ma 2147483647
#define ll long long
#define ld long double
#define pii pair<int,int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define um unordered_map
#define vi vector<int>
#define mii map<int,int>
#define si set<int>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*(b/gcd(a,b))
#define mmst(a,b) memset(a,b,sizeof(a))
int n,m;
int a[10005],b[10004],c[10005],ans[10005];
int tu[200][200];
void dfs(int x)
{
	for (int i=1;i<=n;i++)
	{
		if (tu[x][i]!=0)
		{
			ans[ abs(tu[x][i]) ] = tu[x][i]/abs(tu[x][i]);
			tu[x][i]=0;
			tu[i][x]=0;
			dfs(i);
		}
	}
}
int main()
{
	//freopen("d.in","r",stdin);
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		a[i]=x,b[i]=y;
	}
	for (int i=1;i<=n;i++) scanf("%d",&c[i]);
	for (int i=1;i<=m;i++)
	{
		if (c[a[i]]<c[b[i]]) ans[i]=-1;
		if (c[a[i]]>c[b[i]]) ans[i]=1;
	}
	for (int i=1;i<=m;i++)
	{
		if ( c[a[i]] == c[b[i]] )
		{
			tu[a[i]][b[i]]=i;
			tu[b[i]][a[i]]=-i;
		}
	}
	for (int i=1;i<=n;i++)
	{
		dfs(i);
	}
	for (int i=1;i<=m;i++)
	{
		if (ans[i]<0) printf("<-");
		if (ans[i]>0) printf("->");
		printf("\n");
	}
}


#include <iostream>
#include <cmath>
#include <utility>

using namespace std;

#define mp make_pair
#define x first
#define y second
typedef pair<int,int> pii;
typedef long long ll;

pii tocke[1003];

int main(){
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>tocke[i].x>>tocke[i].y;
	}
	int br=0;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			if(abs(tocke[i].y-tocke[j].y)/abs(tocke[i].x-tocke[j].x)==0 or abs(tocke[i].y-tocke[j].y)==abs(tocke[i].x-tocke[j].x)) br++;
		}
	}
	cout<<br;

return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll n;
    cin>>n;
    vector<pair<ll,ll>>v;
    ll two=INT_MAX;
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        two=min(two,a+b);
    }
    ll first=INT_MAX;
    ll second=INT_MAX;
    ll f2=INT_MAX;
    ll s2=INT_MAX;
    ll i=0,index=0;
    for(auto itr:v){
        if(itr.first<first){
            first=min(itr.first,first);
            index=i;
        }
        i++;
    }
    i=0;
    for(auto itr:v){
        if(itr.second<second&&index!=i ){
            second=min(itr.second,second);
        }
        i++;
    }
    i=0;
    index=0;
    for(auto itr:v){
        if(itr.first<f2){
            f2=min(itr.first,f2);
            index=i;
        }
        i++;
    }
    i=0;
    for(auto itr:v){
        if(itr.second<s2&&index!=i ){
            s2=min(itr.second,s2);
        }
        i++;
    }
    //cout<<first<<" "<<second<<" "<<f2<<" "<<s2<<" ";
    ll tmp=min(max(first,second),max(f2,s2));
    ll ans=min(two,tmp);
    cout<<ans<<"\n";
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    LL N, C;
    cin >> N >> C;
    vector<LL> a(N), b(N), c(N);

    set<LL> zipped;

    LL M = -1;
    REP(i, N) {
        cin >> a[i] >> b[i] >> c[i];
        b[i]++;
        zipped.insert(a[i]);
        zipped.insert(b[i]);
    }

    map<LL, int> dic;
    map<int, LL> inv;
    int n = 0;
    for(auto i : zipped) {
        dic[i] = n;
        inv[n] = i;
        n++;
    }

    vector<LL> cost(dic.size() + 1, 0);
    REP(i, N) {
        cost[dic[a[i]]] += c[i];
        cost[dic[b[i]]] -= c[i];
    }

    FOR(i, 1, dic.size() + 1) {
        cost[i] += cost[i - 1];
    }
    REP(i, dic.size() + 1) {
        cost[i] = min(cost[i], C);
    }

    LL s = 0;
    REP(i, dic.size()) {
        s += (inv[i + 1] - inv[i])*cost[i];
    }
    cout << s << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=200005,INF=1<<30;

int main(){

    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);

    int Q;cin>>Q;
    while(Q--){
        int N;cin>>N;
        vector<int> p(N+1);
        for(int i=0;i<N;i++) cin>>p[i+1];
        vector<int> ans;

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

        int t=1;
        for(int i=1;i<=N-3;i++){
            int pos=-1;
            for(int j=i;j<=N;j++){
                if(p[j]==i){
                    pos=j;
                    break;
                }
            }
            if(pos==i){
                for(int j=i+1;j<N;j++){
                    if((j&1)==(t&1)){
                        ans.push_back(j);
                        swap(p[j],p[j+1]);
                        t++;
                        break;
                    }
                }
            }else{
                if((pos&1)==(i&1)){
                    for(int j=i;j<N;j++){
                        if((j&1)==(t&1)&&j!=pos){
                            ans.push_back(j);
                            swap(p[j],p[j+1]);
                            t++;
                            break;
                        }
                    }
                }

                for(int j=pos-1;j>=i;j--){
                    ans.push_back(j);
                    swap(p[j],p[j+1]);
                    t++;
                }
            }
        }

        if(p[N-2]==N-2){
            if(p[N-1]==N){
                ans.push_back(N-2);
                ans.push_back(N-1);
                ans.push_back(N-2);
                ans.push_back(N-1);
                ans.push_back(N-2);
            }
        }else{
            if(p[N-1]==N-2){
                ans.push_back(N-2);
                swap(p[N-2],p[N-1]);
                t++;
            }else{
                ans.push_back(N-2);
                swap(p[N-2],p[N-1]);
                t++;

                ans.push_back(N-1);
                swap(p[N-1],p[N]);
                t++;

                ans.push_back(N-2);
                swap(p[N-2],p[N-1]);
                t++;
            }

            if(p[N-1]==N){
                ans.push_back(N-1);
            }
        }

        cout<<si(ans)<<endl;
        for(int a:ans) cout<<a<<" ";
        cout<<endl;
    }
}

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

const int MAX_N = 2e5, MOD = 1e9 + 7, INF = 1e9;
int t, n[250];
vector<int> v[250], ans[250];

int main() {
    ci(t);
    rep(i, t) {
        ci(n[i]);
        rep(j, n[i]) {
            int p;
            ci(p);
            v[i].epb(p - 1);
        }
    }
    rep(i, t) {
        if (n[i] == 2) {
            if (v[i][0]) ans[i].epb(1);
            continue;
        }
        vector<int> memo(n[i]);
        rep(j, n[i]) memo[v[i][j]] = j;
        int cnt = 0;
        rep(j, n[i] - 3) {
            int a = memo[j];
            if (a == j) continue;
            if (cnt % 2 == a % 2) {
                cnt++;
                if (a > j + 1) {
                    swap(v[i][a - 2], v[i][a - 1]);
                    swap(memo[v[i][a - 2]], memo[v[i][a - 1]]);
                    ans[i].epb(a - 1);
                }
                else if (a + 3 < n[i]) {
                    swap(v[i][a + 2], v[i][a + 3]);
                    swap(memo[v[i][a + 2]], memo[v[i][a + 3]]);
                    ans[i].epb(a + 3);
                }
                else {
                    ans[i].epb(a + 1);
                    ans[i].epb(a);
                    ans[i].epb(a + 1);
                    swap(v[i][a - 1], v[i][a + 1]);
                    swap(memo[v[i][a - 1]], memo[v[i][a + 1]]);
                    cnt += 2;
                }
            }
            for (int k = a - 1; k >= j; k--) {
                memo[v[i][k]]++;
                swap(v[i][k], v[i][k + 1]);
                cnt++;
                ans[i].epb(k + 1);
            }
            memo[j] = j;
        }
        for (bool j = (cnt + n[i] + 1) % 2; v[i][n[i] - 3] != n[i] - 3 ||
                                        v[i][n[i] - 2] != n[i] - 2 ||
                                        v[i][n[i] - 1] != n[i] - 1; j = !j) {
            swap(v[i][n[i] - 3 + j], v[i][n[i] - 2 + j]);
            ans[i].epb(n[i] - 2 + j);
        }
    }
    rep(i, t) {
        co(ans[i].size());
        rep(j, ans[i].size() - 1) cout << ans[i][j] << " ";
        if (ans[i].empty()) cout << endl;
        else cout << ans[i].back() << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
//	freopen("input.in", "r", stdin);
	int n, k, m;
	scanf("%d %d %d", &n, &k, &m);
	m *= n;
	for (int i = 1; i < n; ++i) {
		int a;
		scanf("%d", &a);
		m -= a;
	}
	m = max(m, 0);
	if (m <= k)
		printf("%d\n", m);
	else
		puts("-1");
	return 0;
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  int n,k,m;
  cin>>n>>k>>m;
  vi a(n-1);
  int sum=0;
  rep(i,n-1) {
    cin>>a[i];
    sum+=a[i];
  }
  int ja=m*n-sum;
  if(ja>k){
    cout<<-1<<endl;
    return 0;
  }
  if(ja<=0){
    cout<<0<<endl;
    return 0;
  }
  cout<<ja<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define FIO ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
#define int long long
#define mod 1000000007
typedef vector<int> vi;
typedef vector<bool> vb;
#define ff first
#define ss second
#define pb push_back
#define Pob pop_back
#define mp make_pair

void solve() {
  int n; cin >> n;
  int a;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a > 10) {
      ans += a - 10;
    }
  }
  cout << ans;

}

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

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


#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 2005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
string s[2005];
int h,w;
ll dp[N][N][5];

bool valid(int i,int j)
{
    return i>=0&&i<h&&j>=0&&j<w&&s[i][j]=='.';
}

ll run(int i,int j,int c)
{
    if(i==h-1&&j==w-1)
    {
        return 1;
    }
    if(dp[i][j][c]!=-1)
        return dp[i][j][c];
    ll ans=0;
    if(c==0)
    {
        if(valid(i,j+1)) ans=(ans+run(i,j+1,1));
        if(valid(i+1,j)) ans=(ans+run(i+1,j,2));
        if(valid(i+1,j+1)) ans=(ans+run(i+1,j+1,3));
    }
    else if(c==1)
    {
        ans=(ans+run(i,j,0));
        if(valid(i,j+1)) ans=(ans+run(i,j+1,1));
    }
    else if(c==2)
    {
        ans=(ans+run(i,j,0));
        if(valid(i+1,j)) ans=(ans+run(i+1,j,2));
    }
    else if(c==3)
    {
        ans=(ans+run(i,j,0));
        if(valid(i+1,j+1)) ans=(ans+run(i+1,j+1,3));
    }
    ans%=M;
    return dp[i][j][c]=ans;
}

main()
{
    memset(dp,-1,sizeof dp);
    cin>>h>>w;
    for(int i=0;i<h;i++)
        cin>>s[i];
    cout<<run(0,0,0);
}

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
#include<time.h>
#include<deque>
#include<cstring>
#define ll long long
#define DB double
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define pf push_front
#define MOD (ll)(998244353)
#define INF (ll)(1e9)
#define M 5000005
#define AC ios::sync_with_stdio(0);cin.tie(0);
using namespace std;

template<class T> using PQ=priority_queue<T,vector<T>,greater<T> >;

ll fpow(ll x,ll y){
    ll r=1;
    while(y){
        if(y&1){
            r*=x;
            r%=MOD;
        }
        x=x*x%MOD;
        y>>=1;
    }
    return r;
}

ll gcd(ll x,ll y){
    if(x<y) swap(x,y);
    return y?gcd(y,x%y):x;
}
ll dp[105][10005],s[105];
signed main(){
    AC;
    s[0]=1;
    FOR(i,1,101) s[i]=(s[i-1]*i)%MOD;
    int n,w[105],sum=0;
    cin>>n;
    FOR(i,1,n+1){
        cin>>w[i];
        sum+=w[i];
    }
    if(sum&1) {
        cout<<0<<endl;
        return 0;
    }
    sum/=2;
    dp[0][0]=1;
    FOR(i,1,n+1)for(int j=i;j>0;j--)for(int k=sum;k>=w[i];k--) dp[j][k]=(dp[j][k]+dp[j-1][k-w[i]])%MOD;
    ll ans=0;
    FOR(i,1,n){
        ll tmp=s[i]*s[n-i]%MOD;
        tmp*=dp[i][sum];
        tmp%=MOD;
        ans=(ans+tmp)%MOD;
    }
    cout<<ans<<endl;
}


/**
 * Author: Daniel
 * Created Time: 2021-01-24 23:19:13
**/

// time-limit: 2000
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define ER erase
#define IS insert
#define PI acos(-1)
#define PB pop_back
#define EB emplace_back
#define lowbit(x) (x & -x)
#define SZ(x) ((int)x.size())
#define MP(x, y) make_pair(x, y)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define SOS; ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<fixed<<setprecision(10);

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef unsigned long long ULL;

template <typename A> using VE = vector<A>;
template <typename A> using USET = unordered_set<A>;
template <typename A> using HEAP = priority_queue<A>;
template <typename A, typename B> using PA = pair<A, B>;
template <typename A, typename B> using UMAP = unordered_map<A, B>;
template <typename A> using RHEAP = priority_queue<A, vector<A>, greater<A> >;

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

// check the limitation!!!
const int N = 100010, M = 1010;

char a, b, c;

// read the question carefully!!!
int main()
{
    SOS;

    cin >> a >> b >> c;
    if (a == b && b == c) cout << "Won\n";
    else cout << "Lost\n";
    return 0;
}

// GOOD LUCK!!!

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

void solve() {

}

int main() {
  string s;
  cin >> s;
  if( s[0] == s[1] && s[1] == s[2] ) puts("Won");
  else puts("Lost");

  return 0;
}


#include <bits/stdc++.h>
#define clog(x) std::clog << (#x) << " is " << (x) << '\n';
using LL = long long;

const int N = 2002;
struct Edge {
	int to;
	LL c, d;
	Edge(int x, LL y, LL z) : to(x), c(y), d(z) {}
};
const LL INF = 1e18;
int main() {
	//freopen("in", "r", stdin);
	std::cin.tie(nullptr)->sync_with_stdio(false);
	int cas = 1;
	// std::cin >> cas;
	while (cas--) {
		int n, m;
		std::cin >> n >> m;
		std::vector<std::vector<Edge>> e(n);
		for (int i = 0, u, v; i < m; ++i) {
			LL c, d;
			std::cin >> u >> v >> c >> d;
			if (--u == --v) continue;
			e[u].emplace_back(v, c, d);
			e[v].emplace_back(u, c, d);
		}
		auto f = [&](LL c, LL d, LL t) -> LL {
			int sn = std::sqrt(d);
			if (t > sn) return c + t + d / (t + 1);
			return c + sn + std::min(d / (sn + 1), d / (sn + 2) + 1);
		};
		std::vector<LL> dist(n, INF);
		dist[0] = 0;
		std::priority_queue<std::pair<LL, int>> Q;
		Q.push({0, 0});
		while (!Q.empty()) {
			auto [du, u] = Q.top();
			Q.pop();
			if (du != -dist[u]) continue;
			for (auto [v, c, d] : e[u]) {
				LL now = f(c, d, -du);
				if (dist[v] > now) {
					dist[v] = now;
					Q.push({-now, v});
				}
			}
		}
		std::cout << (dist[n - 1] == INF ? -1 : dist[n - 1]) << '\n';
	}
	return 0;
}

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

template <class T>
using idx_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define ull unsigned long long
#define arr array
#define vt vector
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()
#define pi acosl(-1)

//ofstream out("debug.txt");

const int MxN = 1e5, md = 1e9 + 7;

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

	ll n, C;
	cin >> n >> C;
	vt<arr<ll, 2>> v;
	ll a, b, c;
	for (int i = 0; i < n; ++i)
		cin >> a >> b >> c, v.push_back({a, c}), v.push_back({b + 1, -c});
	sort(all(v));
	ll cf = 0, tf = 0, ld = 0;
	for (auto a : v)
	{
		tf += min(cf, C) * (a[0] - ld);
		cf += a[1];
		ld = a[0];
	}
	cout << tf << '\n';
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

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

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

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int N;
    cin >> N;
    V<int> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    ll ans = 0;
    ll s = 0;
    V<ll> v1, v2;

    rep(i, N) {
        s += A[i];
        if (i & 1) {
            v1.pb(A[i] - B[i]);
        } else {
            v2.pb(A[i] - B[i]);
        }
    }
    sort(ALL(v1));
    sort(ALL(v2));
    ans = s;
    rep(i, N / 2) {
        s -= v1[i] + v2[i];
        chmax(ans, s);
    }
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
#define pu push
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=1;i<=x;i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define BITSC(x,v) (binary_search(x.begin(),x.end(),v)
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
const double eps =1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main(){
    int n;cin>>n;
    vi a(n);
    vi b(n);
    rep(i,n){
        cin>>a[i];
        b[i]=i+1;
    }
    sort(rng(a));
    bool flag=1;
    rep(i,n){
        if(a[i]!=b[i])flag=0;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_ll.hpp>

#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 fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1e9+7;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<ll>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc ll t; cin >> t; while(t--)

// using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<vector<pii>> adj;
vector<ll> store;
void dfs(ll u,ll p){
  for(auto i:adj[u]){
    if(i.f!=p){
      store[i.f]=store[u]^i.s;
      dfs(i.f,u);
    }
  }
}
void solve(){
  ll n,x,y,w;
  cin>>n;
  adj=vector<vector<pii>>(n);
  store=vector<ll>(n,0);
  rep(i,0,n-1){
    cin>>x>>y>>w;
    adj[x-1].pb({y-1,w});
    adj[y-1].pb({x-1,w});
  }
  dfs(0,0);
  ll dp[61],dp1[61];
  rep(i,0,61) dp[i]=0,dp1[i]=0;
  ll ans=0,c1,c2;
  rep(j,0,61){
     c1=0,c2=0;
      rep(i,0,n){
        if( store[i] & (1LL<<j)) c1++;
        else c2++;
      }
      ll z=1LL<<j;
      z%=mod;
      ans=(ans+(((z*c1)%mod)*c2)%mod)%mod;
  }
  cout<<ans<<endl;
}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N=205;
int n,a[N];
vector<int>v,res1,res2;
vector<int>save[N];
bool flag;
void dfs(int cur,int sum){
	sum%=200;
	if(flag)	return;
	if(cur==n+1){
		if(save[sum].size()&&v.size()){
			flag=true;
			res1=save[sum];
			res2=v;
		}
		else	save[sum]=v;
		return;
	}
	dfs(cur+1,sum);

	v.push_back(cur);
	dfs(cur+1,sum+a[cur]);
	v.pop_back();
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	scanf("%d",&a[i]);
	dfs(1,0);
	if(flag){
		puts("Yes");
		cout<<res1.size()<<" ";
		for(int i=0;i<res1.size();i++)	cout<<res1[i]<<" ";
		puts("");
		cout<<res2.size()<<" ";
		for(int i=0;i<res2.size();i++)	cout<<res2[i]<<" ";
	}
	else	puts("No");
	return 0;
}
/*
鸽巢原理
如果n个巢里有kn+1个鸽子，那么至少有一个巢里面有kn+1个鸽子
*/


// <Rahil Malhotra / ViciousCoder>
#include "bits/stdc++.h"
using namespace std;

template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int mul=1;
    int fl=0;
    for(int i=1;;i++)
    {
        mul*=3ll;
        int temp=n-mul;
        if(temp<5)
            break;
        int ctr=0;
        while(temp%5==0)
        {
            temp/=5;
            ctr++;
        }
        if(temp!=1 || ctr==0)
            continue;
        cout<<i<<" "<<ctr<<endl;
        fl=1;
        break;
    }
    if(!fl)
        cout<<-1;
}


#include<bits/stdc++.h>
using namespace std;
#define light ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define cases() ll t;cin>>t;while(t--)
#define all(c) c.begin(),c.end()
#define PI 3.14159265358979323846
const ll MAX = 2e5+5;
const ll INF = 1e18;
const ll MOD = 1e9+7;

int main()
{
    ll i,j,k,l,p,q,x,y,n;
    cin >> n;
    multiset<pair<ll,pair<ll,ll>>> mp;
    p = 0;
    for(i=0;i<n;i++)
    {
        cin >>  x >> y;
        mp.insert({2*x+y,{x,y}});
        p+=x;
    }
    l = 0;k = 0;
    while(l<=p)
    {
        pair<ll,ll> pi = mp.rbegin()->second;
        x = pi.first;y = pi.second;
        p = p-x;l = l+x+y;
        k++;
        mp.erase(prev(mp.end()));
    }
    cout << k;
}

//#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<cctype>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<ctime>
#include<cstdlib>
#define X first
#define Y second
#define L (u<<1)
#define R (u<<1|1)
#define pb push_back
#define mk make_pair
#define Mid (tr[u].l+tr[u].r>>1)
#define Len(u) (tr[u].r-tr[u].l+1)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define db puts("---")
using namespace std;

//void rd_cre() { freopen("d://dp//data.txt","w",stdout); srand(time(NULL)); }
//void rd_ac() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//AC.txt","w",stdout); }
//void rd_wa() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//WA.txt","w",stdout); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

const int N=200010,mod=1e9+7,INF=0x3f3f3f3f;
const double eps=1e-6;

int n;
struct Node
{
    LL a,b;
    bool operator < (const Node&W) const
    {
        return a*2+b>W.a*2+W.b;
    }
}node[N];

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

    scanf("%d",&n);
    LL sum=0,ans=0;
    for(int i=1;i<=n;i++) scanf("%lld%lld",&node[i].a,&node[i].b),sum+=node[i].a;
    sort(node+1,node+1+n);
    int res=0;
    for(int i=1;i<=n;i++)
    {
        ans+=node[i].a*2+node[i].b;
        res++;
        if(ans>sum) break;
    }
    printf("%d\n",res);

	return 0;
}
/*

*/


#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,a,b) for(int i=(a);i>=(b);--i)
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 2e5 + 5;
int n;
int a[maxn], b[maxn], lg[maxn], st[maxn][22];
void init() {
	fo(i, 1, n)st[i][0] = a[i];
	fo(i, 2, n)lg[i] = lg[i >> 1] + 1;
	for (int j = 1; j <= lg[n]; ++j) {
		for (int i = 1; i + (1 << j) - 1 <= n; ++i) {
			st[i][j] = max(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);
		}
	}
}
int f(int l, int r) {
	int k = lg[r - l + 1];
	return max(st[l][k], st[r - (1 << k) + 1][k]);
}
int main() {
	IOS;
	cin >> n;
	fo(i, 1, n)cin >> a[i];
	fo(i, 1, n)cin >> b[i];
	init();
	ll ans = 0;
	fo(i, 1, n) {
		ans = max(ans, 1ll * f(1, i) * b[i]);
		cout << ans << endl;
	}

	return 0;
}
/*

*/

#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define int long long
#define ld long double
#define vint vector<int>
#define vpair vector<pair<int, int>>
#define vvec vector<vector<int>>
#define vvpair vector<vector<pair<int, int>>>
#define qint queue<int>
#define pint pair<int, int>
#define ps(x,y) fixed<<setprecision(y)<<x
#define all(x) x.begin(), x.end()
#define revall(x) x.rbegin(), x.rend()
#define in(v, s, e) for(int i = s; i<e; i++){cin >> v[i];}
#define out(v, s, e) for(int i = s; i<e; i++){cout << v[i];}

const int mod = 1e9 + 7;
const int MAX = 1e18;

int sol(int n)
{
    int ans = 1;

    while(n > 0)
    {
        ans *= 10;
        n--;
    }

    return ans;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    int ans = 0;
    int x = log10(n);
    while(x >= 3)
    {
        // cout << n << " " << x << endl;
        int y = sol(x);
        // cout << y << endl;
        ans += (n - y + 1)*(x/3);
        // cout << y << " " << x << " " << ans << endl;
        n = y;
        n--;
        x--;
    }

    cout << ans;
}


#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
int main(){
  double n,ans=0; cin >> n;
  for(int i=1; i<n; i++){
    ans += n/i;
  }
  cout << fixed << setprecision(15) << ans << endl;
}

#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
// include
#include <bits/stdc++.h>

using namespace std;

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
// change
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
// math
template <class T>
inline T sqr(T x) {
  return x * x;
}

template <class T>
inline T nCr(T n, T r) {
  T num = 1;
  for (int i = 1; i <= r; ++i) {
    num *= (n - i + 1) / i;
  }
  return num;
}
template <class T>
inline T nPr(T n, T r) {
  r = n - r;
  T sum = 1;
  int i;
  for (i = n; i >= r + 1; --i) sum *= i;
  return sum;
}

template <class T>
inline T facctorial(T k) {
  T sum = 1;
  for (int i = 1; i <= k; ++i) {
    sum *= i;
  }
  return sum;
}
// numeric
template <class T>
inline T gcd(T a, T b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
// using
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using PII = pair<int, int>;
using LL = int64_t;

// container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) static_cast<int>((a).size())
#define EACH(i, c) \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())

// repetition
#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int N;
  cin >> N;
  double ans = 0;
  for (int i = 1; i < N; i++) {
    ans += 1.0 * N / (N - i);
  }
  printf("%.10f\n", ans);

  return 0;
}


#pragma GCC optimize("Ofast")
//#pragma GCC target ("sse4")

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	if (n < 0) {
		ll res = mod_pow(x, -n, m);
		return mod_pow(res, m - 2, m);
	}
	if (abs(x) >= m)x %= m;
	if (x < 0)x += m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
modint operator/=(modint& a, modint b) { a = a / b; return a; }
const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[a - b];
}

void solve() {
	int n; cin >> n;
	int ans = mod;
	rep(i, n) {
		int a, p, x; cin >> a >> p >> x;
		if (a < x) {
			ans = min(ans, p);
		}
	}
	if (ans == mod)ans = -1;
	cout << ans << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(5);
	//init_f();
	//init();
	//expr();
	//int t; cin >> t; rep(i,t)
	solve();
	return 0;
}

#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class DisjointSet {
    public:
        DisjointSet(int n) : N(n), sz(n), pars(n, -1) {
        }
        void reset() { sz = N, fill(pars.begin(), pars.end(), -1); }
        int find(int x) { return pars[x] < 0 ? x : pars[x] = find(pars[x]); }
        int size() { return sz; }
        int count(int x) { return -pars[find(x)]; }
        bool unite(int x, int y) {
            x = find(x), y = find(y);
            if (x == y) { return false; }
            --sz;
            if (pars[x] < pars[y]) { swap(x, y); }
            pars[y] += pars[x];
            pars[x] = y;
            return true;
        }
    private:
        int N, sz;
        vector<int> pars;
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;

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

    long double eps = 1e-9;

    long double lo = 0, hi = 100;
    int rnd = 150;

    DisjointSet ds(n + 2);
    int s = n, t = n + 1;

    auto ok = [&](long double r) {
        ds.reset();
        for (int i = 0; i < n; ++i) {
            if (Y[i] - 2 * r - (-100) < eps) {
                ds.unite(i, s);
            }
            if (100 - (Y[i] + 2 * r) < eps) {
                ds.unite(i, t);
            }
        }

        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                auto d = hypot(X[i] - X[j], Y[i] - Y[j]);
                if (d <= 2 * r + eps) {
                    ds.unite(i, j);
                }
            }
        }
        return ds.find(s) != ds.find(t);
    };

    while (rnd-- > 0) {
        auto mi = (lo + hi) / 2;
        if (ok(mi)) {
            lo = mi;
        } else {
            hi = mi;
        }
    }
    cout << lo << '\n';
    return 0;
}


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

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

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

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

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

int main() {
    ll N, K;
    cin >> N >> K;
    vvc<ll> T(N, vl(N));
    rep(i, N) rep(j, N) cin >> T[i][j];
    vl A(N);
    iota(all(A), 0ll);

    ll ans = 0;
    do{
        if (A[0] != 0) continue;
        ll t = 0;
        rep(i, N - 1) t += T[A[i]][A[i + 1]];
        t += T[A[N - 1]][A[0]];

        if (t == K) ans++;
    } while (next_permutation(all(A)));
    cout << ans << endl;
}

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

template<typename T_first,typename T_second>
ostream& operator<<(ostream& os,const pair<T_first,T_second>& P){
    os<<"("<<P.first;
    os<<", "<<P.second;
    os<<")";
    return os;
}

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


#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n;
  int a;
  bool f=false;
  map<int,int> v;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    v[a]++;
    if(v[a]!=1) f=true;
  }
  if(f) cout<<"No\n";
  else cout<<"Yes\n";
}

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

//#define ordered_set tree<int, null_type, less<int >,rb_tree_tag, tree_order_statistics_node_update>
//using namespace __gnu_pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ll long long
#define ld long double
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define vii vector<int>
#define vll vector<ll>
#define clr(v, d) memset(v,d,sizeof(v))
using namespace std;
const int N = 2e5 + 9;

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

    int n;
    cin>>n;
    set<int>st;
    for (int i = 0; i < n; ++i) {
        int a;
        cin>>a;
        st.insert(a);
    }
    vector<int>v;
    v.assign(all(st));
    if(v.size()!=n||v[0]!=1)cout<<"No\n";
    else{
        for(int i=1;i<n;i++){
            if(v[i]-v[i-1]!=1)return cout<<"No\n",0;
        }
        cout<<"Yes\n";
    }

    return 0;
}


// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#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 rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define forn(i, n) rep(i, 0, n)
#define rof(i, n) per(i, n, 0)
#define forone(i, n) for (int i = 1; i <= (n); ++i)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define ff first
#define ss second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define int long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define setbits(x) __builtin_popcountll(x)
#define zerbefone(x) __builtin_ctzll(x)
#define pqb priority_queue<int>                               // maxheap
#define pqs priority_queue<int, vector<int>, greater<int>>    // minheap
#define piipqs priority_queue<pii, vector<pii>, greater<pii>> // minheap for pair<int,int>
#define piipqb priority_queue<pii>                            // maxheap for pair<int,int>
#define mod 1000000007   //1e9+7
#define mod1 998244353
#define inf 2000000000000000000 //2e18
#define PI  3.141592653589793238
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define meminf(a) memset(a, 0x7f, sizeof(a))
#define precise(x, y) fixed << setprecision(y) << x
#define FastIO                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
// #define oset  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 rng(61378913);
/* usage - just do rng() */

// *************************** Code Begins **************************** //

void solve()
{
   string str;
   cin>>str;
   reverse(all(str));
   forn(i,str.size())
    {
        if(str[i]=='6')
            str[i] = '9';
       else if (str[i] == '9')
           str[i] = '6';
    }
    cout<<str;
}

signed main()
{
    FastIO;
    int tt = 1;
    // cin >> tt;
    for (int i = 1; i <= tt; i++)
        solve();
}

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

const ll mod = 1e9 + 7;
const double Pi = 3.14159265358979;

int run_test(){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  for(int i = 0; i < s.length(); i++){
    if(s[i]=='6'){
      s[i]='9';
    }
    else if(s[i] == '9'){
      s[i]='6';
    }
  }
  cout << s;
  return 0;
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int tt;
  tt = 1;
  while(tt--){
    run_test();
  }
}


#include <bits/stdc++.h>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
#define rep(i,n) for(int  i=0;i<n;i++)
using ll = long long;
int main() {
    int N;
    cin>>N;
    N*=1.08;
    if(N<206)cout<<"Yay!"<<endl;
    else if(N==206)cout<<"so-so"<<endl;
    else cout<<":("<<endl;
}

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <regex>

#define Debug cout << "line: " << __LINE__ << "Debug" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;
#define ALL(a) (a).begin(), (a).end()
#define MP make_pair
#define MOD 1000000007
#define PI 3.14159265358979323846

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vd = vector<double>;
using vl = vector<long long>;

void set_FPD(int n){
    cout << fixed << setprecision(n);
    return;
}

void Main(){
    int n;
    cin>>n;
    if(floor(n*1.08)<206) cout<<"Yay!"<<endl;
    else if(floor(n*1.08)>206) cout<<":("<<endl;
    else cout<<"so-so"<<endl;
    return;
}

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


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,tune=native")

#define ll long long
#define int ll
#define ull unsigned ll
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
//#define inf 1010000000
#define inf 4000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(vector<T> x){for(auto i: x) cerr << i << ' ';cerr << "\n";}
template<typename T> void _do(set<T> x){for(auto i: x) cerr << i << ' ';cerr << "\n";}
template<typename T> void _do(T && x) {cerr << x << endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr << x << ", "; _do(y...);}
#else
#define bug(...) 826
#endif
template<typename T> void print(T && x) {cout << x << "\n";}
template<typename T, typename... S> void print(T && x, S&&... y) {cout << x << ' ';print(y...);}

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
const int maxn=505;

//i_am_noob
#define wiwihorz
int n,a[maxn];
vector<int> res;

void op(int x){
    if((x+sz(res))&1){
        bug(x,sz(res));
    }
    if(sz(res)==60604) bug(x);
    assert((x+1+sz(res))&1);
    res.pb(x+1);
    swap(a[x],a[x+1]);
}

void report(){
    print(sz(res));
    for(auto i: res) print0(i);
    cout << "\n";
}

void orzck(){
    res.clear();
    cin >> n;
    rep(n) cin >> a[i];
    rep(n) a[i]--;
    if(n<=3){
        while(!is_sorted(a,a+n)){
            if(sz(res)&1) op(1);
            else op(0);
        }
        report();
        return;
    }
    rep3(i,n-1,4){
        int pos;
        rep1(j,n) if(a[j]==i) pos=j;
        if((pos+sz(res))&1){
            if(sz(res)&1) op(pos==2?3:1);
            else op(pos==1?2:0);
        }
        rep2(j,pos,i) op(j);
    }
    bug(sz(res));
    rep(n) bug(a[i]);
    int pos;
    if(sz(res)&1) op(1);
    rep(4) if(a[i]==3) pos=i;
    if((pos+1+sz(res))&1){
        rep2(i,pos,3) op(i);
    }
    else if(pos<3){
        op(2);
        rep2(i,pos,3) op(i);
    }
    rep(n) bug(a[i]);
    while(!is_sorted(a,a+n)){
        if(sz(res)&1) op(1);
        else op(0);
    }
    assert(is_sorted(a,a+n));
    report();
}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    #ifdef i_am_noob
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    freopen("output2.txt","w",stderr);
    #endif
    cout << fixed << setprecision(15);
    int t;
    #ifdef wiwihorz
    cin >> t;
    #else
    t=1;
    #endif
    while(t--) orzck();
    return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
#define x first
#define y second
const int N = 2e5 + 10;

int a[N], res[N], pos[N];

void Swap(int p, int &idx) {
	swap(pos[a[p]], pos[a[p + 1]]);
	swap(a[p], a[p + 1]);
	res[idx++] = p;
}

void solve() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		pos[a[i]] = i;
	}
	int idx = 1;
	for(int i = n; i >= 1; i--) {
		if(a[i] == i) continue;
		while(idx % 2 != pos[i] % 2) {
			if(idx & 1) Swap(1, idx);
			else Swap(2, idx);
		}
		while(pos[i] != i) {
			Swap(pos[i], idx);
		}
	}
	printf("%d\n", idx - 1);
	for(int i = 1; i < idx; i++) {
		printf("%d ", res[i]);
	}
	puts("");
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int t; cin >> t; while(t--)
    solve();
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cctype>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <ctime>
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
inline int read_int(){
	int t=0;bool sign=false;char c=getchar();
	while(!isdigit(c)){sign|=c=='-';c=getchar();}
	while(isdigit(c)){t=(t<<1)+(t<<3)+(c&15);c=getchar();}
	return sign?-t:t;
}
inline LL read_LL(){
	LL t=0;bool sign=false;char c=getchar();
	while(!isdigit(c)){sign|=c=='-';c=getchar();}
	while(isdigit(c)){t=(t<<1)+(t<<3)+(c&15);c=getchar();}
	return sign?-t:t;
}
inline char get_char(){
	char c=getchar();
	while(c==' '||c=='\n'||c=='\r')c=getchar();
	return c;
}
inline void write(LL x){
	char c[21],len=0;
	if(!x)return putchar('0'),void();
	if(x<0)x=-x,putchar('-');
	while(x)c[++len]=x%10,x/=10;
	while(len)putchar(c[len--]+48);
}
inline void space(LL x){write(x),putchar(' ');}
inline void enter(LL x){write(x),putchar('\n');}
const int MAXN=3005,Mod=998244353;
int dp[MAXN][MAXN];
int dfs(int n,int k){
	if(k>n)return 0;
	if(n==0||k==0)return n==0&&k==0;
	if(~dp[n][k])return dp[n][k];
	return dp[n][k]=(dfs(n-1,k-1)+dfs(n,k<<1))%Mod;
}
int main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	int n=read_int(),k=read_int();
	mem(dp,-1);
	enter(dfs(n,k));
	return 0;
}

#include <stdio.h>
#include <bits/stdc++.h>
#define ll long long int
#define inf 1000000000000
#define mod 998244353
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define ps(x, y) fixed << setprecision(y) << x
using namespace std;

void solve()
{
	ll n, kl;
	cin >> n >> kl;
	vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));
	dp[1][1] = 1;
	for(int i=2;i<=n;i++)
	{
		for(int k=i;k>=1;k--)
		{
			dp[i][k] = (dp[i][k] + dp[i - 1][k - 1] + (2 * k <= i ? dp[i][2 * k] : 0)) % mod;
		}
	}
	cout << dp[n][kl] << endl;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	int t = 1;
	// cin>>t;
	while (t--)
	{
		solve();
	}
}


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

int main(){
	int n; cin>>n;
	int cnt=1000000001;
	rep(i,n){
		int a,p,x; cin>>a>>p>>x;
		if(x-a>0) cnt=min(cnt,p);
	}
	if(cnt!=1000000001) cout<<cnt<<endl;
	else cout<<-1<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
#define lowbit(x) (x&-x)
#define reg register
#define mkpr make_pair
#define fir first
#define sec second
typedef long long LL;
typedef unsigned long long uLL;
const int INF=0x3f3f3f3f;
const int mo=998244353;
const LL jzm=2333;
const int iv2=499122177;
const double Pi=acos(-1.0);
typedef pair<int,int> pii;
const double PI=acos(-1.0);
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=getchar();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=getchar();}
	while('0'<=s&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=getchar();}
	x*=f;
}
template<typename _T>
void print(_T x){if(x<0){x=(~x)+1;putchar('-');}if(x>9)print(x/10);putchar(x%10+'0');}
int n,minn;
struct ming{int a,p,x;}s[MAXN];
signed main(){
	read(n);minn=INF;
	for(int i=1;i<=n;i++)read(s[i].a),read(s[i].p),read(s[i].x);
	for(int i=1;i<=n;i++)if(s[i].x>s[i].a)minn=min(s[i].p,minn);
	if(minn>INF-1)puts("-1");else printf("%d\n",minn);
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long  int ll;
typedef long double db;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

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

int main() {
	// your code goes here
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;

	cin >> n;
	ll a[n], b[n];
	ll p[n];
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) {
		cin >> p[i];
		p[i]--;
	}
	ll flg = 0;
	rep(i, n) {
		if (a[i] <= b[p[i]] && p[i] != i)flg = 1;
	}
	if (flg) cout << "-1";
	else {
		v<pll> vec;
		rep(i, n) {
			vec.eb(a[i], i);
		}
		sortv(vec);
		map<ll, ll> ma;
		rep(i, n) {
			ma[p[i]] = i;
		}
		v<pll> out;
		for (auto u : vec) {
			x = ma[u.se];
			if (x == u.se) continue;
			else {
				ma[p[u.se]] = x;
				ma[p[x]] = u.se;
				swap(p[x], p[u.se]);
				out.eb(u.se + 1, x + 1);
			}
		}
		cout << out.size() << '\n';
		for (auto u : out) cout << u.fi << ' ' << u.se << '\n';
	}

	return 0;

}

#include<bits/stdc++.h>
using namespace std;
namespace Sakurajima_Mai{
    #define ms(a) memset(a,0,sizeof(a))
    #define repi(i,a,b) for(int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ?
    #define repd(i,a,b) for(int i=a,bbb=b;i>=bbb;--i)
    #define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
    #define ce(i,r) i==r?'\n':' '
    #define pb push_back
    #define all(x) x.begin(),x.end()
    #define gmn(a,b) a=min(a,b)
    #define gmx(a,b) a=max(a,b)
    #define fi first
    #define se second
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double db;
    const int infi=2e9;//infi较大，注意涉及inf相加时爆int
    const ll infl=4e18;
    inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }
    inline ll pos_mod(ll a,ll b){ return (a%b+b)%b; }
    //std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));
}
using namespace Sakurajima_Mai;
namespace Fast_Read{
    inline int qi(){
        int f=0,fu=1; char c=getchar();
        while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
        while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
        return f*fu;
    }
    inline ll ql(){
        ll f=0;int fu=1; char c=getchar();
        while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
        while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
        return f*fu;
    }
    inline db qd(){
        char c=getchar();int flag=1;double ans=0;
        while((!(c>='0'&&c<='9'))&&c!='-') c=getchar();
        if(c=='-') flag=-1,c=getchar();
        while(c>='0'&&c<='9') ans=ans*10+(c^48),c=getchar();
        if(c=='.'){c=getchar();for(int Bit=10;c>='0'&&c<='9';Bit=(Bit<<3)+(Bit<<1)) ans+=(double)(c^48)*1.0/Bit,c=getchar();}
        return ans*flag;
    }
}
namespace Read{
    #define si(a) scanf("%d",&a)
    #define sl(a) scanf("%lld",&a)
    #define sd(a) scanf("%lf",&a)
    #define ss(a) scanf("%s",a)
    #define rai(x,a,b) repi(i,a,b) x[i]=qi()
    #define ral(x,a,b) repi(i,a,b) x[i]=ql()
}
namespace Out{
    #define pi(x) printf("%d",x)
    #define pl(x) printf("%lld",x)
    #define ps(x) printf("%s",x)
    #define pc(x) printf("%c",x)
    #define pe() puts("")
}
namespace DeBug{
    #define MARK false
    #define DB if(MARK)
    #define pr(x) cout<<#x<<": "<<x<<endl
    #define pra(x,a,b) cout<<#x<<": "<<endl; \
            repi(i,a,b) cout<<x[i]<<" ";     \
            puts("");
    #define FR(a) freopen(a,"r",stdin)
    #define FO(a) freopen(a,"w",stdout)
}
using namespace Fast_Read;
using namespace Read;
using namespace Out;
using namespace DeBug;
const int MAX_N=2e5+5;
const int mod=1e9+7;
char s[MAX_N];
int n,num[MAX_N],k;
int dp[MAX_N][17];
int main()
{
    ss(s+1),si(k);
    n=strlen(s+1);
    repi(i,1,n) num[i]=isdigit(s[i])?s[i]-'0':s[i]-'A'+10;
    int sta=0;
    repi(i,0,n-1){
        repi(j,1,16){
            dp[i+1][j]=(1ll*dp[i+1][j]+1ll*dp[i][j]*j%mod)%mod;
            dp[i+1][j+1]=(1ll*dp[i+1][j+1]+1ll*dp[i][j]*(16-j)%mod)%mod;
        }
        dp[i+1][1]=(1ll*dp[i+1][1]+1ll*dp[i][0]*15%mod)%mod;
        dp[i+1][0]=1;
        repi(j,0,num[i+1]-1)if(i||j){
            int nxt=sta|1<<j;
            dp[i+1][__builtin_popcount(nxt)]++;
        }
        sta|=1<<num[i+1];
    }
    pl(pos_mod(dp[n][k]+(__builtin_popcount(sta)==k),mod)),pe();
    return 0;
}


/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */
#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

using ld=long double;
const ld PI = acos((ld)-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) ld d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<ld, ld>;
using vd= vector<ld>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

void solve() {
    cini(a);
    cini(b);
    cini(c);
    cini(d);

    int ans=b-c;
    cout<<ans<<endl;
}

signed main() {
    solve();
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << b - c << endl;
return 0;
}


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

#define int long long
#define mod 1000000007
#define pb push_back
#define ss second
#define ff first
#define all(v) v.begin(), v.end()
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

int32_t main() {

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

    int n,k;
    cin >> n >> k;
    vector<pair<int,int>> v(k);

    for(int i = 0; i < k; ++i)
        cin >> v[i].ff >> v[i].ss;

    sort(all(v));

    set<int> can;
    can.insert(n);

    for(int i = 0; i < k;) {
        vector<int> rem,add;
        int temp = v[i].ff;

        while(i < k && v[i].ff == temp) {
            int l = can.count(v[i].ss - 1);
            int r = can.count(v[i].ss + 1);

            if(l + r == 0)
                rem.push_back(v[i].ss);
            else add.pb(v[i].ss);

            i++;
        }

        for(int j: rem)
            can.erase(j);

        for(int j: add)
            can.insert(j);
    }

    cout << can.size();

    return 0;
}

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

struct P {
    bool operator<(const P &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }
    int x, y;
};

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

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

    int l = m + 1;

    vector<P> p;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        y += l - n;
        if (!(0 <= y && y <= l * 2)) continue;

        p.push_back({ x, y });
    }
    sort(p.begin(), p.end());

    vector<int> c(l * 2 + 1, 0);
    c[l] = 1;
    int x0 = -10, y0 = -10, c0 = -10;
    for (const auto &[x, y] : p) {
        int c1 = (x0 == x && y0 == y - 1) ? c0 : c[y - 1];
        x0 = x;
        y0 = y;
        c0 = c[y];
        c[y] = c1 | c[y + 1];
    }

    int r = 0;
    for (const auto &i : c) {
        r += i;
    }
    cout << r << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int _ = (cout << fixed << setprecision(9), cin.tie(0), ios::sync_with_stdio(0));
using Int = long long;
int main() {
    Int N; cin >> N;
    const int M = 44;
    vector<Int> X(M), Y(M);
    for (int i = 0; i < M; i++) {
        // X = X + 1
        X[i] = 1;
        if (i + 1 == M) break;
        // Y = X + Y
        for (int j = 0; j < M; j++) {
            Y[j] += X[j];
        }
        // X = X + Y
        for (int j = 0; j < M; j++) {
            X[j] += Y[j];
        }
    }
    vector<Int> A(M);
    for (int i = 0; i < M; i++) {
        while (X[i] <= N) {
            A[i]++;
            N -= X[i];
        }
    }
    vector<int> op;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < A[i]; j++) {
            op.push_back(1);
        }
        if (i + 1 == M) break;
        op.push_back(4);
        op.push_back(3);
    }
    cout << op.size() << '\n';
    for (auto x : op) cout << x << '\n';
    return 0;
}

#include <bits/stdc++.h>

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

template<int mod>
struct ModInt{
	int x;
	ModInt () : x(0) {}
	ModInt (int64_t x) : x(x >= 0 ? x % mod : (mod - -x % mod) % mod) {}
	ModInt &operator += (const ModInt &p){
		if ((x += p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt &operator -= (const ModInt &p) {
		if ((x += mod - p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt &operator *= (const ModInt &p) {
		x = (int64_t) x * p.x % mod;
		return *this;
	}
	ModInt &operator /= (const ModInt &p) {
		*this *= p.inverse();
		return *this;
	}
	ModInt &operator ^= (int64_t p) {
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator - () const { return ModInt(-x); }
	ModInt operator + (const ModInt &p) const { return ModInt(*this) += p; }
	ModInt operator - (const ModInt &p) const { return ModInt(*this) -= p; }
	ModInt operator * (const ModInt &p) const { return ModInt(*this) *= p; }
	ModInt operator / (const ModInt &p) const { return ModInt(*this) /= p; }
	ModInt operator ^ (int64_t p) const { return ModInt(*this) ^= p; }
	bool operator == (const ModInt &p) const { return x == p.x; }
	bool operator != (const ModInt &p) const { return x != p.x; }
	explicit operator int() const { return x; }
	ModInt &operator = (const int p) { x = p; return *this;}
	ModInt inverse() const {
		int a = x, b = mod, u = 1, v = 0, t;
		while (b > 0) {
			t = a / b;
			a -= t * b;
			std::swap(a, b);
			u -= t * v;
			std::swap(u, v);
		}
		return ModInt(u);
	}
	friend std::ostream & operator << (std::ostream &stream, const ModInt<mod> &p) {
		return stream << p.x;
	}
	friend std::istream & operator >> (std::istream &stream, ModInt<mod> &a) {
		int64_t x;
		stream >> x;
		a = ModInt<mod>(x);
		return stream;
	}
};
typedef ModInt<1000000007> mint;

template<int mod> struct MComb {
	using mint = ModInt<mod>;
	std::vector<mint> fact;
	std::vector<mint> inv;
	MComb (int n) { // O(n + log(mod))
		fact = std::vector<mint>(n + 1, 1);
		for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * mint(i);
		inv.resize(n + 1);
		inv[n] = fact[n] ^ (mod - 2);
		for (int i = n; i--; ) inv[i] = inv[i + 1] * mint(i + 1);
	}
	mint ncr(int n, int r) {
		return fact[n] * inv[r] * inv[n - r];
	}
	mint npr(int n, int r) {
		return fact[n] * inv[n - r];
	}
	mint nhr(int n, int r) {
		assert(n + r - 1 < (int) fact.size());
		return ncr(n + r - 1, r);
	}
};

int main() {
	int64_t n;
	std::cin >> n;
	int T = 87;
	int64_t fib[T];
	fib[0] = fib[1] = 1;
	for (int i = 2; i < T; i++) fib[i] = fib[i - 1] + fib[i - 2];

	std::vector<int> demand;
	for (int i = T; i--; ) {
		if (n >= fib[i]) n -= fib[i], demand.push_back(i);
	}

	int top = demand.front();
	demand.erase(demand.begin());

	std::vector<int> res;
	for (int i = 0; i <= top; i++) {
		int command;
		if (i == 0) command = 1;
		else if (i == 1) command = 2;
		else command = ((top ^ i) & 1) ? 4 : 3;

		res.push_back(command);
		if (std::count(demand.begin(), demand.end(), top - i)) res.push_back(command == 4 ? 2 : 1);
	}

	printf("%d\n", (int) res.size());
	for (auto i : res) printf("%d\n", i);

	/*
	int64_t x = 0;
	int64_t y = 0;
	for (auto i : res) {
		if (i == 1) x++;
		else if (i == 2)y++;
		else if (i == 3) x += y;
		else y += x;
	}
	printf("%" PRId64 " %" PRId64 "\n", x, y);*/

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=111;
int n,vis[N][N],now,sum[N];
char a[N][N];
void dfs(int x){sum[x]++;vis[now][x]=1;
	for(int i=1;i<=n;i++){if(a[x][i]=='1'&&!vis[now][i])
		dfs(i);
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++)now=i,dfs(i);double ans=0;
	for(int i=1;i<=n;i++){
		ans+=1.0/sum[i];
	}printf("%.10lf",ans);
}

#include<bits/stdc++.h>
using namespace std;
const int N = 100;
char mat[N][N];
int n;
int tout[N];
bool used[N];
int timer = 0;
int colored[N];
int c = 0;
set <int> g[N];
int _sz[N], _sz1[N];
void dfs(int v)
{
    used[v] = 1;
    for(int i = 0; i < n; i++)
    {
        if(mat[v][i] == '1' && !used[i])
        {
            dfs(i);
        }
    }
    tout[v] = timer++;
}
void dfs1(int v)
{
    colored[v] = c;
    used[v] = 1;
    _sz[c]++;
    for(int i = 0; i < n; i++)
    {
        if(mat[i][v] == '1' && !used[i])
        {
            dfs1(i);
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            cin >> mat[i][j];
        }
    }
    for(int i = 0; i < n; i++)
    {
        if(!used[i])
        {
            dfs(i);
        }
    }
    vector <pair <int, int> > mass;
    for(int i = 0; i < n; i++)
    {
        used[i] = 0;
        mass.push_back({tout[i], i});
    }
    sort(mass.begin(), mass.end());
    for(int i = mass.size() - 1; i >= 0; i--)
    {
        int v = mass[i].second;
        if(used[v])
        {
            continue;
        }
        dfs1(v);
        c++;
    }
    set <int> g1[N];
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            if(mat[i][j] == '1')
            {
                g[colored[i]].insert(colored[j]);
                g1[colored[j]].insert(colored[i]);
            }
        }
    }
    double ans = 0;
    for(int i = 0; i < c; i++)
    {
        for(int j = 0; j < c; j++)
        {
            used[j] = 0;
        }
        queue <int> q;
        q.push(i);
        used[i] = 1;
        int _sz2 = 0;
        while(q.size() != 0)
        {
            int v = q.front();
            q.pop();
            if(v != i)
            {
                _sz2 += _sz[v];
            }
            set <int> :: iterator it;
            for(it = g1[v].begin(); it != g1[v].end(); it++)
            {
                if(!used[*it])
                {
                    used[*it] = 1;
                    q.push(*it);
                }
            }
        }
        double pw = 1;
        for(int j = 0; j <= n - _sz2 - _sz[i]; j++)
        {
            ans += pw * _sz[i] * 1.0 / (n - j);
            pw = pw * (n - j - _sz[i] - _sz2) * 1.0 / (n - j);
        }
    }
    cout << fixed << setprecision(10) << ans;
    return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define fb(i,b,a) for(int i=b;i>=a;i--)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 200005;
const ll inf = 1e18 + 5;

int n, m;

ll a[maxn];
ll b[maxn];

ll pref[maxn];
ll sufi[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    cin >> n >> m;
    ff(i,1,n)cin >> a[i];
    ff(i,1,m)cin >> b[i];
    sort(a + 1, a + n + 1);
//    cout << endl;
//    ff(i,1,n)cout << a[i] << " ";
//    cout << endl;
//    cout << endl;
    ff(i,1,n)pref[i] = pref[i - 1] + (i % 2 == 1 ? -a[i] : a[i]);
    fb(i,n,1)sufi[i] = sufi[i + 1] + (i % 2 == 1 ? a[i] : -a[i]);
//    ff(i,1,n)cout << pref[i] << " ";
//    cout << endl;
//    ff(i,1,n)cout << sufi[i] << " ";
//    cout << endl;
    ll rez = inf;
    ff(i,1,m){
        ll x = b[i];
        int l = 1, r = n, ans = 0;
        while(l <= r){
            int mid = (l + r) / 2;
            if(a[mid] <= x){
                ans = mid;
                l = mid + 1;
            }
            else r = mid - 1;
        }
//        cout << "ans: " << ans << endl;
        ans += (ans % 2 == 0);
        ll kol = pref[ans - 1] + abs(x - a[ans]) + sufi[ans + 1];
//        cout << "kol: " << kol << endl;
        rez = min(rez, kol);
    }
    cout << rez << endl;
    return 0;
}
/**

// probati bojenje sahovski ili slicno

**/

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#define debug(...) fprintf(stderr, __VA_ARGS__);
#define rep(i, j, k) for(int i = j; i <= k; ++ i)
#define per(i, j, k) for(int i = j; i >= k; -- i)
using namespace std;

#define fs first
#define sc second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;

const int N = 4e5 + 10;
const int mod = 1e9 + 7;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 Rand(seed);
uniform_int_distribution<ll> ran(0, 1ll << 62);
void ucin() {
  ios::sync_with_stdio(0); cin.tie(0);
}
// uniform_real_distribution<double> dbran;
template<class T> inline void chkmax(T &x, const T &y) { if(x < y) x = y; }
template<class T> inline void chkmin(T &x, const T &y) { if(x > y) x = y; }

inline ll sqr(ll x) { return x * x; }
inline ll cub(ll x) { return x * x * x; }

int main() {
  ucin();
  int n, s, d, ans = 0;
  cin >> n >> s >> d;
  rep(i, 1, n) {
    int x, y;
    cin >> x >> y;
    if(x < s && y > d) {
      ans = 1;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


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

#include<cstdio>
#include<cstring>

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

int N, M;
int to[400005], ne[400005], c[200005], he[100001];
int kotae[100001];

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int MAX = 1000;
class shuturyoku_unko {
public:
	char C[MAX * 4];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 3) {
				C[i * 4 + 2 - j] = '0' + X % 10;
				X /= 10;
			}
			C[i * 4 + 3] = ' ';
		}
	}
};
constexpr shuturyoku_unko f;
const int dm = 1 << 17;
char* dn = cn, * di = dn, * owad = dn + dm - 20;
void putint(int A) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	if (A >= 1000) {
		int dig = 1;
		if (A >= 100000) dig = 3;
		else if (A >= 10000) dig = 2;
		memcpy(di, f.C + A / 1000 * 4 + 3 - dig, dig);
		memcpy(di + dig, f.C + A % 1000 * 4, 4);
		di += dig + 4;
	}
	else {
		int dig = 1;
		if (A >= 100) dig = 3;
		else if (A >= 10) dig = 2;
		memcpy(di, f.C + A * 4 + 3 - dig, dig + 1);
		di += dig + 1;
	}
}

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

	N = getint();
	M = getint();

	int k = 2;
	rep1(i, M) {
		int u = getint(), v = getint();
		c[i] = getint();
		to[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		to[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	int Q[100001], q = 0;
	Q[q++] = 1;
	kotae[1] = 1;
	while (q) {
		int tmp = Q[--q];
		int oya = kotae[tmp];
		for (int k = he[tmp]; k; k = ne[k]) {
			int t = to[k];
			if (!kotae[t]) {
				int e = c[k >> 1];
				kotae[t] = e + (oya == e);
				Q[q++] = t;
			}
		}
	}

	rep1(i, N) putint(kotae[i] - ((kotae[i] > N) << 1));
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep0(i, n) for (ll i = 0; i <= (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep1(i, n) for (ll i = (n); i > 0; --i)
#define rrep0(i, n) for (ll i = (n); i >= 0; --i)
#define srep(i, s, t) for (ll i = s; i < t; ++i)
#define srep1(i, s, t) for (ll i = s; i <= t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define snuke srand((unsigned)clock() + (unsigned)time(NULL));
#define show(x) cerr << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
constexpr ll MAX = 200002;

int main()
{
    ll n;
    cin >> n;
    vl a(MAX, 0);
    ll b = 0, maxb = 0, sum = 0, ans = 0;
    rep1(i, n) cin >> a[i];
    rep1(i, n)
    {
        b += a[i];
        maxb = max(maxb, b);
        ans = max(ans, sum + maxb);
        sum += b;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    double n , d , h;
    cin >> n >> d >> h ;
    vector<double> D(n) , H(n) ;
    double a = h / d ;
    double ans = 0 ;
    rep(i,n){
        cin >> D[i] >> H[i] ;
        if( a *(d - D[i]) > h - H[i]   ){
            a = ( h - H[i] ) / ( d - D[i] ) ;
            ans = h - d * a ;
        }
    }
    cout << ans << endl ;
}

//a.9
#include<bits/stdc++.h>
#define ll long long
#define all(x) x.begin(),x.end()
#define CASE(t) cout<<"Case #"<<(t)<<": ";
#define endll endl
#define endl '\n'
#define mod 1000000007
#define INF 1e18
#define maxN 500005
#define deb(x) cout << "[" << (#x) << "=" << x << "]" << '\n'
#define deb2(x,y) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "]" << '\n'
#define deb3(x,y,z) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "] [" << (#z) << "=" << z << "]" << '\n'
#define popcnt __builtin_popcountll
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
ll ceill(ll a,ll b){return a/b+bool(a%b);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b, a % b);}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll power(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x)%mod;x=(x*x)%mod;y>>=1;}return res;}
void bin(unsigned n,string &str){str="";if(n>1)bin(n>>1,str);str+=to_string(n&1);}
bool isPrime(ll n)
{
    if(n<=1)return false;if(n<=3)return true;if(n%2==0 || n%3==0)return false;
    for(ll i=5;i*i<=n;i=i+6)if(n%i==0 || n%(i+2)==0) return false; return true;
}
vector<ll> primeFactors(ll n)
{
    vector<ll>vec;
    while(n%2==0)vec.push_back(2),n/=2;
    for(ll i=3;i<=sqrt(n);i+=2)while(n%i==0)vec.push_back(i),n/=i;
    if(n>2)vec.push_back(n);
    return vec;
}
vector<ll>primes;
void SieveOfEratosthenes()
{
    bool prime[maxN];primes.clear();
    memset(prime, true, sizeof(prime));
    for(ll i=2;i*i<maxN;i++)if(prime[i]==true)for(ll j=i*i;j<maxN;j+=i)prime[j]=false;
    for(ll i=2;i<maxN;i++)if(prime[i])primes.push_back(i);
}
//vector<ll>fact(maxN);
//void factpre(){fact[0]=1;for(ll i=1;i<maxN;i++)fact[i]=(fact[i-1]*1LL*i);}
//ll mul(ll a,ll b){return (a*1LL*b)%mod;}
//ll nCr(ll n,ll k){return mul(fact[n],power(mul(fact[k],fact[n-k]),mod-2));}
void solve()
{
    double n,d,h;cin>>n>>d>>h;
    double ans=0;
    for(double i=0;i<n;i++)
    {
        double di,hi;cin>>di>>hi;
        double tmp=(d*double(hi)-double(di)*h)/double(d-di);
        ans=max(ans,tmp);
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
}
signed main()
{
    ios;
    ll tc=1; //cin>>tc;
    for(ll t=1;t<=tc;t++)
    {
        //CASE(t);
        solve();
    }
}


// clang-format off
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()

using namespace std;
using namespace __gnu_pbds;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
// clang-format on

int main() {
    fastio();

    int n;
    cin >> n;

    cout << (n % 2 ? "Black" : "White") << endl;

    return 0;
}

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

using namespace std;

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

    long long ret = 1;
    for (long long i = 2; i <= n; i++)ret = ret * i / __gcd(ret, i);

    cout << ret + 1 << endl;
    return 0;
}