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

#define ln  "\n"

void solve(int input)
{
	int a, b;
	cin >> a >> b;
	int r = abs(a - b);
	if (r <= 2)
	{
		cout << "Yes";
	}
	else
		cout << "No";
	return;

}

signed main()
{
	int t = 1;
	while (t--)
	{
		solve(t);
	}
	return 0;
}

#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 9;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

int main()
{
  KAKA
  ll x,y;
  cin>>x>>y;
  if((llabs)(x - y) < 3) cout<<"Yes"<<"\n";
  else cout<<"No"<<"\n";
}


#include <bits/stdc++.h>

using namespace std;
const int c=200002;
long long kom[c], a[c], sok=1e16, nagymax=-sok, kismin=sok;
int n, q, t[c];
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> a[i] >> t[i];
        kom[i]=kom[i-1];
        if (t[i]==1) {
            kom[i]+=a[i];
        } else {
            a[i]-=kom[i];
            if (t[i]==2) {
                nagymax=max(nagymax, a[i]);
                kismin=max(kismin, nagymax);
            }
            if (t[i]==3) {
                kismin=min(kismin, a[i]);
                nagymax=min(nagymax, kismin);
            }
        }
    }
    cin >> q;
    for (int i=1; i<=q; i++) {
        long long x; cin >> x;
        cout << max(min(x, kismin), nagymax)+kom[n] << "\n";
    }
    return 0;
}

//#define MULTIPLE_TESTS 0
#include "bits/stdc++.h"
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template<typename T> using policy_set = tree<T, null_type, less < T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
struct mul {
    int m;
    mul(int m) : m(m) {}
    int operator()(int a, int b) { return 1ll * a * b % m; }
};
int identity_element(mul) { return 1; }
#define fastpower(a, b, m) power(a,b,mul(m))
#define endl '\n'
#define F first
#define S second
#define all(v) (v).begin(), (v).end()
#define SZ(v) int((v).size())
const int N = 2e5 + 7, M = 2 * N, MOD = 1e9 + 7, OO = 0x3f3f3f3f;

int n, m, a[N], t[N], x[N], sorted[N];
ll ans[N];
void MAIN(int tc = 0) {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
        scanf("%d", t + i);
    }
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) {
        scanf("%d", x + i);
    }
    iota(sorted, sorted + m, 0);
    sort(sorted, sorted + m, [](int i, int j) {
        return x[i] < x[j];
    });
    ll plus = 0;
    vector <pair<ll, int>> y;
    for (int i = 0; i < m; ++i) {
        y.emplace_back(x[sorted[i]], 1);
    }
    int st = 0, en = m - 1;
    for (int i = 0; i < n; ++i) {
        if (t[i] == 1) {
            plus += a[i];
        }
        else if (t[i] == 2) {//max
            int j;
            int cnt = 0;
            for (j = st; j <= en && y[j].F+plus < a[i]; ++j) cnt += y[j].S;
            if (cnt)
                y[j - 1] = {a[i]-plus, cnt}, st = j - 1;
        }
        else if (t[i] == 3) {//min
            int j;
            int cnt = 0;
            for (j = en; j >= st && y[j].F+plus > a[i]; --j) cnt += y[j].S;
            if (cnt)
                y[j + 1] = {a[i]-plus, cnt}, en = j + 1;
        }
    }
    int i = 0;
    for(int j = st; j <= en; ++j){
        ll cur = y[j].F;
        int cnt = y[j].S;
        while(cnt--) {
            ans[sorted[i++]] = cur + plus;
        }
    }
    for (int i = 0; i < m; ++i) {
        printf("%lld\n", ans[i]);
    }
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef CLION
    freopen("in", "rt", stdin);
#endif
#ifdef MULTIPLE_TESTS
    int nTests;
#if MULTIPLE_TESTS == 0
    scanf("%d", &nTests);
#else
    cin >> nTests;
#endif
    for (int tc = 1; tc <= nTests; ++tc) {
        MAIN(tc);
    }
#else
    MAIN();
#endif

}


#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ll long long
#define ull unsigned long long
#define ld long double
#define mx 300005
#define mod 1000000007
#define fr first
#define cti(a) (a-48)
#define itc(a) char(a+48)
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }

ll a[mx],tree[4*mx],lazy[4*mx];

ll Merge(ll lft, ll rgt)
{
    return lft^rgt;
}

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

ll Query(ll node, ll b, ll e, ll i, ll j)
{
    //relax(node,b,e);
    if(i>e || j<b)return 0;
    if(b>=i && e<=j)return tree[node];

    ll mid=(b+e)/2;
    ll left=node*2;
    ll right=left+1;
    ll p=Query(left,b,mid,i,j);
    ll q=Query(right,mid+1,e,i,j);
    return Merge(p,q);
}

void clr() { memo(tree, 0), memo(lazy, 0), memo(a, 0); }

void solve(int kk)
{
    clr();
    int n,q;
    scanf("%d %d", &n, &q);
    for(int i=1; i<=n; i++){
        scanf("%lld", &a[i]);
        update(1, 1, n, i, a[i]);
    }

    //printf("Case %d:\n", kk);

    while(q--){
        int aa,bb,cc;
        ll val;
        scanf("%d %d %d", &aa, &bb, &cc);
        if(aa == 1){
            update(1, 1, n, bb, cc);
        }
        else printf("%lld\n", Query(1,1,n,bb,cc));
    }

}

int main()
{
   //fast;
   int t=1,kk=0;
   //scanf("%d", &t);
   while(++kk<=t) solve(kk);

   return 0;
}

/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
const int BIT_NUM = 20;
struct BIT{
    int _n;
    long long _d[1 << BIT_NUM];
    void init(int __n) {
        _n=__n;
        memset(_d, 0, sizeof(long long) * (_n+1));
    }
    void ins(int x, long long v) {
        for(; x <= _n; x += x & -x) { _d[x] ^= v; }
    }
    long long qq(int x) {
        if(x <= 0) {
            return 0;
        }
        long long res = 0;
        for(; x; x -= x & -x) { res ^= _d[x];}
        return res;
    }
    long long qq_range(int x, int y) {
        if(x > y) {
            return 0;
        }
        long long ret = qq(y);
        if(x)ret ^= qq(x-1);
        return ret;
    }
    long long k_th(int k){
        int now = 0;
        for(int i = BIT_NUM - 1; i >= 0; i--) {
            if(_d[now + (1 << i)] < k) {
                k -= _d[now + (1 << i)];
                now += 1 << i;
            }
        }
        return now + 1;
    }
}bit;
int N, Q;
void solve() {
    FOR(i, 1, Q) {
        int ty, x, y;
        R(ty, x, y);
        if(ty == 1) {
            bit.ins(x, y);
        } else {
            W(bit.qq_range(x, y));
        }
    }
}
void input() {
    R(N, Q);
    bit.init(N);
    FOR(i, 1, N) {
        int x;
        R(x);
        bit.ins(i, x);
    }
}
int main(){
    input();
    solve();
    return 0;
}


#include <bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace std;
//usin	g namespace __gnu_pbds;
//using namespace __gnu_cxx;
//template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

using namespace std;
#define go ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define ll long long
const int mxn = 2e5 + 5 , mod = 1e9 + 7 , MOD = 1e9 + 7 , mod2 = 998244353;
int n ;
vector<int>vi[mxn * 2];
int siz ;
bool ok ;
bool exist[mxn * 2] , vis[mxn * 2];
void dfs(int node, int par = -1){
	vis[node] = true;
	siz++;
	for(auto it : vi[node]){
		if(it == par)
			continue;
		if(vis[it])ok = true;
		if(!vis[it])
		dfs(it , node);
	}
}
void bingo(){
	cin>>n;
	map<int,int>mp;
	int mx = 0;
	for(int i =0 ;i < n ; i++){
		int u , v;
		cin>>u>>v;
		vi[u].push_back(v);
		vi[v].push_back(u);
		mx = max({mx , u , v});
		exist[u] = exist[v] = true;
	}
	int out = 0;
	for(int i = 1 ; i <= mx  ; i++){
		if(exist[i] && !vis[i] ){
			ok = false;
			siz = false ;
			dfs(i);
			if(ok)out += siz;
			else out += siz - 1;
		}
	}
	cout<<out;
}
int main() {
	go
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
//	freopen("output.in", "wt", stdout);
#endif
	int t = 1;
	//cin>>t;
	while(t--){
		bingo();
	}
	return 0;
}

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

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

    const int MX = 400000;

    int n;
    cin >> n;

    vector<vector<edge>>  g(MX, vector<edge>());
    unordered_set<int> color;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
        color.insert(a);
        color.insert(b);
    }

    vector<bool> vis(MX, false);

    auto is_tree = [&](auto self, int v, int i = -1) -> bool {
        // @return
        // true=木
        // false=サイクル
        bool ret = true;
        vis[v] = true;
        for (auto [u, j] : g[v]) {
            if (j == i) continue; // 訪問に用いた辺を逆にたどっている
            if (vis[u]) {
                ret = false;
                continue;
            }
            if (!self(self, u, j)) ret = false;
        }
        return ret;
    };

    int ans = (int)color.size();
    for (auto v : color) {
        if (vis[v]) continue;
        if (is_tree(is_tree, v)) ans--;
    }

    cout << ans << "\n"s;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
///////////////////////////
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<
long long,
null_type,
less<long long>,// _equal for multiset
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
///////////////////////////
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

const int N=2e5+8;
int h,w,m,cnt[N];
vector <int> v[N];
ordered_set con;

int32_t main(){
   ios;
   cin>>h>>w>>m;

   int mn=1e9;
   F(i,1,m){
   	int x,y;
   	cin>>x>>y;
   	if(x==1) mn=min(mn,y);
   	v[y].pb(x);
   	con.insert(x);
   	cnt[x]++;
   }

   //dummy obstacles
   if(mn<1e9){
   	F(j,mn+1,w){
   		con.insert(1);
   		v[j].pb(1);
   		cnt[1]++;
   	}
   }
   if(v[1].size()){
   	int id=*min_element(all(v[1]));
   	F(i,id+1,h){
   		con.insert(i);
   		cnt[i]++;
   	}
   }

   //subtracting unreachable points
   int ans=h*w;
   R(j,w,1){
   	if(v[j].size()==0) continue;
   	int id=*min_element(all(v[j]));
   	ans-=con.size()-con.order_of_key(id);
   	for(auto it:v[j]){
   		cnt[it]--;
   		if(cnt[it]==0) con.erase(it);
   	}
   }
   cout<<ans<<endl;
}

#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
void eras(map<int,int> &m,int x)
{
    m[x]--;
    if (!m[x])
        m.erase(x);
}
const int N=(int)3e5+100;
const int M=(int)2e6+100;
const int inf=(int)1e9+100;
#define filename ""

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int a,b,w,i;
    cin>>a>>b>>w;
    w*=1000;
    fr(i,1,1000001)
    {
        if (a*i<=w&&w<=b*i) break;
    }
    if (i==1000001)
    {
        cout<<"UNSATISFIABLE";
    }
    else
    {
        cout<<i<<' ';
        while(a*(i+1)<=w&&w<=b*(i+1))
        {
            i++;
        }
        cout<<i;
    }
}


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

int main()
{
    ll N;
    cin>>N;
    vector<ll>arr(N,0);
    ll maxi=0;
    for(ll i=0;i<N;i++)
    {
    	cin>>arr[i];
    	maxi=max(maxi,arr[i]);
	}

    ll i=0;
    ll j=N-1;
    ll ans=0;

    vector<ll>mapper(maxi+100,0);
    for(ll i=0;i<=maxi+1;i++)
    {
    	mapper[i]=i;
	}
	vector<ll>sizes(maxi+100,1);

    while(i<j)
    {
    	if(arr[i]!=arr[j])
    	{
    	  ll i1=arr[i];
		  ll i2=arr[j];
		  while(i1!=mapper[i1])
		  {
		  	i1=mapper[i1];
		  }
		  while(i2!=mapper[i2])
		  {
		  	i2=mapper[i2];
		  }

		  if(i1!=i2)
		  {
		  	ans++;
		  	if(sizes[i1]>=sizes[i2])
		  	{
		  		mapper[i2]=mapper[i1];
		  		sizes[i1]+=sizes[i2];
			  }
			  else
			  {
			  	mapper[i1]=mapper[i2];
			  	sizes[i2]+=sizes[i1];
			  }
		  }

		}
		i++;
		j--;

	}
	cout<<ans;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

using ll=long long;
#define pb push_back

int main()
{
    ll n,i,j,k;
    cin>>n;
    ll arr[n];
    ll mx=0;
    ll temp1=0,temp=0;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        mx=max(mx,arr[i]);
        temp1=temp1+arr[i];
        temp=temp1+temp;
        cout<<(i+1)*mx+temp<<"\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    ll first = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        first += a[i];
    }
    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    sort(p.begin(), p.end(), [&](int i, int j){
        return (-a[i]-a[i]-b[i]) < (-a[j]-a[j]-b[j]);
    });
    for (int i = 0; i < n; ++i) {
        int x = p[i];
        first += -a[x]-a[x]-b[x];
        if (first < 0) {
            cout << i+1 << '\n';
            return 0;
        }
    }
    return 0;
}

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL) ;cout.tie(NULL)
using namespace std;

#define deb(x) cout << #x << " " << x << endl;
#define ll long long int
#define pb push_back
#define endl "\n"
#define mp make_pair
#define ss second
#define ff first

void online_judge() {

#ifndef ONLINE_JUDGE
	freopen("D:/C++ projects sublime/input/input.txt", "r", stdin);
	freopen("D:/C++ projects sublime/input/output.txt", "w", stdout);
#endif

}

const int N = 2e5 + 5;
int small = INT_MIN;
int large = INT_MAX;

void solve() {
	int n;
	cin >> n;
	vector<pair<double, double>> v;
	for (int i = 0; i < n; i++) {
		double t1, t2;
		cin >> t1 >> t2;
		v.push_back(make_pair(t1, t2));
	}

	int ans = 0;

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (v[j].first != v[i].first) {
				double slope = (v[j].second - v[i].second) / (v[j].first - v[i].first);
				if (slope >= -1 && slope <= 1) {
					ans++;
				}
			}
		}
	}

	cout << ans << endl;

}

int main() {

	fast_cin();
	online_judge();

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

		solve();

	}

	return 0;
}


// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#ifdef _LOCAL_
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define name(x) #x
#define dump(x) cout << name(x) << " = " << x << endl;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rrep(i,n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define For(i,x) for (auto &i : x)
#define len(x) ll(x.size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) ll(__builtin_popcountll(bit))
#define gcd(a,b) __gcd(a, b)
#define lcm(a,b) a * b / __gcd(a, b)
#define roundup(x,y) (x + y - 1) / y
using ll = long long;
using pii = pair<int,int>;
const long double pi = acos(-1.0);
const ll INF = 4500000000000000000ll;
const int MAX = 1000010;
const int MOD1 = 1000000007;
const int MOD2 = 998244353;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};
const int di2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dj2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
template <typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <typename T> bool chmin(T &a, T b) {if (b < a) {a = b; return 1;} return 0;}
template <typename T> T bpow(T a, int n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
template <typename T> auto comp(vector<T> a) {sort(all(a)); a.erase(unique(all(a)),a.end()); return a;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T,U> &p) {os << p.first << " " << p.second; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T,U> &mp) {For(p,mp) {os << "[" << p << "]\n";} return os;}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {rep(i,len(v)) {if(i) os << " "; os << v[i];} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T> &st) {int c(0); For(x,st) {if (c) os << " "; os << x; c++;} return os;}
template <typename T> istream &operator>>(istream &i, vector<T> &v) {rep(j,len(v)) i >> v[j]; return i;}
template <typename T, typename U> istream &operator>>(istream &i, pair<T,U> &p) {i >> p.first >> p.second; return i;}

void solve() {
    int n; cin >> n;
    string s; cin >> s;
    string t = "";
    int num = 10000000000;
    rep(i,n/3+2) t += "110";
    bool ok = false;
    rep(i,3) if (t.substr(i,n) == s) ok = true;
    if (!ok) cout << 0 << endl;
    else {
        int c = 0;
        rep(i,n) if (s[i] == '0') c++;
        if (s == "1") cout << 2 * num << endl;
        else if (s[n-1] == '0') cout << num - c + 1 << endl;
        else cout << num - c << endl;
    }
    return;
}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef _DEBUG
#define show(x)          \
	cerr << #x << " : "; \
	showVal(x)
template <typename T>
void showVal(const T &a) { cerr << a << endl; }
template <typename T>
void showVal(const vector<T> &a) {
	for (const T &v : a) cerr << v << " ";
	cerr << endl;
}
template <typename T>
void showVal(const vector<vector<T>> &a) {
	cerr << endl;
	for (const vector<T> &v : a) showVal(v);
}
#else
#define show(x)
#endif
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<ll> s1(n + 1), s2(n + 1);
	for (int i = 0; i < n; i++) {
		s1[i + 1] = s1[i];
		if (i % 2 == 0) s1[i + 1] += a[i];
		s2[i + 1] = s2[i];
		if (i % 2 == 1) s2[i + 1] += a[i];
	}
	show(s1);
	show(s2);
	map<ll, int> diff;
	for (int i = 0; i < n + 1; i++) {
		diff[s1[i] - s2[i]]++;
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		diff[s1[i] - s2[i]]--;
		ans += diff[s1[i] - s2[i]];
	}
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

struct BIT{
    vector<LL> node;
    int size;

    BIT(int n){
        size=n;
        node.resize(size,0);
    }

    void add(int a,int x){
        for(int i=a;i<size;i|=i+1) node[i]+=x;
    }

    LL sum(int a){
        LL res=0;
        for(int i=a-1;i>=0;i=(i&(i+1))-1){
            res+=node[i];
        }
        return res;
    }
};

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

    int h,w,m;
    cin>>h>>w>>m;

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

    int clsh=h,clsw=w;
    for(int i=0;i<m;i++){
        if(x[i]==0) clsw=min(clsw,y[i]);
        if(y[i]==0) clsh=min(clsh,x[i]);
    }

    vector<int> rih(clsh,w);
    for(int i=0;i<m;i++){
        if(x[i]<clsh) rih[x[i]]=min(rih[x[i]],y[i]);
    }
    vector<int> riw(clsw,h);
    for(int i=0;i<m;i++){
        if(y[i]<clsw) riw[y[i]]=min(riw[y[i]],x[i]);
    }

    LL res=0;
    for(int i=0;i<clsh;i++) res+=rih[i];
    for(int i=0;i<clsw;i++) res+=riw[i];

    vector<vector<int>> dels(w+1);
    for(int i=0;i<clsh;i++) dels[rih[i]].push_back(i);

    BIT bt(h);
    for(int i=0;i<clsh;i++) bt.add(i,1);
    for(int i=0;i<clsw;i++){
        for(int d:dels[i]) bt.add(d,-1);
        res-=bt.sum(riw[i]);
    }

    cout<<res;

    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
// SOME BITMASK KNOWLEDGE
// 1)x & (x - 1):sets the last one bit of x to zero
// power of two exactly when x & (x − 1) = 0.
// 2)x & -x:sets all the one bits to zero, except last one bit
// 3)x | (x - 1):inverts all the bits after the last one bit
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);

ll power(ll a,ll n,ll c){
    if(n == 0) return 1 % c;
    ll s = power(a,n/2,c);
    s = (s * s) % c;
    if(n % 2) s = (s * a) % c;
    return s;
}

int main()
{
	i_os;
	// freopen("output.txt","w",stdout);
	ll h,w,m;
	cin>>h>>w>>m;
	vector<set<ll>> edges1,edges2;
	edges1.resize(h,set<ll>());
	edges2.resize(w,set<ll>());
	// set<ll> edges1[h],edges2[w];
	REP(i,0,m){
		ll x,y;
		cin>>x>>y;
		edges1[x-1].insert(y-1);
		edges2[y-1].insert(x-1);
	}
	vector<ll> col(w),row(h);
	bool f = 0;
	REP(i,0,w){
		if(edges2[i].size()){
			if(f){
				col[i] = -1;
			}
			else {
				col[i] = *edges2[i].begin() - 1;
				if(col[i] == -1) f = 1;
			}
		}
		else {
			if(f) col[i] = -1;
			else col[i] = h-1;
		}
	}
	f = 0;
	REP(i,0,h){
		if(edges1[i].size()){
			if(f){
				row[i] = -1;
			}
			else {
				row[i] = *edges1[i].begin() - 1;
				if(row[i] == -1) f = 1;
			}
		}
		else {
			if(f) row[i] = -1;
			else row[i] = w-1;
		}
	}
	ll ans = 0;
	REP(i,0,w){
		ans += col[i] + 1;
	}
	vector<pair<ll,ll>> v;
	REP(i,0,h){
		if(row[i] >= 0){
			v.push_back({row[i],i});
		}
	}
	sort(v.begin(),v.end());
	indexed_set s;
	ll curr = -1,v1 = 1;
	for(auto it:v){
		while(curr < it.first){
			curr++;
			s.insert({col[curr],v1});
			v1++;
		}
		ans += s.order_of_key({it.second,0});
	}
	cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
#define per(i,n) for(ll (i)=(n)-1;(i)>=0;--(i))
#define inf 9223372036854775807
#ifdef LOCAL
#define debug(x) cerr<<__LINE__<<": "<<#x<<"="<<x<<endl;
#define debugALL(x) cerr<<__LINE__<<": "<<#x<<"=";for(auto i=(x).begin();i!=--(x).end();i++)cerr<<*i<<" ";cerr<<*--(x).end()<<endl;
#else
#define debug(x) true
#define debugALL(x) true
#endif
using namespace std;

int main(){
    double n;
    cin>>n;
    double x0,y0;
    cin>>x0>>y0;
    double xn,yn;
    cin>>xn>>yn;
    double X=(x0+xn)/2;
    double Y=(y0+yn)/2;
    double rad=2*3.14159265358979/n;
    double c=cos(rad);
    double s=sin(rad);
    cout<<fixed<<setprecision(10);
    cout<<X+(x0-X)*c-(y0-Y)*s<<" "<<Y+(y0-Y)*c+(x0-X)*s<<endl;
}

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

#define int long long
#define ld long double

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

#define pb push_back
#define mp make_pair
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin(),A.rend()
#define precise(i) fixed << setprecision(i)
#define fi first
#define se second

#define err() cout<<"\n==================================\n";
#define errA(A) for(auto i:A) cout<<i<<" "; cout<<"\n";
#define err1(a) cout<<#a<<" "<<a<<"\n";
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n";
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<"\n";

const int logN = 20;
const int M = 1000000007;
const int INF = 1e12;
#define PI 3.14159265;
const int N = 200005;

#define Pii pair<int,int>
#define Vi vector<int>
#define Vpii vector<Pii>

void solve()
{
    int n,s,d;
    cin>>n>>s>>d;
    Vpii a;
    rep(c,0,n)
    {
        int x,y;
        cin>>x>>y;
        a.pb(mp(x,y));
    }
    rep(c,0,n)
    {
        if((a[c].fi >= s) || (a[c].se <= d))
        {
            continue;
        }
        cout<<"Yes";
        return;
    }
    cout<<"No";
}

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


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

// https://ei1333.github.io/luzhiled/

// combination with fermat theorem
// https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae

// binary search
// https://qiita.com/drken/items/97e37dd6143e33a64c8c

// modint
// https://qiita.com/DaikiSuyama/items/2dcc49932f2489292e44

int main(){
    ll n; cin >> n;
    ll M = 998244353;

    ll a, b, c;
    a = 0;
    b = 0;
    c = 0;
    ll ans = std::numeric_limits<ll>::max();
    ll tmp = 1;
    while(true) {
        if (b == 0) {
            a = n;
            c = 0;
        } else {
            tmp *= 2;
            a = n / tmp;
            c = n - a * tmp;
            if (c < 0) break;
        }
        ans = min(ans, a + b + c);
        b++;
        if (b > 63) break;
        // cout << b << ": " << a + b + c << " = " << a * tmp + c <<  endl;
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N;
    cin >> N;
    ll b = 0;
    ll B = 1;
    ll ans = INF;
    while(B <= N){
        ll a = N / B;
        ll c = N - a * B;
        ans = min(ans, a + b + c);
        b++;
        B *= 2;
    }
    cout << ans << endl;

}


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

// p^q
long long sisu(long long p, long long q){
  long long ans = 1;
  for (int i=0; i<q; i++){
    ans *= p;
  }
  return ans;
}

//log(p^q)
int hantei(long long p, long long q){
  return q*log(p);
}

int main(){
  string X_;
  long long M;
  cin >> X_ >> M;
  int S = X_.size();
  vector<int> X(S);
  for (int i = 0; i<S; i++){
    X.at(i) = (int)X_.at(i) - (int)'0' ; //0番目に最上位桁が収納
  }

  int d = 1;
  for (int i=0; i< S; i++){
    if (d < X.at(i)){
      d = X.at(i);
    }
  }

  long long m;
  long long D;
  if (S != 1){
    D = 10000 + exp(log((double)M / (double)X.at(0)) / (double)(S-1));
  }else{
    D = X.at(0);
  }
  long long count = D - d;
  if (count > 0){

    while (true){
      m=0;
      if ( log((double)X.at(0)) + (double)(S-1)*log((double)D) > log((double)M) ){
        count--;
        D--;
        continue;
      }
      for (int i =0; i<S; i++){
        m += X.at(i)*sisu(D,S-i-1);
      }
      if (M >= m)break;
      count--;
      D--;
    }

  }
  if (count < 0){
    count = 0;
  }
  if (S == 1){
    if (X.at(0) <= M){
      count = 1;
    }else{
      count = 0;
    }
  }
  cout << count << endl;
}

/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int n;
vector<int> v[2];
LL rest=0;
int a[100000+20],b[100000+20];
int main(){
	cin>>n;
	rb(i,1,n)
	{
		cin>>a[i];
		rest+=a[i];
	}
	rb(i,1,n)
	{
		cin>>b[i];
		v[i&1].PB(b[i]-a[i]);
	}
	sort(ALL(v[0]));
	sort(ALL(v[1]));
	LL MAX=0;
	LL sum=0;
	reverse(ALL(v[0]));
	reverse(ALL(v[1]));
	rep(i,n/2){
		sum+=v[0][i]+v[1][i];
		check_max(MAX,sum);
	}
	rest+=MAX;
	cout<<rest<<endl;
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


#include<bits/stdc++.h>
#define pairs pair<int,int>
#define loop(i,a,n) for(int i=a;i<n;i++)
#define m_p make_pair
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(v) v.begin(),v.end()
using namespace std;

void solve(){
	ll a,b,c;
	cin>>a>>b>>c;
	string ans;
	if(c==1){
		ans="Aoki";
		if(b>a)
	    {
	    	cout<<ans;
		}
		else{
			cout<<"Takahashi";
		}
	}
	else
{
	if(a>b){
		cout<<"Takahashi";
	}
	else
	cout<<"Aoki";
}

}
int main(){
    int test=1;
    //cin>>test;
    while(test--){
        solve();
        cout<<endl;
    }
}

#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;
// #pragma GCC optimize("O2")
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef multiset <ll> mms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define deb(x) cout << #x << " " << x << endl;
#define ff first
#define ss second
#define pb(v) push_back(v)
#define lb(v) lower_bound(v)
#define ub(v) upper_bound(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b) {
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s) {
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v) {
	forl(i,v.size()) cout<<v[i]<<" ";
	cout<<"\n";
}
void pa(ll *v, ll size) {
	forl(i,size) cout<<v[i]<<" ";
	cout<<"\n";
}
void removeDups(mv &v) {
	sort(all(v));
	mv::iterator it = unique(v.begin(), v.end());
	v.resize(distance(v.begin(), it));
}
inline ld kthRoot(ld n, ll k) {
	return pow(k, (1.0 / k) * (log(n) / log(k)));
}
ll power(ll x, ll y, ll p) {
	ll res=1;
	x=x%p;
	while(y>0) {
		if(y&1) res = (res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x, ll mod) {
	if(x>=mod) x%=mod;
}

ll mod = 1e9 + 7;

set < string > sett1, sett2;

void thisIsMain() {
	ll n;
	cin>>n;
	forl(i,n) {
		string s;
		cin>>s;
		if(s[0] == '!') {
			s.replace(0,1,"");
			sett2.insert(s);
		} else sett1.insert(s);
	}
	for(auto v : sett1) {
		if(sett2.find(v) != sett2.end()) {
			cout<<v<<"\n";
			return ;
		}
	}
	cout<<"satisfiable\n";
}

int main(void)
{
	fastio
	ll t = 1;
	// cin>>t;
	while(t--) thisIsMain();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    char a , b , c;
    cin>> a >> b >> c;
    if( a==b and b==c ){
        cout<<"Won";
    }
    else{
        cout<<"Lost";
    }

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define V vector
#define vcin(v) rep(i, v.size()) cin >> v[i]

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


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> Pair;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

int MSB(int n) {
    n |= (n >> 1);
    n |= (n >> 2);
    n |= (n >> 4);
    n |= (n >> 8);
    n |= (n >> 16);
    return n - (n >> 1);
}

void solve(int N){
    int msb = MSB(N), msb2 = msb<<1;
    REP(i,N){
        int a = 2*i % msb2, b = (2*i+1) % msb2;
        if(a>=N) a %= msb;
        if(b>=N) b %= msb;
        cout << a+1 << " " << b+1 << en;
    }
}
void Main(){
    int N; cin >> N;
    solve(N);
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int n;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cout<<(2*i)%n+1<<' '<<(2*i+1)%n+1<<endl;
	return 0;
}


#include <bits/stdc++.h>

#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int k, n, m;
    cin >> k >> n >> m;
    int a[k], b[k];
    vector<pair<int,int>> v;
    int rem = m;
    for (int i = 0; i < k; i++) {
        cin >> a[i];
        b[i] = (m*a[i])/n;
        rem -= b[i];
        v.push_back({m*a[i]-b[i]*n,i});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for (int i = 0; i < rem; i++) b[v[i].second]++;
    for (int i = 0; i < k; i++) cout << b[i] << ' ';
    cout << '\n';
}

/**
    template for testing/using the algorithms
    import(copy-paste the methods ;v) algorithm/s and use here
**/

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

using namespace std;

///------------------- algorithm function/s to be placed here start -------------------///

string s[3];
unsigned long long N[3][10+5], n[3];

vector<char> chars;
vector<bool> isFirst;

void insertNumWhereChar(long long num, char c){

    for(int i=0;i<3;i++){

        for(int j=0;j<s[i].size();j++){

            if(s[i][j] == c) N[i][j] = num;
        }
    }
}

bool isN1PlusN2EqualsN3(){

    for(int i=0;i<3;i++){

        n[i] = 0;

        for(int j=0;j<s[i].size();j++){

            n[i] = n[i]*10 + N[i][j];
        }
    }

    int len[3]; bool lenSame = true;
    for(int i=0;i<3;i++){

        long long x = n[i]; len[i] = 0;

        while(x){

            x/=10;
            len[i]++;
        }

        lenSame = lenSame && (len[i]==s[i].size());
    }

    return (n[0]+n[1] == n[2]) && lenSame;
}

bool findd( int i, bool taken[10]){

    if(i==chars.size()) {

        return isN1PlusN2EqualsN3();
    }

    int start = 0;

    if(isFirst[i]) start++;

    bool found = false;

    for(int ii=start;ii<10;ii++){

        if(taken[ii]) continue;

        taken[ii] = true;
        insertNumWhereChar(ii, chars[i]);

        found = found || findd(i+1, taken);
        if(found) return true;

        //removeNumWhereChar(chars[i]);
        taken[ii] = false;
    }

    return found;
}

///-------------------- algorithm function/s to be placed here end --------------------///

void exec(int T){
// execute the algorithm

    string s1[3]; cin>>s[0]>>s[1]>>s[2];

    map<char, bool> uniq_chars;
    for(int i=0;i<3;i++){

        for(int j=0;j<s[i].size();j++) uniq_chars[s[i][j]] = (j==0);
    }

    if(uniq_chars.size()>10){

        cout<<"UNSOLVABLE\n";
        return;
    }

    chars.clear();
    isFirst.clear();
    for(auto i = uniq_chars.begin();i!=uniq_chars.end();i++){

        chars.push_back(i->first);
        isFirst.push_back(i->second);
    }

    bool taken[10];
    for(int i=0;i<10;i++) taken[i] = false;
    if(findd(0, taken)) cout<<n[0]<<"\n"<<n[1]<<"\n"<<n[2]<<"\n";
    else cout<<"UNSOLVABLE\n";

}

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

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

    int t=1;

    //cin>>t;

    for(int T=1;T<=t;T++){

        exec(T);

    }

    return 0;
}


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

//pragmas

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef unsigned long long int ull;
typedef long double ld;
typedef unsigned long long ull;

const long double pi = acos(-1.0);

#define FOR(a,b,c) for(int (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(int (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(int (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(int (a)=(b);(a)>=(c);--(a))
#define TC(n) cout << "Case #" << (n) << ": "
#define DEBUG(x) cout << "DEBUG " << #x << ' ' << x << '\n';
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>

void init(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void infile(){
    freopen("dull.in", "r", stdin);
}

void outfile(){
    freopen("input.txt", "w", stdout);
}

ll rp(ll a, ll b, ll mod){
    ll res = 0;
    while(b > 0){
        if(b & 1)
            res = (res + a) % mod;
        res %= mod;
        a = (a << 1)%mod;
        b = b >> 1;
    }
    return res;
}

ll modex(ll a, ll b, ll mod){
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ll tmp = modex(a, b/2LL, mod);
    tmp = rp(tmp, tmp, mod);
    if(b & 1LL)
        tmp = rp(tmp, a, mod);
    return tmp;
}

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

//End of template

int main(){
    init();

    ll n, x;
    string s;
    cin >> n >> x >> s;
    FOR(i, 0, n){
        if(s[i] == 'x'){
            x = max(x-1, 0LL);
        }
        else{
            x++;
        }
    }
    cout << x << endl;
    return 0;
}

#include <bits/stdc++.h>

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

#ifdef LOCAL
#define log(val) std::cerr << std::setw(3) << __LINE__ << "| " << #val << " = " << (val) << std::endl
#define dbg(proc) proc
#else
#define log(val) 0
#define dbg(proc) 0
#endif

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

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename T>
std::tuple<T, T, T> extgcd(T a, T b){
    T s1 = 1, t1 = 0, s2 = 0, t2 = 1;
    while(b != 0){
        std::tie(s1, t1, s2, t2) = std::make_tuple(s2, t2, s1 - (a / b) * s2, t1 - (a / b) * t2);
        std::tie(a, b) = std::make_tuple(b, a % b);
    }
    return std::make_tuple(s1, t1, a);
}

// 注意: a と mod が互いに素である必要がある
template <typename T>
T mod_inverse(T a, T mod){
    T b;
    std::tie(b, std::ignore, std::ignore) = extgcd(a, mod);
    if(b < 0){b += mod;}
    return b;
}

template <typename T>
struct Combinatorics{
    std::vector<T> fact, inv_fact, pow;

    Combinatorics(T max) : fact(max + 1), inv_fact(max + 1), pow(max + 1) {
        fact[0] = 1;
        pow[0] = 0;
        for(T i=1;i<=max;++i){
            int j = i, p = 0;
            while(j % 3 == 0){
                j /= 3;
                p += 1;
            }

            fact[i] = j * fact[i - 1] % 3;
            pow[i] = p + pow[i-1];
        }

        for(T i=0;i<=max;++i){
            inv_fact[i] = mod_inverse(fact[i], 3);
        }
    }

    T nCk(T n, T k){
        if(n < k){return 0;}
        if(pow[n] > pow[n-k] + pow[k]){
            return 0;
        }
        return fact[n] * inv_fact[k] % 3 * inv_fact[n - k] % 3;
    }
};

Combinatorics<int> comb(400100);
int N;
std::string S;
int A[400100];
std::string T = "BWR";

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

    std::cin >> N >> S;

    for(int i=0;i<N;++i){
        if(S[i] == 'B'){
            A[i] = 0;
        }else if(S[i] == 'W'){
            A[i] = 1;
        }else{
            A[i] = 2;
        }
    }

    int res = 0;

    for(int i=0;i<N;++i){
        // std::cout << A[i] << ", " << comb.nCk(N - 1, i) << std::endl;
        res += A[i] * comb.nCk(N - 1, i);
    }

    res %= 3;

    if(N % 2 == 0){
        res = (3 - res) % 3;
    }

    std::cout << T[res] << std::endl;
}


#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
const int N=1000010;
int pr[N];
void sev(){
  pr[1]=1;
  for(int i=2; i<N; ++i){
    if(pr[i])
      continue;
    for(int j=i; j<N; j+=i){
      pr[j]=i;
    }
  }
}
int main(){
	ll l, r;
	scanf("%lld%lld",&l,&r);
	ll tmp, ans = 0;
	ll tmp1, cnt, tmp2, cnt1;
	sev();
	for(ll i=2; i<=r; ++i){
		tmp = (r/i*i - (l-1)/i*i)/i;
		cnt = 0;
		tmp1 = i;
		while(tmp1!=1){
			++cnt;
			tmp2 = pr[tmp1];
			cnt1 = 0;
			while(tmp1%tmp2==0){
				tmp1/=tmp2;
				++cnt1;
			}
			if(cnt1>1)break;
		}
		if(cnt1>1)continue;
		// cout<<i<<" "<<tmp<<" "<<cnt<<endl;
		if(cnt%2){
			ans += tmp*(tmp-1);
		}
		else{
			ans -= tmp*(tmp-1);
		}
	}
	// cout<<ans<<endl;
	for(int i=max(l,2ll); i<=r; ++i){
		tmp1 = (r)/i*i+i;
		// cout<<i<<" "<<tmp1<<endl;
		ans -= ((tmp1-i)/i-1)*2;
	}
	cout<<ans<<endl;
}

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

signed  main(){
	int A, B, i, ans = 0;
	scanf("%d%d", &A, &B);
	for(i = 1; i <= B; i++){
		if(i * ((A + i - 1) / i) < i * (B / i)){
			ans = i;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector< ll > vi;
typedef pair< ll, ll > pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(ll i = a; i <= b; i++)
#define nl "\n"

const int MAX_N = 1e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e11;
const ll NINF = -1e11;
const ll epsilon = 1e-9;

ll fast_pow(ll base, ll exp, ll mod){
    if(exp == 0)
        return 1;
    if(exp == 1)
        return base%mod;
    ll half = fast_pow(base, exp/2, mod);
    if(exp % 2 == 0)
        return (half%mod * half%mod)%mod;
    else
        return ((half%mod * half%mod)%mod * base%mod)%mod;
}

ll fast_pow_iter(ll base, ll exp, ll mod){
    ll ans = 1;
    while(exp > 0){
        if(exp & 1)
            ans = (ans * base)%mod;
        base = (base * base)%mod;
        exp >>= 1;
    }
    return ans;
}

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

ll gcd_extended(ll a, ll b, ll& s, ll& t){
    if(b == 0){
        s = 1;
        t = 0;
        return a;
    }

    ll s1,t1;
    ll d = gcd_extended(b, a%b, s1, t1);
    s = t1;
    t = s1 - t1 * (a/b);
    return d;
}
ll sum = 0;
ll fact[10];
set< string > st;
void find_all(vector< ll > must, vector< ll > v){
    if(must.size() == 4){
        ll hash[10] = {0};
        string s;
        for(ll i=0; i<4; i++){
            s.PB('0' + must[i]);
            hash[must[i]]++;
        }
        sort(s.begin(), s.end());
        if(st.find(s) != st.end()){
            return;
        }
        st.insert(s);
        ll value = 24;
        for(ll i=0; i<10; i++){
            value /= fact[hash[i]];
        }
        sum += value;
        return;
    }

    for(ll i=0; i<v.size(); i++){
        must.PB(v[i]);
        find_all(must, v);
        must.pop_back();
    }
    return;
}

void solve() {
    // Code for problem here
    string s;
    cin >> s;
    ll o=0,unsure=0;
    vector< ll > v;
    vector< ll > must;
    for(ll i=0; i<s.length(); i++){
        if(s[i] == 'o'){
            o++;
            v.PB(i);
            must.PB(i);
        }
        else if(s[i] == '?'){
            unsure++;
            v.PB(i);
        }
    }
    if(o > 4){
        cout << 0 << endl;
        return;
    }

    fact[0] = 1;
    for(ll i=1; i<10; i++){
        fact[i] = i * fact[i-1];
    }
    sum = 0;
    find_all(must, v);
    cout << sum << endl;
    return;
}

int main()
{

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

    int total_cases = 1;
    // cin >> total_cases;
    for (int t = 1; t <= total_cases; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
    return 0;
}

#pragma region Template  // clang-format off
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, m, n) for (int i = m; i < (int)(n); i++)
#define repe(i, m, n) for (int i = m; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define yesno {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
using ll = long long;
using vvi = vector<vector<int>>;
using P = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#pragma endregion Template  // clang-format on

int main() {
  int n;
  cin >> n;
  map<int, ll> m;
  rep(i, 0, n) {
    int a;
    cin >> a;
    m[a]++;
  }

  ll ans = 0;
  repe(i, -200, 200) {
    repe(j, i, 200) { ans += m[i] * m[j] * (i - j) * (i - j); }
  }

  cout << ans << endl;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> S(0), T(0);
    int a, b, c, d;
    for(int i = 0; i < N; i++){
        cin >> a >> b;
        a *= N;
        b *= N;
        S.push_back(make_pair(a, b));
    }
    for(int i = 0; i < N; i++){
        cin >> c >> d;
        c *= N;
        d *= N;
        T.push_back(make_pair(c, d));
    }
    pair<int, int> gs{0, 0}, gt{0, 0};
    for(int i = 0; i < N; i++){
        gs.first += S.at(i).first;
        gs.second += S.at(i).second;
        gt.first += T.at(i).first;
        gt.second += T.at(i).second;
    }
    gs.first /= N;
    gs.second /= N;
    gt.first /= N;
    gt.second /= N;
    for(int i = 0; i < N; i++){
        S.at(i).first -= gs.first;
        S.at(i).second -= gs.second;
        T.at(i).first -= gt.first;
        T.at(i).second -= gt.second;
    }

    for(int i=0; i<N; i++){
        if(S.at(i).first != 0 || S.at(i).second != 0){
            swap(S.at(i).first, S.at(0).first);
            swap(S.at(i).second, S.at(0).second);
        }
    }

    if(N == 1){
        cout << "Yes" << endl;
        return 0;
    }
    else if(N == 2){
        int sdis = pow(S.at(1).first - S.at(0).first, 2) + pow(S.at(1).second - S.at(0).second, 2);
        int tdis = pow(T.at(1).first - T.at(0).first, 2) + pow(T.at(1).second - T.at(0).second, 2);
        if(sdis == tdis) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }

    const double eps = 1e-6;
    string ans = "No";
    for(int i = 0; i < N; i++){
        double angle = atan2(T.at(i).second, T.at(i).first) - atan2(S.at(0).second, S.at(0).first);
        int flag = 1;
        for(int j = 0; j < N; j++){
            double X = S.at(j).first * cos(angle) - S.at(j).second * sin(angle);
            double Y = S.at(j).first * sin(angle) + S.at(j).second * cos(angle);
            int tmpflag = 0;
            for(int k = 0; k < N; k++){
                if(abs(X - T.at(k).first) <= eps && abs(Y - T.at(k).second) <= eps) tmpflag = 1;
            }
            flag &= tmpflag;
        }
        if(flag) ans = "Yes";
    }
    cout << ans << endl;

}

#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define reps(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define prl(a) cout << (a) << endl
#define allrange(a) a.begin(),a.end()

bool solve_translated(vector<pair<int,int>> &S,vector<pair<int,int>> &T){
    int N = S.size();
    int dx = S[0].first-T[0].first;
    int dy = S[0].second-T[0].second;
    bool flg = true;
    reps(i,1,min(N,20)){
        if(!((S[i].first==T[i].first+dx) && (S[i].second==T[i].second+dy))){flg = false; break;}
    }
    return flg;
}
vector<pair<int,int>> Pitagora_rot(vector<pair<int,int>> &S,int a, int b , int c){
    int N = S.size();
    vector<pair<int,int>> PS(N);
    auto pt0 = S[0];
    PS[0] = pt0;
    bool flg = true;
    int dx,dy,x,y;
    reps(i,1,N){
        dx = S[i].first - pt0.first;
        dy = S[i].second - pt0.second;
        x=dx*a-dy*b;
        y=dx*b+dy*a;
        if(((x%c)!=0) || ((y%c)!=0)) {flg = false; break;}
        PS[i] = make_pair(x/c+pt0.first, y/c+pt0.second);
    }
    if(flg) return PS;
    else return vector<pair<int,int>>();
}

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

    vector<pair<int,int>> S(N),T(N);
    rep(i,N)
    {
        int x,y;
        cin >> x >> y;
        S[i].first = x;S[i].second = y;
    }

    rep(i,N)
    {
        int x,y;
        cin >> x >> y;
        T[i].first = x;
        T[i].second = y;
    }
    sort(allrange(T));

/*ピタゴラ三角形
    5	12	13
    8	15	17
    3	4	5
*/
    constexpr int tri[12][3] ={
    {3,4,5},
    {4,3,5},
    {-3,4,5},
    {-4,3,5},
    {0,1,1},
    {1,0,1},
    {-1,0,1},
    {0,-1,1},
    {-3,-4,5},
    {-4,-3,5},
    {3,-4,5},
    {4,-3,5}
    };

 /*
    vector<vector<int>> tri(0);
    tri.push_back(vector<int>({3,4,5}));
    tri.push_back(vector<int>({4,3,5}));
    tri.push_back(vector<int>({-3,4,5}));
    tri.push_back(vector<int>({-4,3,5}));
    tri.push_back(vector<int>({0,1,1}));
    tri.push_back(vector<int>({1,0,1}));
    tri.push_back(vector<int>({-1,0,1}));
    tri.push_back(vector<int>({0,-1,1}));
    tri.push_back(vector<int>({-3,-4,5}));
    tri.push_back(vector<int>({-4,-3,5}));
    tri.push_back(vector<int>({3,-4,5}));
    tri.push_back(vector<int>({4,-3,5}));
 //   tri.push_back(vector<int>({-5, -12, 13}));
 //   tri.push_back(vector<int>({-12, -5, 13}));
 //   tri.push_back(vector<int>({-8,-15,17}));
 //   tri.push_back(vector<int>({-15,-8,17}));
 //   tri.push_back(vector<int>({5, 12, 13}));
 //   tri.push_back(vector<int>({12, 5, 13}));
 //   tri.push_back(vector<int>({8,15,17}));
 //   tri.push_back(vector<int>({15,8,17}));
 //   tri.push_back(vector<int>({-5, 12, 13}));
 //  tri.push_back(vector<int>({-12, 5, 13}));
  //  tri.push_back(vector<int>({-8,15,17}));
  //  tri.push_back(vector<int>({-15,8,17}));
 //   tri.push_back(vector<int>({5, -12, 13}));
 //   tri.push_back(vector<int>({12, -5, 13}));
 //   tri.push_back(vector<int>({8,-15,17}));
 //   tri.push_back(vector<int>({15,-8,17}));

 */
    bool flg;

    if(N==2){
        auto sx = S[0].first-S[1].first;
        auto sy = S[0].second-S[1].second;
        auto tx = T[0].first-T[1].first;
        auto ty = T[0].second-T[1].second;
        flg= (sx*sx+sy*sy==tx*tx+ty*ty);
    } else {
        rep(j,12){
            auto S2 = Pitagora_rot(S,tri[j][0],tri[j][1],tri[j][2]);
            if(S2.empty()) continue;
            sort(allrange(S2));
            flg = solve_translated(S2,T);
            if(flg) break;
        }
    }
    if(flg) prl("Yes"); else prl("No");
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll rd() {
	ll x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d rd()
ll n;
struct node{
	ll x,y,sum;
}a[200010];
bool cmp(node a,node b){
	return a.sum+a.x>b.sum+b.x;
}
ll del,cnt;
int main(){
	n=d;
	f(i,1,n)a[i].x=d,a[i].y=d,a[i].sum=a[i].x+a[i].y;
	sort(a+1,a+n+1,cmp);
	f(i,1,n)del+=a[i].x;
	f(i,1,n){
		del-=a[i].x,cnt+=a[i].sum;
		if(del<cnt){
			cout<<i;
			return 0;
		}
	}
	return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define ll long long
#define F(type, i, a, b, incr) for (type i = a; i <= (type)(b); i += (type)(incr))
#define RF(type, i, a, b, decr) for (type i = a; i >= (type)(b); i -= (type)(decr))
#define sz(a) sizeof(a)
#define deb(a) cerr << " [" << #a << "->" << a << "] "
#define next_line cerr << '\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for (auto it = s.begin(); it != s.end(); it++)
#define setbits(x) __builtin_popcountll(x)
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

/*
1. If you cannot approach a problem
directly in the way it is proposed
then try to think from backwards
2. Have you checked the implementation
before starting to write the code?
3. Have you read the question carefully ?
4. Keep the names of variable descriptive.
5. Check the types and range of the values properly
6. Erase a iterator in the set or map only after using its value.
7. 1 bitset of 1e9 size only takes 256 mb.
8. Try to use global variables in case of recursion
9. Short and precise exectutes faster
*/

void solve()
{
    int n, su = 0;
    cin >> n;
    vector<pii> vo(n);
    F(int, i, 0, n - 1, 1){
        cin >> vo[i].first >> vo[i].second;
        su += vo[i].first;
    }
    sort(all(vo), [](pii a, pii b){
        return make_pair(2LL*a.first + a.second, a.first) < make_pair(2LL*b.first + b.second, b.first);
    });
    int ans = 0, sc = 0;
    RF(int, i, n - 1, 0, 1){
        if(sc > su){
            break;
        }else{
            ans ++;
            sc += (vo[i].first + vo[i].second);
            su -= (vo[i].first);
        }
    }
    cout << ans << '\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        // freopen("Debug.txt", "w", stderr);
    #else
    #endif
    // cout << fixed << setprecision(10);
    // int _t;
    // cin>>_t;
    // while(_t --)
        solve();
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

bool yes;
LL X[100011], Y[100011];
LL solve(int len) {
    if (len <= 1) return 0;
//    rprintf("%lld", X, X+len);
//    rprintf("%lld", Y, Y+len);

    LL ret = len - 1;
    int left = 0;
    for (int i=1; i<len; ) {
	int j = i;
	while (j < len && Y[i] == Y[j]) j++;
	while (X[left] <= Y[i]) left++;

	if (left && X[left-1] == Y[i]) {
	    ret += i - left;
	} else {
	    yes = false;
	    return 0;
	}

	i = j;
    }

    return ret;
}

int N;
LL L;
LL A[100011];
LL B[100011];

void MAIN() {
    scanf("%d%lld", &N, &L);
    A[0] = B[0] = 0;
    REP (i, N) scanf("%lld", A+i+1);
    REP (i, N) scanf("%lld", B+i+1);
    N += 2;
    A[N-1] = B[N-1] = L+1;

    REP (i, N) {
	A[i] -= i;
	B[i] -= i;
    }

    yes = true;
    LL ans = 0;
    for (int i=0; i<N && yes; ) {
	int j = i + 1;
	while (B[j] < A[j]) j++;

	int len = j - i;
	REP (a, len) {
	    X[a] = A[i+a] - A[i];
	    Y[a] = B[i+a] - B[i];
	}
	ans += solve(len);

	int k = j;
	while (A[k] < B[k]) k++;
	if (B[k] < A[k]) {
	    yes = false;
	    break;
	}

	len = k - j + 1;
	REP (a, len) {
	    X[a] = A[k] - A[k-a];
	    Y[a] = B[k] - B[k-a];
	}
	ans += solve(len);

	i = k;
    }

    if (yes) {
	printf("%lld\n", ans);
    } else {
	puts("-1");
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}

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

// 解説を見て
int main(void) {
    string x;
    cin >> x;

    ll m;
    cin >> m;

    if (x.size() == 1) {
        if (stoi(x) <= m) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }

    int d = 0;
    for (char c : x) d = max(d, int(c - '0'));
    ll ac = d, wa = m + 1;
    while (wa - ac > 1) {
        ll wj = (ac + wa) / 2;
        ll v = 0;
        for (char c : x) {
            if (v > m / wj) v = m + 1;
            else v = v * wj + (c - '0');
        }
        if (v <= m) ac = wj;
        else wa = wj;
    }

    cout << ac - d << endl;

    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
const vector<ll> dx={-1,0,1,0},dy={0,1,0,-1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
inline void yes() { cout << "Yes" << ENDL; }
inline void no() { cout << "No" << ENDL; }

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(auto&& x: vec) is >> x;
  return is;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}

template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}

template <long long MOD = mod>  // MODを適宜設定すること
struct Mint {
  using M = Mint;
  ll a;
  Mint(ll x = 0) {
    a = x % MOD;
    if(a < 0) a += MOD;
  }  // Mintで

  M pow(ll n) {
    M b = *this, r = 1 % MOD;
    while(n) {
      if(n & 1) r *= b;
      b *= b;
      n >>= 1;
    }
    return r;
  }

  M inv() { return pow(MOD - 2); }

  M& operator+=(M r) {
    a += r.a;
    if(a >= MOD) a -= MOD;
    return *this;
  }
  M& operator-=(M r) {
    a += MOD - r.a;
    if(a >= MOD) a -= MOD;
    return *this;
  }
  M& operator*=(M r) {
    a = 1LL * a * r.a % MOD;
    return *this;
  }
  M& operator/=(M r) { return (*this) *= r.inv(); }
  M operator+(M r) const { return M(a) += r; };
  M operator-(M r) const { return M(a) -= r; };
  M operator*(M r) const { return M(a) *= r; };
  M operator/(M r) const { return M(a) /= r; };
  M operator-() const { return M() - *this; }

  friend ostream& operator<<(ostream& os, const M& r) { return os << r.a; }
};
using M = Mint<mod>;

/*
using M = Mint<mod>;
M xとint iの演算はx.a+=i またはx+=M{i}
M(x).pow(exp)
*/

const int MAX=100010;

M fac[MAX], finv[MAX], inv[MAX];

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

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  COMinit();

  ll n,m;cin>>n>>m;
  V<ll> a(n);cin>>a;

  ll asum=0;
  M ans=1;
  rep(i,0,n){
    asum+=a[i];
  }

  rep(i,1,n+asum+1){
    ans/=i;
    ans*=(m+n+1-i);
  }
  cout<<ans<<ENDL;

}
//! ( . _ . ) !
//CHECK overflow,vector_size,what to output?
//any other simpler approach?
//list all conditions, try mathematical and graphic observation

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 200010
priority_queue<pll,vector<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T = 1,n,m,k;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n >> m;
    ll d = 2*n+100;
    cout << max(0ll, d-m) << "";

    return 0;
}


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

int main()
{
	int x;
	cin >> x;
	if(x >= 0) cout << x << endl;
	else cout << "0" << endl;
	return 0;
}

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace __gnu_pbds;
//using namespace boost::multiprecision;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<vector<ll>> VVI;
typedef pair<ll, ll> PII;
typedef vector<PII> VPII;
typedef set<ll> SI;
typedef map<string, ll> MSI;
typedef map<ll, ll> MII;
typedef pair<ll, PII> PIII;

#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define MOD 1000000007
#define test ll t;cin>>t;while(t--)
#define REP(i,a,b) for (int i = a; i <= b; i++)

void solve()
{
    ll x;
    cin >> x;
    if(x<0)
    cout  << 0 << "\n";
    else cout << x << "\n";
    return;
}

int main()
{
    flash;

    // test
    // {
    //     solve();
    // }
    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

class UnionFind {
public:
    vector<int> par;
    int num;

    UnionFind(int n) : par(n, -1), num(n) {};

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    int size(int x) {
        return -par[root(x)];
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        num--;
        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    int a[n], b[n];
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    UnionFind uf(n);
    rep(i, 0, m) {
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        if (!uf.same(c, d)) uf.unite(c, d);
    }
    vector<ll> x(n, 0), y(n, 0);
    rep(i, 0, n) {
        x[uf.root(i)] += a[i];
        y[uf.root(i)] += b[i];
    }
    if (x == y) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

#include <bits/stdc++.h>

#define rep(i, a, b) for (int i = a, i##end = b; i <= i##end; ++i)
#define per(i, a, b) for (int i = a, i##end = b; i >= i##end; --i)
#define rep0(i, a) for (int i = 0, i##end = a; i < i##end; ++i)
#define per0(i, a) for (int i = (int)a-1; ~i; --i)
#define chkmax(a, b) a = std::max(a, b)
#define chkmin(a, b) a = std::min(a, b)
#define x first
#define y second
#define pb push_back
#define mp std::make_pair
#define enter putchar('\n')

typedef long long ll;

int read() {
	int w = 0, f = 1; char c;
	while (!isdigit(c = getchar())) c == '-' && (f = -1);
	while (isdigit(c)) w = w*10+(c^48), c = getchar();
	return w * f;
}

int a[4];

int main() {
	rep0(i, 4) a[i] = read();
	std::sort(a, a+4);
	if (a[0] + a[1] + a[2] == a[3] || a[0] + a[2] == a[1] + a[3] || a[0] + a[3] == a[1] + a[2]) printf("Yes");
	else printf("No");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
typedef pair<int,int> pp;
bool com(pp x,pp y){
    if(x.ff==y.ff) return x.ss<y.ss;
    return x.ff<y.ff;
}
ll power(ll x,ll y){
    ll prod=1;
    while(y){
        if(y&1) prod=(prod*x)%mod;
        x=(x*x)%mod;
        y/=2;
    }
    return prod;
}
const int N=1e5+9;
void solve(){
    int n,t,s,k;
    cin>>n>>t>>s>>k;
    if(k<n*t||k>s*n) puts("Yes");
    else puts("No");
}
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	    solve();
	return 0;
}
/*
*/

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


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>
#define IN
#define LL long long
#define P(t1) ((t1 - 1) / blk + 1)
using namespace std;

const int MAXN = 2e3 + 5;
int T;
LL A, B, C;

int main() {
	int i,j,k;
	scanf ("%d", &T);
	while (T--) {
		scanf ("%lld%lld", &A, &B), C = max (B - 2ll * A + 1, 0ll);
		printf ("%lld\n", (C + 1) * C / 2);
	}
	return 0;
}

#include <bits/stdc++.h>

#pragma region my_template

struct Rep {
  struct I {
    int i;
    void operator++() { ++i; }
    int operator*() const { return i; }
    bool operator!=(I o) const { return i < *o; }
  };
  const int l_, r_;
  Rep(int l, int r) : l_(l), r_(r) {}
  Rep(int n) : Rep(0, n) {}
  I begin() const { return {l_}; }
  I end() const { return {r_}; }
};
struct Per {
  struct I {
    int i;
    void operator++() { --i; }
    int operator*() const { return i; }
    bool operator!=(I o) const { return i > *o; }
  };
  const int l_, r_;
  Per(int l, int r) : l_(l), r_(r) {}
  Per(int n) : Per(0, n) {}
  I begin() const { return {r_ - 1}; }
  I end() const { return {l_ - 1}; }
};

template <class F>
struct Fix : private F {
  Fix(F f) : F(f) {}
  template <class... Args>
  decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};

template <class T = int>
T scan() {
  T res;
  std::cin >> res;
  return res;
}

template <class T, class U = T>
bool chmin(T& a, U&& b) {
  return b < a ? a = std::forward<U>(b), true : false;
}
template <class T, class U = T>
bool chmax(T& a, U&& b) {
  return a < b ? a = std::forward<U>(b), true : false;
}

#ifndef LOCAL
#define DUMP(...) void(0)
template <int OnlineJudge, int Local>
constexpr int OjLocal = OnlineJudge;
#endif

using namespace std;

#define ALL(c) begin(c), end(c)

#pragma endregion

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n = scan();
  vector<int64_t> a(n), b(n);
  generate(ALL(a), scan<>);
  generate(ALL(b), scan<>);
  int64_t ans = 0, mx = 0;
  for (int i : Rep(n)) {
    chmax(mx, a[i]);
    chmax(ans, mx * b[i]);
    cout << ans << '\n';
  }
}


#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end()
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

int main(){
string S;cin >> S;
ll N = S.size();
bool C;
map<char, ll> M;
vector<ll> V(124, -1);
if(1 == N)V[0] = 8;

if(2 == N)V[0] = 16;

if(3 <= N)V[0] = 104;

rep(i, 0, 123){

  if(8 + V[i] > 1000)break;

  V[i + 1] = 8 + V[i];

}

for(auto x : S )M[x]++;

for(auto x : V ){

  string T = to_string(x);
  map<char, ll> m;
  C = 1;//cout << T << endl;

  for(auto y : T )m[y]++;

  for(auto z : m ){

    if(z.second > M[z.first]){C = 0;break;}

  }

  if(C == 1)break;

  m.clear();

}

if(C == 1)cout << "Yes";

else cout << "No";

}

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

using namespace std;
using ll = long long;

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

    string S;
    cin >> S;

    map<char, int> digits;
    for (int i = 0; i < S.length(); i++) {
        digits[S[i]]++;
    }

    // for (auto d : digits) {
    // cout << d.first << " " << d.second << endl;
    // }

    if (S.length() >= 3) {
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                for (int k = 1; k < 10; k++) {
                    map<char, int> tmp = digits;
                    if ((i * 100 + j * 10 + k) % 8 == 0) {
                        if (tmp['0' + i] != 0)
                            tmp['0' + i]--;
                        else
                            continue;
                        if (tmp['0' + j] != 0)
                            tmp['0' + j]--;
                        else
                            continue;
                        if (tmp['0' + k] != 0)
                            tmp['0' + k]--;
                        else
                            continue;
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
            }
        }
    } else if (S.length() == 1) {
        if (S[0] == '8') {
            cout << "Yes" << endl;
            return 0;
        } else {
            cout << "No" << endl;
            return 0;
        }
    } else {
        if (((S[0] - '0') * 10 + (S[1] - '0')) % 8 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        if (((S[1] - '0') * 10 + (S[0] - '0')) % 8 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


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

struct fastio{fastio(){cin.tie(nullptr);ios_base::sync_with_stdio(false);std::cout<<std::fixed<<setprecision(10);}}oitsaf;
#define rep(i,n) for(int i=0;i<int(n);++i)
template<class T>std::vector<T>vec(size_t a){return std::vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a,Ts... ts){return std::vector<decltype(vec<T>(ts...))>(a,vec<T>(ts...));}
template<class T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){for(auto const& vi:v)os<<vi<<" ";return os;}

int main() {
  int n, k;
  cin >> n >> k;
  auto dist = vec<int>(n, n);
  cin >> dist;
  vector<int> idx(n - 1);
  iota(begin(idx), end(idx), 1);
  int ans = 0;
  do {
    int tmp = dist[0][idx[0]];
    rep(i, n - 2) tmp += dist[idx[i]][idx[i + 1]];
    tmp += dist[idx[n - 2]][0];
    ans += tmp==k;
  } while (next_permutation(begin(idx), end(idx)));
  cout << (ans) << endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll g[20][20];
ll a[20],n,k,res;
bool vis[20];
void dfs(int t)
{
	if(t > n)
	{
		int ans = 0;
		for(int i = 2;i <= n;i++)
		{
			ans += g[a[i-1]][a[i]];
		}
		ans += g[a[n]][1];
		if(ans == k) res++;
	}
	else{
		for(ll i = 2;i <= n;i++)
		{
			if(!vis[i])
			{
				vis[i]=true;
				a[t]=i;
				dfs(t+1);
				vis[i]=false;
				a[t]=0;
			}
		}
	}
}
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i = 1;i <= n;i++)
	{
		for(int j = 1;j <= n;j++)
		{
			scanf("%lld",&g[i][j]);
		}
	}
	a[1]=1;
	vis[1] = true;
	dfs(2);
	printf("%lld",res);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using s64 = signed long long;
using u64 = unsigned long long;
using f128 = long double;
#define LOGVAR(var) cout << #var << ": " <<  var << endl

int main()
{
    vector<s64> a(3);
    cin >> a[0] >> a[1] >> a[2];

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

    if(a[2] - a[1] == a[1] - a[0])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

#define ff                  first
#define ss                  second
#define pb                  push_back
#define eb                  emplace_back
#define mp                  make_pair
#define lb                  lower_bound
#define ub                  upper_bound
#define setbits(x)          __builtin_popcountll(x)
#define zrobits(x)          __builtin_ctzll(x)
#define sz(v)               (int)v.size()
#define ps(y)               cout << fixed << setprecision(y)
#define ms(arr, v)          memset(arr, v, sizeof(arr))
#define all(v)              v.begin(), v.end()
#define rall(v)             v.rbegin(), v.rend()
#define trav(x, v)          for(auto &x: v)
#define w(t)                int t; cin >> t; while(t--)
#define rep0(i, n)          for(int i = 0; i < n; i++)
#define rrep0(i, n)         for(int i = n - 1; i >= 0; i--)
#define rep1(i, n)          for(int i = 1; i <= n; i++)
#define rrep1(i, n)         for(int i = n; i > 0; i--)
#define inp(arr, n)         rep0(i, n) cin >> arr[i];
#define rep(i, a, b)        for(int i = a; i <= b; i++)
#define rrep(i, a, b)       for(int i = a; i >= b; i--)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef map<ll, ll> mii;
typedef map<char, ll> mci;
typedef priority_queue<ll> pq_mx;
typedef priority_queue<ll, vi, greater<>> pq_mn;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> pbds;
/*
 * find_by_order(i) -> returns an iterator to the element at ith position (0 based)
 * order_of_key(i)  -> returns the position of element i (0 based)
 */

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll inf = 1e18;

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

void fio() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
}

int main() {
    fio();

    vi a(3);
    inp(a, 3)
    sort(all(a));
    if(a[1] - a[0] == a[2] - a[1]) cout<<"Yes";
    else cout<<"No";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    stack<pair<int,int>> st;
    st.push({v[0],0});
    vector<int> right(n,-1);
    vector<int> left(n,-1);
    for(int i=1;i<n;i++){
        while(!st.empty() && st.top().first>v[i]){
            right[st.top().second]=i;
            st.pop();
        }
        st.push({v[i],i});
    }
    while(!st.empty()){
        st.pop();
    }
    st.push({v[n-1],n-1});
    for(int i=n-2;i>=0;i--){
        while(!st.empty() && st.top().first>v[i]){
            left[st.top().second]=i;
            st.pop();
        }
        st.push({v[i],i});
    }
    int ans=0;
    for(int i=0;i<n;i++){
         if(left[i]==-1 && right[i]==-1){
            ans=max(ans,v[i]*n);
         }
         else if(left[i]==-1 && right[i]!=-1){
            ans=max(ans,v[i]*right[i]);
         }
         else if(right[i]==-1 && left[i]!=-1){
            ans=max(ans,v[i]*(n-left[i]-1));
         }
         else{
            ans=max(ans,v[i]*(right[i]-left[i]-1));
         }
    }
    cout<<ans<<endl;
    return 0;
}

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

int calc_points(string s)
{
	//cout << "b";
	int res = 0;
	vector<int> c(10,0);
	rep(i,5)
	{
		c[s[i]-'0']++;
	}
	for (int i = 1; i <= 9; ++i)
	{
		int t = i;
		rep(j,c[i])
		{
			t *= 10;
		}
		res += t;
	}
	//cout << "c";
	return res;
}

int main()
{
	int K;
	cin >> K;
	rep(i,9)
	{
		cnt[i+1] = K;
	}
	string S,T;
	cin >> S >> T;
	rep(i,4)
	{
		cnt[S[i]-'0']--;
		cnt[T[i]-'0']--;

	}
	double ans = 0.0;
	for (int i = 1; i <= 9; ++i)
	{
		if (cnt[i] < 1) continue;
		char new_c = '0'+i;
		S[4] = new_c;
		int S_point = calc_points(S);
		for (int j = 1; j <= 9; ++j)
		{
			if ((i == j && cnt[j] < 2) || (i != j && cnt[j] < 1)) continue;
			char new_c2 = '0'+j;
			T[4] = new_c2;
			int T_point = calc_points(T);
			if (S_point > T_point)
			{
			 	if (i != j) ans += double(cnt[i])/double(9*K-8) * double(cnt[j])/double(9*K-9);
				else ans += double(cnt[i])/double(9*K-8) * double(cnt[j]-1)/double(9*K-9);
			}
		}
		//cout << "a";
	}
	cout << setprecision(10) << ans << endl;
	return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
//#include <unistd.h>
void solve(){
        int n;
        cin>>n;
        V<int> a(n);
        for(int i=0;i<n;i++){
                cin>>a[i];
                a[i]--;
        }
        int t=0;
        V<int> ans;
        V<bool> ok(n,false);
        while(1){
              bool ok=true;
                for(int j=0;j<n;j++){
                        if(a[j]<j){
                              ok=false;
                               if(j%2==t){
                                      if(t==0){
                                             swap(a[0],a[1]);
                                             ans.emplace_back(1);
                                      }else{
                                            swap(a[1],a[2]);
                                            ans.emplace_back(2);
                                      }
                                      t^=1;
                               }
                               while(a[j]<j){
                                       swap(a[j-1],a[j]);
                                       ans.emplace_back(j);
                                       j--;
                                       t^=1;
                               }
                               break;
                        }
                }
                if(ok)break;
        }
      //  print(a);
        cout<<ans.size()<<"\n";
        print(ans);
}
int main(){
      int t;
      cin>>t;
      while(t--)solve();
}

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, a, N) for (int i = (a); i< N; i++)

typedef pair<int, int> pii;

int N;

int main() {
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(N);
    int cnt[100001];
    memset(cnt, 0, sizeof(cnt));
    rep (i, 1, N+1) cin >> a[i];
    rep (i, 1, N+1) cin >> b[i];
    rep (i, 1, N+1) cin >> c[i], cnt[b[c[i]]]++;
    long long ans = 0;
    rep (i, 1, N+1) {
        ans += cnt[a[i]];
    }
    cout << ans << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN=505;

int n,p[MAXN];
int opt[MAXN*MAXN],m;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch))(ch=='-')&&(f=-f),ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline int find(int x){
	for(int i=1;;++i) if(p[i]==x) return i;
}
inline bool do_til(int now,int tar,int &oe){
	int i;bool flag=0;
	if(now==tar) return 1;
	if(((now-1)&1)==oe&&now>tar) for(i=now,flag=1;i>tar;--i) swap(p[i-1],p[i]),opt[++m]=i-1,oe^=1;
	if(((now)&1)==oe&&now<tar)for(i=now,flag=1;i<tar;++i) swap(p[i],p[i+1]),opt[++m]=i,oe^=1;
	return flag;
}
inline bool randswap(int now,int &oe){
	if(oe){
		if(now&1) swap(p[now+2],p[now+3]),opt[++m]=now+2;
		else swap(p[now+1],p[now+2]),opt[++m]=now+1;
	}else{
		if(now&1) swap(p[now+1],p[now+2]),opt[++m]=now+1;
		else swap(p[now+2],p[now+3]),opt[++m]=now+2;
	}
	oe^=1;
	return 1;
}

inline void solve(){
	int i,oe=1;
	n=read();m=0;
	for(i=1;i<=n;++i) p[i]=read();
//	printf("%d\n",n);
//	for(i=1;i<=n;++i) printf("%d ",p[i]);
	for(i=1;i<=n-2;++i){
		while(!do_til(find(i),i,oe))
			randswap(i-1,oe);
	}
	if(p[n-1]==n-1);
	else if(((n-2)&1)==oe){
		opt[++m]=n-2;
		opt[++m]=n-1;
		opt[++m]=n-2;
		opt[++m]=n-1;
		opt[++m]=n-2;
	}else opt[++m]=n-1;
//	puts("");
	printf("%d\n",m);
	for(i=1;i<=m;++i) printf("%d ",opt[i]);puts("");
}

int main(){
//	freopen("data.in","r",stdin);
//	freopen("1.out","w",stdout);
	for(int T=read();T;--T)
		solve();
	return 0;
}
/*
2
5
4 1 2 3 5
10
1 4 3 2 5 6 9 7 8 10

*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);

template< int mod = 1000000007 >
struct ModInt {
	int x;
	ModInt() : x(0) {}
	ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % 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 = (int) (1LL * x * p.x % mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p) {
		*this *= p.inverse();
		return *this;
	}

	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; }
	bool operator==(const ModInt &p) const { return x == p.x; }
	bool operator!=(const ModInt &p) const { return x != p.x; }

	ModInt inverse() const {
		int a = x, b = mod, u = 1, v = 0, t;
		while(b > 0) {
			t = a / b;
			swap(a -= t * b, b);
			swap(u -= t * v, v);
		}
		return ModInt(u);
	}

	ModInt pow(int64_t n) const {
		ModInt ret(1), mul(x);
		while(n > 0) {
			if(n & 1) ret *= mul;
			mul *= mul;
			n >>= 1;
		}
		return ret;
	}

	friend ostream &operator<<(ostream &os, const ModInt &p) {
		return os << p.x;
	}

	friend istream &operator>>(istream &is, ModInt &a) {
		int64_t t;
		is >> t;
		a = ModInt< mod >(t);
		return (is);
	}

	static int get_mod() { return mod; }
};

// const int mod = 1000000007;
const int mod = 998244353;
using mint = ModInt< mod >;
const int MAX = 300005;

mint fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i;
	}
	finv[MAX-1] = fac[MAX-1].inverse();
	for(int i=MAX-2;i>=1;i--){
		finv[i] = finv[i+1]*(i+1);
		inv[i+1] = fac[i]*finv[i+1];
	}
}

// 二項係数計算
mint COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k]);
}

mint ans = 0;
ll n,m;
unordered_map<int,int> mp[200020];
vector<int> prime;
bool not_prime[MAX];
void era(){
	not_prime[0]=not_prime[1]=1;
	for(int i=2;i*i<MAX;i++){
		if(not_prime[i])continue;
		for(int j=i+i;j<MAX;j+=i){
			not_prime[j]=1;
		}
	}
	for(int i=2;i<MAX;i++)if(not_prime[i] == false)prime.push_back(i);
}
mint dfs(ll now,int cnt,ll ma,mint p){
	// if(mp[now][cnt]){
	// 	return mp[now][cnt];
	// }
	mint ret = p;
	for(ll i=ma+1;i<(int)prime.size();i++){
		ll x = now*prime[i];
		if(x > m)break;
		int c = cnt+1;
		int cc = 1;
		while(x<=m){
			cc++;
			ret += dfs(x,c,i,p*COM(n+cc-2,cc-1));
			x *= prime[i];
			c++;
		}
	}
	// mp[now][cnt]=ret.x;
	// cerr << now << " " << ret << endl;
	return ret;
}

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

	int n,m;
	cin>>n>>m;
	COMinit();
	mint dp[20][5005];
	dp[0][0]=1;
	for(int i=0;i<19;i++){
		for(int j=0;j<=n;j+=2){
			for(int k=0;k<=m;k++){
				int sum = k + (1<<i)*j;
				if(sum <= m){
					dp[i+1][sum] += dp[i][k] * COM(n,j);
				}
			}
		}
	}
	cout << dp[19][m] << endl;
}


#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <math.h>
#include <string.h>
#include <cstdlib>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <fstream>

typedef long long ll;

#define INF 10000000;

using namespace std;

vector<int> insertVector(int n)
{
    vector<int> x;
    for(ll i = 0; i < n; i++)
    {
        int y;
        cin >> y;
        x.push_back(y);
    }

    return x;
}

void displayVector(vector<int> x)
{
    for(auto i : x)
        cout << i << " ";

    cout << "\n";
}

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

    ll n, k;
    double ans = 0;
    cin >> n >> k;
    vector<pair<ll,ll>> x;
    for(ll i = 0; i < n; i++)
    {
        ll y, z;
        cin >> y >> z;
        x.push_back(make_pair(y, z));
    }

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

    /*for(auto i : x)
    {
        cout << i.first <<  " " << i.second << endl;
    }*/

    for(ll i = 0; i < n; i++)
    {
        if(x[i].first == x[i - 1].first)
        {
            k = k + x[i].second;
        }

        else if((ans + k) - x[i].first < 0)
        {
            ans = ans + k;
            k = 0;
            break;
        }

        else
        {
            k = (ans + k) - x[i].first + x[i].second;
            ans = x[i].first;
        }

    }

    if(k > 0)
        ans = ans + k;

    cout << setprecision(100) << ans;

}

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> ab(n);
    rep(i, 0, n) cin >> ab[i].first >> ab[i].second;
    sort(ab.begin(), ab.end());
    rep(i, 1, n) {
        if(ab[i].first == ab[i - 1].first) {
            ab[i].second += ab[i - 1].second;
            ab[i - 1].first = 0;
            ab[i - 1].second = 0;
        }
    }

    ll ans = 0;
    rep(i, 0, n) {
        if((ans + k) - ab[i].first < 0) {
            ans += k;
            break;
        }
        k -= (ab[i].first - ans);
        k += ab[i].second;
        ans += (ab[i].first - ans);

        if(i == n - 1) ans += k;
    }

    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
int _ = (cout << fixed << setprecision(9), cin.tie(0), ios::sync_with_stdio(0));
using Int = long long;
void solve(int N, string S, vector<int> A) {
    int k = 1e9;
    for (int i = 0; i < N; i++) {
        k = min(k, abs(A[i + 1] - A[i]));
    }
    vector<vector<int>> B(k, vector<int>(N + 1));
    for (int i = 0; i < N + 1; i++) {
        for (int j = 0; j < k; j++) {
            B[j][i] += A[i] / k;
        }
        for (int j = 0; j < A[i] % k; j++) {
            B[j][i] += 1;
        }
    }
    cout << k << '\n';
    for (int j = 0; j < k; j++) {
        for (int i = 0; i < N + 1; i++) {
            cout << B[j][i] << " \n"[i + 1 == N + 1];
        }
    }
}
int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<int> A(N + 1); for (auto &a : A) cin >> a;
    solve(N, S, A);
    return 0;
}

#include<iostream>
#include<cstring>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long LL;
const int N=2e5+10;
int a[N];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d",&a[i]);
	}
	a[++m]=0;
	a[++m]=n+1;
	sort(a+1,a+1+m);
	int minv=n;
	for(int i=1;i<=m-1;i++){
		if(a[i+1]>a[i]+1)
		minv=min(a[i+1]-a[i]-1,minv);
	}
	int cnt=0;
	for(int i=1;i<=m-1;i++){
		if(a[i+1]>a[i]+1)
		cnt+=(a[i+1]-a[i]-1+minv-1)/minv;
	}
	cout<<cnt;
}