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

#define rep(i, init, end) for(ll i = init; i < end; i++)
#define REP(i, init, end) for(ll i = init; i < end + 1; i++)
#define rev(i, end, init) for(ll i = init - 1; i >= end; i--)
#define REV(i, end, init) for(ll i = init; i >= end; i--)
#define PI 3.14159265359
// #define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;

#define INF 1 << 30

int main(){
    ll H, W;
    cin >> H >> W;

    string A[H];
    rep(i, 0, H){
        cin >> A[i];
    }

    ll diff = 0;
    ll dp[H][W];
    rep(i, 0, H){
        rep(j, 0, W){
            dp[i][j] = INF;
        }
    }
    dp[H - 1][W - 1] = 0;

    rev(i, 0, H){
        rev(j, 0, W){
            if(i == H - 1 && j == W - 1){
                continue;
            }

            if(i == H - 1){
                if((i + j) % 2 == 1){
                    dp[i][j] = (A[i][j + 1] == '+' ? -1 : 1) + dp[i][j + 1];
                }else{
                    dp[i][j] = (A[i][j + 1] == '+' ? 1 : -1) + dp[i][j + 1];
                }
            }else if(j == W - 1){
                if((i + j) % 2 == 1){
                    dp[i][j] = (A[i + 1][j] == '+' ? -1 : 1) + dp[i + 1][j];
                }else{
                    dp[i][j] = (A[i + 1][j] == '+' ? 1 : -1) + dp[i + 1][j];
                }
            }else{
                if((i + j) % 2 == 1){
                    dp[i][j] = min((A[i][j + 1] == '+' ? -1 : 1) + dp[i][j + 1], (A[i + 1][j] == '+' ? -1 : 1) + dp[i + 1][j]);
                }else{
                    dp[i][j] = max((A[i][j + 1] == '+' ? 1 : -1) + dp[i][j + 1], (A[i + 1][j] == '+' ? 1 : -1) + dp[i + 1][j]);
                }
            }
        }
    }

    if(dp[0][0] > 0){
        cout << "Takahashi" << endl;
    }else if(dp[0][0] < 0){
        cout << "Aoki" << endl;
    }else{
        cout << "Draw" << endl;
    }

    return 0;
}

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

#include <bits/stdc++.h>

// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
void YES(bool t=true) {cout<<(t?"YES":"NO")<<endl;}
void Yes(bool t=true) {cout<<(t?"Yes":"No")<<endl;}
void yes(bool t=true) {cout<<(t?"yes":"no")<<endl;}
void NO(bool t=true) {cout<<(t?"NO":"YES")<<endl;}
void No(bool t=true) {cout<<(t?"No":"Yes")<<endl;}
void no(bool t=true) {cout<<(t?"no":"yes")<<endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
int popcount(ll t) { return __builtin_popcountll(t); }
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {0, 1, 0, -1}, dy = {-1, 0, 1, 0};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
struct Setup_io {
    Setup_io() {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        cout << fixed << setprecision(25);
    }
} setup_io;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

void solve(vector<pii> wv, vi x) {
    sort(all(x));

    ll ans = 0;
    for (pii temp: wv) {
        int w = temp.first, v = temp.second;
        rep (i, x.size()) {
            if (x[i] >= w) {
                ans += v;
                x.erase(x.begin() + i);
                break;
            }
        }
    }
    cout << ans << endl;
}

signed main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<pii> wv(n);
    rep (i, n) {
        cin >> wv[i].first >> wv[i].second;
    }
    sort(all(wv), [&](pii a, pii b) {
        return a.second > b.second;
    });

    vi x(m);
    rep (i, m) cin >> x[i];

    while (q--) {
        vi X;
        int l, r;
        cin >> l >> r;
        l--;
        rep (i, m) {
            if (in(i, l, r)) continue;
            X.push_back(x[i]);
        }

        solve(wv, X);
    }
}


// #pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

using namespace std;
using ll = long long;
using pii = pair<int, int>;
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...); cout<<'\n';}
template<typename T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } // set a = min(a,b)
template<typename T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

template <int MOD>
struct ModInt {
    int val;
    // constructor
    ModInt(ll v = 0) : val(int(v % MOD)) {
        if (val < 0) val += MOD;
    };
    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }
    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(ll n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }
    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = int(ll(val) * x.val % MOD);
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }
    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }
    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};
using mint = ModInt<int(998244353)>;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin>>n>>m;
    mint ans=0;
    int M=m+n;
    vector<mint> fac(M+1), inv(M+1);
    fac[0]=1;
    for (int i=1; i<=M; i++) {
        fac[i]=fac[i-1]*i;
    }
    inv[M]=fac[M].inv();
    for (int i=M-1; i>=0; i--) inv[i]=inv[i+1]*(i+1);
    auto C=[&](int n, int m) -> mint {
        return fac[n]*inv[m]*inv[n-m];
    };
    for (int i=1; i<=m; i++) {
        mint tmp=1;
        int x=i;
        for (int f=2; f*f<=x; f++) {
            int cnt=0;
            while (x%f==0) x/=f, cnt++;
            tmp*=C(cnt+n-1, n-1);
        }
        if (x>1)
            tmp*=C(1+n-1, n-1);
        ans+=tmp;
    }
    cout<<ans;
    return 0;
}

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define endl '\n'

using namespace std;

const int mod = 998244353;

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

    return a;
}

int fast_pow(int x, int deg)
{
    int ans = 1, y = x;
    while (deg)
    {
        if (deg & 1)
            ans = 1ll * ans * y % mod;

        deg >>= 1;
        y = 1ll * y * y % mod;
    }

    return ans;
}

int n, m;
void read()
{
	cin >> n >> m;
}

const int maxn = 2e5 + 3;
const int maxlog = 20;

int fact[maxn], inv_fact[maxn];
void precompute()
{
    fact[0] = 1;
    for (int i = 1; i < maxn; i++)
        fact[i] = 1ll * fact[i-1] * i % mod;

    inv_fact[maxn-1] = fast_pow(fact[maxn-1], mod-2);
    for (int i = maxn-2; i >= 0; i--)
        inv_fact[i] = 1ll * inv_fact[i+1] * (i + 1) % mod;
}

int comb(int a, int b)
{
    if (b > a)
        return 0;

    return 1ll * fact[a] * inv_fact[b] % mod * inv_fact[a-b] % mod;
}

int f[maxn][maxlog];
vector <int> d[maxn];

void solve()
{
    precompute();

    for (int i = 1; i <= m; i++)
    for (int j = i + i; j <= m; j += i)
    d[j].push_back(i);

    f[1][1] = 1;
    for (int i = 2; i <= m; i++)
    {
        f[i][1] = 1;
        for (int j = 2; j < maxlog; j++)
            for (auto k: d[i])
                f[i][j] = add(f[i][j], f[k][j-1]);
    }

    int ans = 0;
    for (int i = 1; i <= m; i++)
    for (int j = 1; j < maxlog; j++)
        ans = add(ans, 1ll * f[i][j] * comb(n-1, j-1) % mod);

    cout << ans << endl;
}

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

	read();
	solve();
}


#include<iostream>

using namespace std;

int main(){

	int n;
	cin >> n;
	cout << (n + 99) / 100 << endl;

	return 0;
}

#include<bits/stdc++.h>

#define pl(a) " [" << #a << ": " << (a) << "] "
#define pts(a) " [" << #a << ": { first: " << (a.first) << ", second: " << (a.second) << "}] "

#define all(vi) vi.begin(), vi.end()
#define endl "\n"
#define ll long long

using namespace std;

pair<int, int> n4[4] { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };
pair<int, int> n8[8] { {1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {-1, -1}, {-1, 1}, {1, -1} };

ll int h(ll int x1, ll int y1, ll int x2, ll int y2) { return abs(x2 - x1) + abs(y2 - y1); }
ll int pow(ll int x, ll int y) { if (y == 0) return 1; if (y % 2 == 0) { ll int a = pow(x, y / 2); return a * a; } else { int a = pow(x, y / 2); return a * a * x; } return 0;}

template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "[" << p.first << ", " << p.second << "]"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) { cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) { cin >> p.first; return cin >> p.second; }

ll int pow(int x, int y) {
    if (y == 0) return 1;
    if (y % 2 == 0) {
        int a = pow(x, y / 2);
        return a * a;
    } else {
        int a = pow(x, y / 2);
        return a * a * x;
    }
    assert(false);
    return 0;
}

void set_in(string s) {
    if (s.length() > 0) {
        freopen ((s+".in").c_str(), "r", stdin);
        freopen ((s+".out").c_str(), "w", stdout);
    }
}

void solve() {
    int n; cin >> n;
    n--;
    n = max(n, 1);
    n /= 100;
    cout << n + 1 << endl;
}

int main() {
#ifndef DEBUG
    set_in("");
#endif
#ifdef DEBUG
    auto clock_start = chrono::high_resolution_clock::now();
    cout << endl;
#endif

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

    solve();
    // int T; cin >> T;

    // for (int t = 1; t <= T; t++) {
    //     cout << "Case #" << t << ": ";
    //     solve();
    // }

    // Clock
#ifdef DEBUG
    auto clock_end = chrono::high_resolution_clock::now();
    cout << endl;
    chrono::duration<double> elapsed = clock_end - clock_start;
    cout << "Execution time: " << elapsed.count() << "s" << endl;
#endif
    return 0;
}


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

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
// using namespace atcoder;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
using graph = vector<vector<edge>>;
// using graph = vector<vector<int>>;
// using mint = modint1000000007;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define delim(i, n) cout << (i == n-1 ? "\n" : " ")
#define print1(v) cout << fixed << setprecision(10) << v << "\n"
#define print2(v1, v2) cout << fixed << setprecision(10) << v1 << " " << v2 << "\n"
#define print3(v1, v2, v3) cout << fixed << setprecision(10) << v1 << " " << v2 << " " << v3 << "\n"
#define printvi(v, n) REP(iiii, n) { cout << v[iiii]; delim(iiii, n); }
#define printvii(v, h, w) REP(iiiii, h) { printvi(v[iiiii], w); }

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

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

const int maxn = 2e5+10;
int n, m, k;
vi p(maxn);

vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};

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

    cin >> n;
    int cnt = 0;
    REP(i, n) {
        int tmp; cin >> tmp;
        p[tmp] = 1;
        while(p[cnt] > 0) {
            cnt++;
        }
        print1(cnt);
    }
}

#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '.'){
            for(int j = 0; j < i; j++){
                cout << s[j];
            }
            cout << endl;
            return 0;
        }
    }
    cout << s << endl;
    return 0;
}


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

int main() {
    int n;
    scanf("%d", &n);
    puts(n == 191 ? "so-so" : (n < 191 ? "Yay!" : ":("));
    return 0;
}

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

int main() {
	ll n;
	cin >> n;
	vector<ll> ans;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			if (i * i == n) ans.push_back(i);
			else {
				ans.push_back(i);
				ans.push_back(n / i);
			}
		}
	}
	sort(ans.begin(), ans.end());
	rep(i, (int)ans.size()) {
		cout << ans[i] << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define rsort(a) {sort(all(a));reverse(all(a));}
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
vi seg;
ll N;
void init(ll n){
    N=1;
    while(N<n)N*=2;
    seg=vi(N*2-1);
}
void add(ll i,ll x){
    i=N+i-1;
    seg[i]+=x;
    while(i>0){
        i=(i-1)/2;
        seg[i]=seg[i*2+1]+seg[i*2+2];
    }
}
ll getsum(ll a,ll b,ll k,ll l,ll r){
    if(r<=a||b<=l)return 0;
    if(a<=l&&r<=b)return seg[k];
    ll c1=getsum(a,b,k*2+1,l,(l+r)/2);
    ll c2=getsum(a,b,k*2+2,(l+r)/2,r);
    return c1+c2;
}
inline ll readll() {
    ll x = 0;
    char ch = getchar_unlocked();
    while (ch < '0' || ch > '9') ch = getchar_unlocked();
    while (ch >= '0' && ch <= '9'){
		x = (x << 3) + (x << 1) + ch - '0';
		ch = getchar_unlocked();
	}
    return x;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vp v(n);
    rep(i,n){
        ll a,b;cin>>a>>b;
        v[i].fi=a+b;v[i].se=a-b;
    }sort(all(v));
    vi srt(n);rep(i,n)srt[i]=v[i].se;sort(all(srt));
    init(n);
    ll ans=0;
    rep(i,n){
        ll l=lb(srt,v[i].se);
        ans+=getsum(0,l+1,0,0,N);
        add(l,1);
    }
    out(ans);
}

#pragma GCC optimize("Ofast")

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

bool solve()
{
    int n;
    cin >> n;
    vi x(n);
    vi y(n);
    rep(i,n){
        cin >> x[i] >> y[i];
    }

    int ans = 0;
    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            if(abs(y[i]-y[j]) <= abs(x[i]-x[j])){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return true;
}

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


#include <bits/stdc++.h>
using namespace std;
int T , n , a[550] , pl[550] , minn[2] , noww , it , flag , ans[300000] , tot , p[550];
void build( int l )
{
	for(int i = 1 ; i <= n ; i++ ) pl[a[i]] = i;
	minn[1] = minn[0] = 1e9;
	for(int i = l ; i <= n ; i++ ) minn[i & 1] = min(minn[i & 1] , a[i]);
//	for(int i = l ; i <= n ; i++ )
//		if(a[i] == 297) cerr << minn[i & 1] << endl;
	return ;
}
void print( int a )
{
	int qwq = a / 10;
	if(qwq) print(qwq);
	putchar(a - (qwq << 1) - (qwq << 3) + '0');
	return ;
}
void run( int pl )
{
	ans[++tot] = pl - 2; swap(a[pl - 2] , a[pl - 1]);
	ans[++tot] = pl - 1; swap(a[pl - 1] , a[pl]);
	ans[++tot] = pl - 2; swap(a[pl - 2] , a[pl - 1]);
	ans[++tot] = pl - 1; swap(a[pl - 1] , a[pl]);
}
void walk( int pl )
{
	ans[++tot] = pl - 2; swap(a[pl - 2] , a[pl - 1]);
	ans[++tot] = pl - 1; swap(a[pl - 1] , a[pl]);
	ans[++tot] = pl - 2; swap(a[pl - 2] , a[pl - 1]);
	ans[++tot] = pl - 1; swap(a[pl - 1] , a[pl]);
	ans[++tot] = pl - 2; swap(a[pl - 2] , a[pl - 1]);
}
int main()
{
//	freopen("1.in" , "r" , stdin);
//	freopen("1.out" , "w" , stdout);
	scanf("%d" , &T);
	while(T--)
	{
//		cerr << 11111;
		scanf("%d" , &n); noww = tot = flag = 0; it = 1;
		for(int i = 1 ; i <= n ; i++ ) scanf("%d" , &a[i]) , p[i] = 1 , flag |= (a[i] != i);
		if(!flag)
		{
//			printf("yes\n");
			if(a[2] == 2) printf("0\n\n");
			continue;
		}
		if(n == 2)
		{
//			printf("yes\n");
			if(a[2] == 2) printf("0\n\n");
			else printf("1\n1\n");
			continue;
		}
		if(a[1] == 1) it = 2 , p[1] = 0;
		build(it);
		while(it <= n)
		{
			int u = minn[noww] , d = 0;
			if(u > 500) u = a[n - (noww ^ (n & 1))];
			p[u] = 0;
			for(int i = 1 ; i < u ; i++ ) d += p[i];
			for(int i = pl[u] - 1 ; i >= u - d ; i-- )
				ans[++tot] = i , swap(a[i] , a[i + 1]) , noww ^= 1;
			it++;
			build(it);
//			for(int i = 1 ; i <= n ; i++ ) cerr << a[i] << ' '; cerr << endl;
		}
		if(a[n] != n)
		{
//			cerr << 111111;
			int pl = n , u = a[n];
			while(pl - u >= 2) run(pl) , pl -= 2;
			if(pl - u == 1) walk(pl);
//			if(pl - u == 1) cerr << a[n] << ' ' << "walk\n";
//			else cerr << a[n] << ' ' << "run\n";
		}
//		for(int i = 1 ; i <= n ; i++ ) cerr << a[i] << ' '; cerr << endl;
		print(tot); printf("\n");
		for(int i = 1 ; i <= tot ; i++ ) print(ans[i]) , putchar(' '); printf("\n");
//		while(1);
//		flag = (tot > n * n);
//		for(int i = 1 ; i <= n ; i++ ) flag |= (a[i] != i);
//		for(int i = 1 ; i <= tot ; i++ ) flag |= (ans[i] == 0);
//		if(flag) printf("no\n");
//		else printf("yes\n");
	}
	return 0;
}
/*
1
4
1 2 3 4
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, p[555], at;
vector<ll> ans;

void sp(ll k){
    ans.push_back(k);
    ll tmp = p[k];
    p[k] = p[k + 1];
    p[k + 1] = tmp;
}

void lst4(){
    if(p[4] == 4)return;
    if(p[3] == 4){
        if(ans.size() % 2 == 0){
            sp(3);
        }else{
            sp(2);
            sp(3);
            sp(2);
            sp(3);
        }
        return;
    }
    if(p[2] == 4){
        if(ans.size() % 2 == 1){
            sp(2);
            sp(3);
        }else{
            sp(3);
            sp(2);
            sp(3);
        }
        return;
    }
    if(p[1] == 4){
        if(ans.size() % 2 == 0){
            sp(1);
            sp(2);
            sp(3);
        }else{
            sp(2);
            sp(1);
            sp(2);
            sp(3);
        }
    }
}

void lst3(){
    while(p[1] != 1 || p[2] != 2){
        if(ans.size() % 2 == 0){
            sp(1);
        }else{
            sp(2);
        }
    }
}

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

    ll T; cin >> T;
    while(T--){
        while(!ans.empty())ans.pop_back();

        cin >> n;
        rep(i, 1, n)cin >> p[i];

        if(n == 2){
            if(p[1] != 1)sp(1);
        }else{
            rrep(i, n, 5){
                if(p[i] == i)continue;

                rep(j, 1, i)if(p[j] == i)at = j;

                if(ans.size() % 2 == 1 && at % 2 == 1){
                    if(at == 3){
                        sp(4);
                    }else{
                        sp(2);
                    }
                }

                if(ans.size() % 2 == 0 && at % 2 == 0){
                    if(at == 2){
                        sp(3);
                    }else{
                        sp(1);
                    }
                }

                rep(j, at, i - 1){
                    sp(j);
                }
            }
            if(n >= 4)lst4();
            lst3();
        }

        print(ans.size())
        zep(j, 0, ans.size())cout << ans[j] << " "; cout << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define pre(i,a,b) for(int i=(b);i>=(a);i--)
#define ios ios::sync_with_stdio(false),cin.tie(0);
#define pb push_back
#define ps push
#define fi first
#define se second
#define ps push
#define Inf 0x3f3f3f3f3f3f3f3f
#define eps 1e-5
typedef long long ll;

const int N=3e5+5;
const int M=2e5+5;
const int mod=998244353;
using namespace std;

ll quick_power_mod(ll a,ll b,ll m)//pow(a,b)%m
{
    a%=m;
  ll result = 1;
  while(b>0)
  {
    if(b&1)
    result=(result*a)%m;
    a=(a*a)%m;
    b>>=1;
  }
  return result;
}
//计算组合数取模
ll comp(ll a,ll b,int p)//composite num C(a,b)%p
{
  if(a<b)return 0;
  if(a==b)return 1;
  if(b>a-b)b=a-b;
  ll ans=1,ca=1,cb=1;
  for(ll i=0;i<b;i++)
  {
    ca=(ca*(a-i))%p;
    cb=(cb*(b-i))%p;
  }
  ans=(ca*quick_power_mod(cb,p-2,p))%p;
  return ans;
}
ll lucas(ll n,ll m,ll p)
{
  ll ans=1;
  while(n&&m&&ans)
  {
    ans=(ans*comp(n%p,m%p,p))%p;//also can be recusive
    n/=p;
    m/=p;
  }
  return ans;
}

ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
string   str;
signed main()
{
  ios;
  int n,q;
  cin>>n>>str>>q;
  int t,a,b;
  int cc=0;
  while(q--){
  	 cin>>t>>a>>b;
  	 if(t==1){
  	 	if(cc%2==0){

  	 	swap(str[a-1],str[b-1]);
		}
		else{
	    if(a<=n){
		a+=n;

		}
		else{
			a-=n;
		}
		if(b<=n){
		b+=n;

		}
		else{
			b-=n;
		}

		swap(str[a-1],str[b-1]);
		}
	 }
	 else{
	 	cc++;
	 //	swap(str[n-1],str[2*n-1]);
	 }
  }
  if(cc%2==0){
  	cout<<str<<endl;
  }
  else{
    for(int i=n;i<2*n;i++){
    	cout<<str[i];
	}
	for(int i=0;i<n;i++){
		cout<<str[i];
	}
	cout<<endl;
  }

  return 0 ;
}

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

#define int long long
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const int N = 1e5 + 5;

struct node{
    int to;
    int cost;
    int k;
    node(int _to, int _cost, int _k){
        to = _to;
        cost = _cost;
        k = _k;
    }
};

vector<node> g[N];

int32_t main() {
    fast;
    int n,m,x,y;
    cin >> n >> m >> x >> y;

    f(i,0,m){
        int u,v,cost,k;
        cin >> u >> v >> cost >> k;
        g[u].pb(node(v, cost, k));
        g[v].pb(node(u, cost, k));
    }

    priority_queue<pii, vector<pii>, greater<pii>> pq;
    vi dis(n+1, 1e18);
    dis[x] = 0;
    pq.push({0, x});

    while(!pq.empty()){
        pii p = pq.top();
        pq.pop();
        int u = p.S;
        int cur = p.F;
        for(int i=0 ; i<g[u].size() ; i++){
            int v = g[u][i].to;
            int cost = g[u][i].cost;
            int k = g[u][i].k;
            int temp = (k - cur % k)%k + cur + cost;
            if(dis[v] > temp){
                dis[v] = temp;
                pq.push({temp, v});
            }
        }
    }

    int ans = dis[y];
    if(ans == 1e18){
        ans = -1;
    }
    cout << ans << "\n";
}


#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pairll = pair<ll, ll>;
using pairint = pair<int, int>;
using vecll = vector<ll>;
using vecvecll = vector<vector<ll>>;
using vecpairll = vector<pair<ll, ll>>;
using vecstring = vector<string>;

#define rep(i, n) for (ll i = (0); i < (n); ++i)
#define Rep(i, a, b) for (ll i = (a); i < (b); ++i)
constexpr ll MOD = 1000000007;

template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first;
  is >> p.second;
  return is;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &&x : v) is >> x;
  return is;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.first << ' ' << p.second;
  return os;
}
template <class T>
ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = begin(v); i != end(v); ++i) {
    if (i != begin(v)) os << ' ';
    os << *i;
  }
  return os;
}
inline ll nizyou(ll x) { return x * x; }
bool isprime(long long N) {
  if (N <= 1) {
    return 0;
  }
  for (long long i = 2; i * i <= N; i++) {
    if (N % i == 0) {
      return 0;
    }
  }
  return 1;
}
map<long long, int> Prime_factorization(long long N) {
  map<long long, int> primefact;
  for (long long i = 2; i * i <= N; i++) {
    ll count = 0;
    while (N % i == 0) {
      count += 1;
      N /= i;
    }
    if (count > 0) {
      primefact[i] = count;
    }
  }
  if (N > 1) {
    primefact[N]++;
  }
  return primefact;
}
//整数の指数の累乗
ll expo(ll a, unsigned long long N) {
  if (N < 1) {
    return 1;
  }
  ll sum = a;
  for (ull i = 1; i < N; ++i) {
    sum *= a;
  }
  return sum;
}

ll modexpo(ll a, unsigned long long N, ll mod) {
  if (N < 1) {
    return 1;
  }

  ll sum = a;
  for (ull i = 1; i < N; ++i) {
    sum = sum * a % mod;
  }
  return sum;
}

template <typename T>
void exchange(T &a, T &b) {
  T c = a;
  a = b;
  b = c;
}

void YesOut() { cout << "Yes" << endl; }
void NoOut() { cout << "No" << endl; }
template <typename T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

//デバッグ用表示関数 基本これを使うこと
template <typename T>
void checkOut(T s) {
  //非表示にするときはfalse 表示するときはtrueへ
  bool frag = false;
  if (frag) {
    cout << s << endl;
  }
}
const double PI = acos(-1);
//０～９のchar型のint変換
int ctoi(char c) { return c - '0'; }
ll ctoll(char c) { return static_cast<ll>(ctoi(c)); }
#define INF 10000000000

int main() {
  ll N, Q;
  string S;
  cin >> N >> S >> Q;
  string s1 = S.substr(0, N);
  string s2 = S.substr(N, N);
  rep(i, Q) {
    ll T, a, b;
    cin >> T >> a >> b;
    if (T == 1) {
      if (b <= N) {
        swap(s1[a - 1], s1[b - 1]);
      } else if (a <= N) {
        swap(s1[a - 1], s2[b - N - 1]);
      } else {
        swap(s2[a - 1 - N], s2[b - 1 - N]);
      }
    }
    if (T == 2) {
      swap(s1, s2);
    }
  }

  cout << s1 + s2 << endl;
  return 0;
}

/**
 *  In The Name Of God
 *  author : Behradm
 *  Idvwhu wkdq idvw, Txlfnhu wkdq txlfn, L dp Oljkwqlqj, Vshhg, L dp Vshhg :D :D
**/
#include "bits/stdc++.h"

using namespace std;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int Q; cin >> Q;

  bool f = 1;
  while (Q--) {
    int t, a, b;
    cin >> t >> a >> b;
    --a, --b;
    if (t == 2) {
      f = !f;
    } else {
      if (!f) {
        if (a < n)
          a += n;
        else
          a -= n;
        if (b < n)
          b += n;
        else
          b -= n;
      }
      swap(s[a], s[b]);
    }
  }

  if (f) {
    cout << s << '\n';
    return 0;
  }

  for (int i = n; i < 2 * n; i++)
    cout << s[i];
  for (int i = 0; i < n; i++)
    cout << s[i];
  cout << '\n';
  return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int max_n = 50;
ll a[50],n,t;
void Solve(int l,int r,vector<ll>& v,ll tmp){
	if (l>r||tmp>t)return;
	if (l==r){
		v.push_back(a[l]+tmp);
		v.push_back(tmp);
		return;
	}
	Solve(l+1,r,v,tmp);Solve(l+1,r,v,tmp+a[l]);
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>t;
	for (int i=1;i<=n;++i)cin>>a[i];
	int mid=n/2;
	vector<ll> lft,rgt;
	Solve(1,mid,lft,0);Solve(mid+1,n,rgt,0);
	lft.push_back(0);rgt.push_back(0);
	sort(lft.begin(),lft.end());
	sort(rgt.begin(),rgt.end());
	ll ans = 0;
	for (int i=0;i<lft.size();++i){
		ll l = lft[i];if (l>t)break;
		auto r = lower_bound(rgt.begin(),rgt.end(),t-l);
		ll rr=0;
		if (r!=rgt.end()){
			rr = *r;
			if (rr!=t-l){
				if (r==rgt.begin())rr=0;
				else rr = *(--r);
			}ans = max(ans,l+rr);
		}
		else ans = max(ans,l+rgt.back());
	}cout<<ans<<endl;
}

#include <bits/stdc++.h>

using namespace std;

const int N = 200000 + 10;

int n, m, a[N];
vector <int> G[N];
int in[N], dp[N];

int main() {
    memset(dp, -1, sizeof(dp));
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++)    scanf("%d", a + i);
    for (int i = 1; i <= m; i++) {
        int u, v;   scanf("%d %d", &u, &v);
        G[u].push_back(v);
        in[v]++;
    }
    queue <int> Q;
    for (int i = 1; i <= n; i++) {
        if (!in[i]) {
            Q.push(i);
            dp[i] = a[i];
        }
    }
    int ans = INT_MIN;
    while (!Q.empty()) {
        int u = Q.front();  Q.pop();
        for (auto v : G[u]) {
            if (~dp[v]) dp[v] = min(dp[v], min(dp[u], a[u]));
            else    dp[v] = min(dp[u], a[u]);
            in[v]--;
            if (!in[v]) Q.push(v);
            ans = max(ans, a[v] - dp[v]);
        }
    }

    printf("%d\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> inline bool chmin(T& a, const T b) {a = min(a, b); return (a == b);}
template <typename T> inline bool chmax(T& a, const T b) {a = max(a, b); return (a == b);}

inline void cls() {}

void solve() {
    cls();

    string s;
    cin >> s;
    cout << s[1] << s[2] << s[0] << "\n";
}

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

    int t = 1;
    #ifdef _LOCAL
        system("color a");
        freopen("in.txt", "r", stdin);
        cin >> t;
    #endif

    for (int i = 1; i <= t; ++i) {
        cerr << "Case #" << i << ": \n";
        solve();
        cerr << "\n";
    }

    return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define all(x) (x).begin(), (x).end()
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define sz(x) (int)((x).size())
#define fr first
#define sc second
#define pii pair<int, int>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define ppc __builtin_popcount
#define ppcll __builtin_popcountll
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

template <typename T_vector>
void output_vector(const T_vector &v, bool addOne = false, int start = -1, int end = -1)
{
	if (start < 0)
		start = 0;
	if (end < 0)
		end = (int)v.size();
	for (int i = start; i < end; i++)
		cout << v[i] + (addOne ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}

int ceil(int x, int y)
{
	return x / y + (x % y > 0);
}

const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;

const int N = 2e5 + 5;

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

	cout << n / 100 + (n % 100 > 0 ? 1 : 0) << "\n";
}

signed main()
{
	fast
#ifndef ONLINE_JUDGE

		// For getting input from input.txt file
		freopen("input.txt", "r", stdin);

	// Printing the Output to output.txt file
	freopen("output.txt", "w", stdout);

#endif
	cout << setprecision(12);
	cout << fixed;

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

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int f[1010][1010], a[1010], b[1010], n, m;

int main() {
	cin >> n >> m;
	for(register int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for(register int j = 1; j <= m; j++) {
		cin >> b[j];
	}
	for(register int i = 1; i <= m; i++) f[0][i] = i;
	for(register int i = 1; i <= n; i++) f[i][0] = i;
	for(register int i = 1; i <= n; i++) {
		for(register int j = 1; j <= m; j++) {
			f[i][j] = min(f[i - 1][j], f[i][j - 1]) + 1;
			if(a[i] == b[j]) f[i][j] = min(f[i][j], f[i - 1][j - 1]);
			else f[i][j] = min(f[i][j], f[i - 1][j - 1] + 1);
		}
	}
	cout << f[n][m] << endl;
	return 0;
}

/*   AUTHOR: julianferres   */
#include <bits/stdc++.h>
using namespace std;

// neal Debugger
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef LOCAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

typedef long long ll;
typedef vector<ll> vi; typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define DBG(x) cerr << #x << " = " << (x) << endl
#define RAYA cerr << "===============================" << endl
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define esta(x,c) ((c).find(x) != (c).end())
const int INF = 1e9+15; // const ll INF = 2e18;
const int MOD = 1e9+7; // 998244353
const int MAXN  = 1005;

vi a(MAXN), b(MAXN);
vector<vi> dp(MAXN, vi(MAXN, -1));

ll solve(ll n,ll m){
    if(dp[n][m]!=-1)
        return dp[n][m];
    if(n==0 || m==0)
        return max(n,m);
    dp[n][m] = min({solve(n-1,m-1)+((ll)(a[n]!=b[m])),solve(n,m-1)+1,solve(n-1,m)+1});

    return dp[n][m];
}

int main(){
	FIN;

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

    forr(i, 1, n+1) cin >> a[i];
    forr(i, 1, m+1) cin >> b[i];

    cout << solve(n,m) << endl;

    return 0;
}


// choker
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
using ul = unsigned long long;
const int maxN = 1e6 + 1;
const int mod = 1e9 + 7;
const int BLOCK_SIZE = 400;
const int LIM = 1e4;
//const int ep = 100;
const lli infty = 1e18;

const lli base = 37;
const int ep = 'a' - 1;

void FastInput()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

void InputFile()
{
    freopen("a.INP","r",stdin);
    //freopen("a.OUT","w",stdout);
}

int n,q;
lli a[maxN];
vector<lli> selct;
map<string,int> apr;

void Read()
{
    cin >> n >> q;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        string trans = to_string(a[i]);
        apr[trans] = 1;
    }
}

void Prc(lli m)
{
    lli mini = 1;
    lli maxi = 1e18 + 1e6;
    while(mini <= maxi)
    {
        lli mid = (mini + maxi) / 2;
        lli k = upper_bound(selct.begin(),selct.end(),mid) - selct.begin();
        if(mid - k == m)
        {
            string trans = to_string(mid);
            if(apr[trans] == 1) maxi = mid - 1;
            else
            {
                cout << mid <<'\n';
                return;
            }
        }
        if(mid - k < m)
        {
            mini = mid + 1;
        }
        if(mid - k > m)
        {
            maxi = mid - 1;
        }
    }
}

void Solve()
{
    sort(a + 1,a + n + 1);
    selct.push_back(a[1]);
    for(int i = 2; i <= n; i++)
    {
        if(a[i] != a[i-1]) selct.push_back(a[i]);
    }
    while(q--)
    {
        lli m;
        cin >> m;
        Prc(m);
    }
}

void Debug()
{

}

int main()
{
    FastInput();
    //InputFile();
    int test;
    //cin >> test;
    test = 1;
    while(test--)
    {
        Read();
        Solve();
        Debug();
    }
}

#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <numeric>
#include <climits>
using namespace std;

int main(int argc, char* argv[]){
	long long n,q;
	cin>>n>>q;
	vector<long long>a(n);
	vector<long long>query(q);
	vector<pair<long long,long long>> p;
	pair<long long, long long> p_;
	p_.first = 1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(p_.first==a[i]){
			p_.first = a[i]+1;
		}else{
			p_.second = a[i]-1;
//			cout<<p_.first<<" "<<p_.second<<endl;
			p.push_back(p_);
			p_.first = a[i]+1;
		}
		if(i==n-1){
			p_.second = LLONG_MAX;
//			cout<<p_.first<<" "<<p_.second<<endl;
			p.push_back(p_);
		}
	}
	vector<long long> len;
	long long len_ = 0;
	for(long long i=0;i<p.size();i++){
		len_ += p[i].second - p[i].first +1;
		len.push_back(len_);
//		cout<<len_<<endl;
	}
	for(long long i=0;i<q;i++){
		cin>>query[i];
	}

	for(auto q_ : query ){
		auto itr = lower_bound(len.begin(),len.end(), q_);
		long long idx = distance(len.begin(),itr);
		long long idx_;
		if(idx==0){
			idx_ = q_ - 1;
		}else{
			idx_ = q_ - len[idx-1] -1;
		}
//		cout<<q_<<" "<<idx<<" "<<idx_<<endl;

		long long ans = p[idx].first+idx_;
		cout<<ans<<endl;
	}

}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int) 1e9 + 23111992;
const ll LINF = (ll) 1e18 + 23111992;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int mrand() {return abs((int) mt());}
inline int mrand(int k) {return abs((int) mt()) % k;}
#define db(x) cerr << "[" << #x << ": " << (x) << "] ";
#define endln cerr << "\n";

void chemthan() {
    int n; cin >> n;
    vector<string> s(n);
    FOR(i, 0, n) cin >> s[i];
    vector<vi> g(n, vi(n));
    FOR(i, 0, n) g[i][i] = 1;
    FOR(i, 0, n) FOR(j, 0, n) if (i != j) {
        g[i][j] = s[i][j] == '1';
    }
    FOR(k, 0, n) FOR(i, 0, n) FOR(j, 0, n) {
        g[i][j] |= g[i][k] & g[k][j];
    }
    double res = 0;
    FOR(i, 0, n) {
        int num = 0;
        FOR(j, 0, n) if (i ^ j) {
            if (g[j][i]) {
                num++;
            }
        }
        res += 1.0 / (num + 1);
    }
    cout << prec(9) << res << "\n";
}

int32_t main(int32_t argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

const int N = 100+19;
int g[N][N],vis[N],val[N],n;

void dfs(int u) {
  ++val[u];
  vis[u] = 1;
  for(int i = 1 ; i <= n ; ++i)
    if(g[u][i] && !vis[i])
      dfs(i);
}

void solve() {
  cin >> n;
  for(int i = 1 ; i <= n ; ++i) {
    string s;
    cin >> s;
    for(int j = 1 ; j <= n ; ++j)
      if(s[j-1] == '1')
        g[i][j] = 1;
  }

  for(int i = 1 ; i <= n ; ++i) {
    for(int j = 1 ; j <= n ; ++j) vis[j] = 0;
    dfs(i);
  }
  double ans = 0;
  for(int i = 1 ; i <= n ; ++i) ans += 1.0 / val[i];

  printf("%.12lf\n",ans);
}

int main() {
  int T = 1;
  ios::sync_with_stdio(0);
  //cin >> T;
  while(T--) solve();
  return 0;
}


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

int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector<int> a(2*n);
    for(int i=0;i<2*n;++i) cin>>a[i];
    ll ans=0;
    priority_queue<int,vector<int>,greater<int>> q;
    for(int i=n-1;i>=0;--i) {
        int l=a[i],r=a[2*n-1-i];
        if(l>r) swap(l,r);
        if(!q.empty() && q.top()<l) {
            ans-=q.top(),q.pop();
            q.push(l);ans+=l;
        }
        q.push(r);ans+=r;
    }
    cout<<ans<<endl;
}

#include<bits/stdc++.h>
#define FORz(i,t,n) for(int i=t;i<=n;i++)
#define FORf(i,n,t) for(int i=n;i>=t;i--)
#define SCC(x) scanf("%d",&x)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
using namespace std;
const int N=1e5+5;
const ll MOD=1e9+7;
// inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
//ll pow1(ll a,ll b){ll r=1;while(b){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
//ll pow2(ll a,ll b,ll mod){ll r=1;while(b){if(b&1)r=r*a%mod;a=a*a%mod;b>>=1;}return r%mod;}
//ll gcd(ll a,ll b){ll m=a%b;while(m){a=b;b=m;m=a%b;}return b;}
//void exgcd(ll a, ll b, ll &d, ll &x, ll &y){if(!b) { d = a; x = 1; y = 0;}else { exgcd(b, a % b, d, y, x); y -= x * (a / b); }}
//ll inv(ll a){ll d, x, y;exgcd(a, MOD, d, x, y);return d == 1 ? (x + MOD) % MOD : -1;}struct node{ll mat[105][105];};node mul(node x,node y,int n,ll mod){node tmp;for(int i=0;i<n;i++)for(int j=0;j<n;j++){tmp.mat[i][j]=0;for(int k=0;k<n;k++)tmp.mat[i][j]+=(x.mat[i][k]*y.mat[k][j])%mod;tmp.mat[i][j]%=mod;}return tmp;}
// node matpow(node x,node y,ll num,int n,ll mod){while(num){if(num&1){y=mul(x,y,n,mod);}x=mul(x,x,n,mod);num=num>>1;}return y;}
//for(ll i=2;i<N-1;i++){if(!a[i]) b[++cnt]=i;for(ll j=1;j<=cnt&&i*b[j]<N;j++){a[i*b[j]]=1;if(i%b[j]==0) break;}}
//int find(int x){return a[x]==x?x:a[x]=find(a[x]);}
//void merge(int x,int y){a[find(y)]=a[find(x)];}
ll n;
ll a[N];
int main()
{
    cin>>n;
    FORz(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    ll sum=1;
    FORz(i,1,n) sum=sum*(a[i]-a[i-1]+1)%MOD;
    cout<<sum;
}


#include<iostream>
#include<vector>
#include<cstdlib>
#include<algorithm>
#include<climits>
#include<queue>
#include<stack>
#include<cmath>
#include<iterator>
#include<set>
typedef long long ll;
using namespace std;
#define rep(x, y)   for (ll i = x; i < y; i ++)
#define repi(x, y)  for (ll i = x; i > y; i --)
#define si(x) ll x;cin>>x
ll arr[200005];
vector<ll> brr[100005];
ll crr[100005];
ll drr[100005];
set<int, greater<int> > num;
set<int, greater<int> >::iterator numitr;

int main()
{
    ll test = 1;
    // cin>>test;
    for(ll z=0;z<test;z++)
    {
        si(n);
        for(ll i=0;i<=n;i++)
        {
            crr[i] = 0;
            drr[i] = -1;
        }
        for(ll i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        for(ll i=0;i<n;i++)
        {
            si(a);
            brr[a].push_back(i+1);
        }
        for(ll i=0;i<n;i++)
        {
            ll a;
            cin>>a;
            crr[a]++;
        }
        ll counter =0;
        for(ll i=0;i<n;i++)
        {
            if(drr[arr[i]] == -1)
            {
                ll prevcounter = counter;
                for(ll j = 0;j<brr[arr[i]].size();j++)
                {
                    counter += crr[brr[arr[i]][j]];
                }
                drr[arr[i]] = counter - prevcounter;
            }
            else
            {
                counter += drr[arr[i]];
            }
        }
        cout<<counter<<endl;

    }

}

#include <algorithm>
#include <vector>

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

using namespace std;

int main(){

    //int a, b, c;
    int n;

    cin >> n;

    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    int t;

    for(int i=0;i<n;i++){
        cin >> t;
        a[i]=t-1;
    }
    for(int j=0;j<n;j++){
        cin >> t;
        b[j]=t-1;
    }
    for(int k=0;k<n;k++){
        cin >> t;
        c[k]=t-1;
    }

    vector<int> count(n);
    for (int j = 0; j < n; ++j) {
        count[b[c[j]]] += 1;
    }
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += count[a[i]];
    }
    cout << ans << '\n';

    return 0;
}


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

map<char,char> win{{'R','P'}, {'P','S'}, {'S','R'}}; // [lose]=win

int main(){
	int N, K; string S; cin>>N>>K>>S;
	while(K--){
		string t = S + S;
		rep(i, N){
			char a = t[i*2], b = t[i*2+1];
			S[i] = win[a]==b? b:a;
		}
	}
	cout<< S[0] <<endl;
}

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

int main(){
	long long a,b,c,d;cin>>a>>b>>c>>d;
	cout<<min(a,min(b,min(c,d)))<<"\n";
	return 0;
}


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

int h, w, a, b, ans = 0;

void dfs(int i, int bit, int a, int b) {
    if (i == h*w) {
        ans++;
        return;
    }

    if (bit & 1 << i) {
        dfs(i+1, bit, a, b);
        return;
    }

    if (b) dfs(i+1, bit | 1 << i, a, b-1);
    if (a) {
        if (i%w != w-1 && ~bit & 1 << i+1) dfs(i+1, bit | 1 << i | 1 << i+1, a-1, b);
        if (i/w != h-1 && ~bit & 1 << i+w) dfs(i+1, bit | 1 << i | 1 << i+w, a-1, b);
    }
}

int main(void){
    cin >> h >> w >> a >> b;
    dfs(0, 0, a, b);
    cout << ans << endl;
    return 0;
}

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif

#if __cplusplus >= 201402L
#define lambda(e) ([&](const auto &_){ return (e); })
#define lambda2(e) ([&](const auto &_a, const auto &_b){ return (e); })
#endif

#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8

void mainmain(){
	LL x, y;
	cin >> x >> y;
	LL ans = abs(x - y);
	for(int i = 1; x <= y; ++i){
		x *= 2;
		LL d = abs(y - x);
		LL res = i;
		for(int j = 0; j <= i; ++j){
			if(d >> j & 1){
				++res;
				if(j < i - 2 && (d >> (j + 1) & 3) == 3){
					d += 1LL << j;
				}
				else{
					d -= 1LL << j;
				}
			}
		}
		res += d >> i;
		chmin(ans, res);
	}
	cout << ans << endl;
}

}
int main() {
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAXN = 1000002;
const int MOD2 = 998244353;
const int MOD = 1000000007;
const int INF = 1e8;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
#define fill(x,y) memset(x,y,sizeof(x))
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll mul(ll x, ll y)
{
    return (x * 1ll * y) % MOD;
}

ll fastpow(ll x, ll y)
{
    ll z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}
ll modinv(ll n,ll p)
{
	return fastpow(n,p-2) ;
}
struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second >b.second;
  }
};

int main(int argc, char** argv)
{   sws ;
 // cout<<setprecision(10);
//  ll google=0 ;
   // tcase
    {
    ll n,k ;
    cin>>n>>k ;
    vector<pair<ll,ll>>p;
    forn(i,n)
    {
    	ll x,y ;
    	cin>>x>>y ;
    	p.pb({x,y}) ;
	}
	sort(p.begin(),p.end()) ;
	ll cur=0 ;
	forn(i,n)
	{
		if(cur+k>=p[i].ff)
		{   k-=(p[i].ff-cur) ;
			cur=p[i].ff ;
			k+=p[i].ss ;
		}
	}
	cur+=k ;
	cout<<cur<<"\n";
    }
return 0 ;
}

#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
struct num{
	ll a;
	int b;
	bool operator<(const num& k)const
	{
		return a<k.a;
	}
}nzk[200500];
int main()
{
	int n,flag=0;
	ll k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>nzk[i].a>>nzk[i].b;
	}
	nzk[0].a=0,nzk[0].b=0;
	sort(nzk+1,nzk+n+1);
	for(int i=1;i<=n;i++)
	{
		if(k>=nzk[i].a)
		{
			k+=nzk[i].b;
		}
		else
		{
			break;
		}
}
	cout<<k<<'\n';
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,l,r,mid;
	scanf("%lld",&n),l=1,r=n;
	while(l<r){
		mid=(l+r+1)>>1;
		if(mid+1<=((n+1)<<1)/mid)l=mid;
		else r=mid-1;
	}printf("%lld\n",n+1-r);
	return 0;
}

// Problem: B - log
// Contest: AtCoder - AtCoder Regular Contest 109
// URL: https://atcoder.jp/contests/arc109/tasks/arc109_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin() , (x).end()

void dbg(){
	cerr << endl;
}
template<typename Head , typename... Tail>
void dbg(Head h , Tail... t){
	cerr << h << " ";
	dbg(t...);
}

#ifdef EMBI_DEBUG
#define debug(...) cerr << "(" << #__VA_ARGS__  << "): ", dbg(__VA_ARGS__)
#else
#define debug(...)
#endif

const int max_n = 1e5 + 9;
const int mod = 1e9 + 7;
const int inf = 1e12;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
void solve(){
	ll n;
	cin >> n;

	ll beg = 0 , last = inf , mid , ans;
	while(beg <= last){
		mid = beg + (last - beg) / 2;

		if((n+1) * (n+2) / 2 - mid * (mid + 1) / 2 >= n * (n + 1) / 2){
			ans = mid;
			beg = mid + 1;
		}
		else last = mid - 1;
	}

	cout << n - ans + 1 << "\n";
}
signed main(){
	int t = 1;
	// cin >> t;
	for(int i = 1 ; i <= t ; i++){
		solve();
	}
}


#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; using pll = pair<ll,ll>; const ll INF = 4e18;
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<fixed<<setprecision(15)<<head;print0(tail...);}
void print() { print0("\n"); }
template<typename Head,typename... Tail>void print(Head head,Tail... tail){print0(head);if(sizeof...(Tail)>0)print0(" ");print(tail...);}
// clang-format on

ll a,b,c;
vector<vector<vector<double>>> memo(101, vector<vector<double>>(101, vector<double>(101, -INF)));
double rec(ll i,ll j,ll k){
  if(i==100||j==100||k==100)return 0;
  if(memo[i][j][k]>-INF+100)return memo[i][j][k];
  return memo[i][j][k] =
    (rec(i+1,j,k) + 1) * i / (i+j+k) +
    (rec(i,j+1,k) + 1) * j / (i+j+k) +
    (rec(i,j,k+1) + 1) * k / (i+j+k);
}
int main() {
  cin >>a>>b>>c;
  print(rec(a,b,c));
}

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

ll solve(vl& A, map<P, ll>& m, ll x, int i) {
    if (i == int(A.size()) - 1) return 1;
    if (m.count(P(x, i))) return m[P(x, i)];
    ll d = x % A[i + 1];
    ll ret = solve(A, m, x - d, i + 1);
    if (d > 0) ret += solve(A, m, x + (A[i + 1] - d), i + 1);
    return m[P(x, i)] = ret;
}

int main() {
    // input
    ll N, X;
    cin >> N >> X;
    vl A(N);
    rep(i, N) cin >> A[i];

    // solve
    map<P, ll> m;
    ll ans = solve(A, m, X, 0);
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define NIL (-1)
#define ll long long
using namespace std;
const double PI = acos(-1.0);

int main() {
	int A, B , C;
	cin >> A >> B >> C;

	char ans;
	if (A >= 0 && B >= 0) {
		if (A == B) ans = '=';
		else if (A < B) ans = '<';
		else ans = '>';
	}
	else if (A < 0 && B < 0) {
		if (C & 1) {
			if (A == B) ans = '=';
			else if (A < B) ans = '<';
			else ans = '>';
		}
		else {
			if (A == B) ans = '=';
			else if (A < B) ans = '>';
			else ans = '<';
		}
	}
	else {
		if (C & 1) {
			if (A == B) ans = '=';
			else if (A < B) ans = '<';
			else ans = '>';
		}
		else {
			if (abs(A) == abs(B)) ans = '=';
			else if (abs(A) < abs(B)) ans = '<';
			else ans = '>';
		}
	}
	cout << ans << endl;

	return 0;
}

#include <iostream>
using namespace std;
int main(){
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    int r = r2 - r1, c = c2 - c1;
    int ans = 3;
    if(!r && !c) ans = 0;
    else if(r == c || r == -c || abs(r) + abs(c) <= 3) ans = 1;
    else if((r ^ c ^ 1) & 1 || abs(r + c) <= 3 || abs(r - c) <= 3 || abs(r) + abs(c) <= 6) ans = 2;
    cout << ans << endl;
}


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

#include <iostream>
#include <limits.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
#include <memory>
using namespace std;
// #include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

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

#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define emb emplace_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ld long double

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

template <typename T> inline T range(T l, T r) {
    return uniform_int_distribution<T>(l, r)(rng);
}

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}

template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

const ll INF = 2e18;
const int inf = 0x3f3f3f3f;
const int N = 1e2 + 5;
int n, m, k;

int dp[N][N * N * N];

int p[N];

inline int add(int a, int b) {
    a += b;
    if(a >= m)
        return a - m;
    if(a < 0)
        return a + m;
    return a;
}

inline void add_t(int &a, int b) {
    a = add(a, b);
}

inline int mul(int a, int b) {
    return 1LL * a * b % m;
}

main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    cin >> n >> k >> m;
    dp[0][0] = 1;
    for(int i = 1; i <= n; ++i) {
        memset(p, 0, sizeof(p));
        for(int j = 0; j <= n * n * k; ++j) {
            add_t(p[j % i], dp[i-1][j]);
            dp[i][j] = p[j % i];
            if(j >= i * k)
                add_t(p[j % i], -dp[i-1][j - i * k]);
        }
    }
    for(int x = 1; x <= n; ++x) {
        int res = 0;
        for(int i = 1; i <= n * n * k; ++i)
            add_t(res, mul(1LL * dp[x-1][i] * dp[n-x][i] % m, k + 1));
        cout << add(res, k) << endl;
    }
    return 0;
}

#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int cys=998244353;
int n;
int a[105],d[105][10005],fac[105];

int mod(int x){return x>=cys?x-cys:x;}
void add(int &x,int y){x=mod(x+y);}

int main(){
	n=readint();
	for(int i=1;i<=n;i++) a[i]=readint();
	d[0][0]=1;
	int sum=0;
	for(int i=1;i<=n;i++){
		for(int j=i-1;j>=0;j--)
			for(int k=sum;k>=0;k--)
				add(d[j+1][k+a[i]],d[j][k]);
		sum+=a[i];
	}
	if(sum&1) return printf("0\n"),0;
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%cys;
	ll ans=0;
	for(int i=1;i<=n;i++) ans=(ans+1ll*fac[i]*fac[n-i]%cys*d[i][sum/2])%cys;
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
	int a,b;
  cin >> a >> b;
  if (a+b >= 15 && b >=8){
  cout << 1 << endl;
  }
  else if (a+b >=10 && b>=3){
   cout << 2 << endl;
  }
  else if (a+b>=3){
     cout << 3 << endl;
  }
  else{
  cout << 4 << endl;
  }

}

#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>

using namespace std;
using uint = uint32_t;
using LL = int64_t;
using ULL = uint64_t;
using PP = pair<LL, LL>;
template <typename T> using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#define REP(i, a, n) for(LL i = (a), i##_max_ = (n); i < i##_max_; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##_min_ = (a); i >= i##_min_; --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP { cin.tie(NULL); ios::sync_with_stdio(false); }
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U> istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U> ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N> void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N> void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template <class T> T Next() { T buf; cin >> buf; return buf; }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h&& j >= 0 && j < w; }

#ifdef ONLY_MY_ENVIR
#include "Accumulator.h"
#include "Algebraic.h"
#include "BinaryMatrix.h"
#include "BinaryTree.h"
#include "Bipartite.h"
#include "BIT.h"
#include "Compressor.h"
#include "Decompositions.h"
#include "DiscreteLog.h"
#include "DynamicMod.h"
#include "Exponential.h"
#include "Factorization.h"
#include "FFT.h"
#include "FlowSolver.h"
#include "Geometric2D.h"
#include "Geometric2DFloat.h"
#include "Geometric3D.h"
#include "Geometric3DFloat.h"
#include "Graph.h"
#include "GraphUtil.h"
#include "Interpolation.h"
#include "IntMod.h"
#include "KDTree.h"
#include "LazySegmentTree.h"
#include "LIS.h"
#include "List.h"
#include "Math.h"
#include "MathUtil.h"
#include "Matrix.h"
#include "MinCostFlowSolver.h"
#include "MinMax.h"
#include "Numbers.h"
#include "Optimize.h"
#include "Permutation.h"
#include "Polynomial.h"
#include "Position.h"
#include "Random.h"
#include "Range.h"
#include "Rational.h"
#include "RollingHash.h"
#include "RuntimeMod.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "Sets.h"
#include "Shortest.h"
#include "SlidingWindow.h"
#include "SpanningTree.h"
#include "StringSearching.h"
#include "SuffixArray.h"
#include "SwitchList.h"
#include "Timer.h"
#include "Tree.h"
#include "TreeUtil.h"
#include "UnionFind.h"
#include "Util.h"
#include "VectorUtil.h"
#endif
#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>>(istream& ist, __int128& val) { LL tmp; ist >> tmp; val = tmp; return ist; }
ostream& operator<<(ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

LL a, b;
int main() {
	cin >> a >> b;

	bool ok = false;
	for (LL i = 1; i * i <= b; ++i) {
		if (b % i != 0) continue;
		LL j = b / i;
		if (i + j == a) {
			ok = true;
		}
	}
	YesNo(ok);
	return 0;
}


#include<bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    vector<pair<unsigned long, unsigned long>> fr(N);
    for(auto&& [a, b] : fr)cin >> a >> b;
    sort(begin(fr), end(fr));
    unsigned long now{K};
    for(const auto& [a, b] : fr)if(now < a)return 0 & printf("%lu\n", now);
    else now += b;
    cout << now << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(void) {
	int n;
	long long k;
	long long x, y;
	vector<pair<long long, long long> >a;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		a.push_back({ x,y }); //a[i].first=A_i, a[i].second=B_i
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		if (a[i].first > k)break;
		k += a[i].second;
	}
	cout << k << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rep2(i, m, n) for(ll i = (ll)(n)-1; i >= (ll)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;

constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;

using Array = vector<ll>;
using Matrix = vector<Array>;

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

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

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

struct Edge {
    ll to, cap, rev;

    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll) G[to].size()));
    if (revFlag)
        G[to].push_back(Edge(from, revCap, (ll) G[from].size() - 1));
}

void solve() {
    ll n;
    cin>>n;
    REP(i,n){
        cout<<(2*i)%n+1<<" "<<(2*i+1)%n+1<<en;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    REP(i, t - 1) {
        solve();
    }*/

    solve();

    return 0;
}


#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i)
#define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME
#define REP(...) GET_MACRO_REP(__VA_ARGS__, REP3, REP2) (__VA_ARGS__)
#define RREP2(i, n) for (int i = (n - 1); i >= 0; --i)
#define RREP3(i, l, r) for (int i = (r - 1), i##_len = (l); i >= i##_len; --i)
#define GET_MACRO_RREP(_1, _2, _3, NAME, ...) NAME
#define RREP(...) GET_MACRO_REP(__VA_ARGS__, RREP3, RREP2) (__VA_ARGS__)
#define IN(type, n) type n; cin >> n
#define INALL(type, v) REP(i, v.size()) { IN(type, _tmp); v.at(i) = _tmp; }
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl
#else
#define DEBUG(x)
#endif

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; }
void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
#pragma endregion

void set_values(int A, int B, int C, vector<vector<vector<double> > > &values, double val) {
  values.at(A).at(B).at(C) = val;
  values.at(A).at(C).at(B) = val;
  values.at(B).at(A).at(C) = val;
  values.at(B).at(C).at(A) = val;
  values.at(C).at(A).at(B) = val;
  values.at(C).at(B).at(A) = val;
}

double calc(int A, int B, int C, vector<vector<vector<double> > > &values) {
  if (A == 100 || B == 100 || C == 100) return 0.0;
  if (values.at(A).at(B).at(C) != -1) return values.at(A).at(B).at(C);

  double ans = 0.0;
  if (A != 0) ans += (1.0 + calc(A + 1, B, C, ref(values))) * A / (A + B + C);
  if (B != 0) ans += (1.0 + calc(A, B + 1, C, ref(values))) * B / (A + B + C);
  if (C != 0) ans += (1.0 + calc(A, B, C + 1, ref(values))) * C / (A + B + C);
  set_values(A, B, C, ref(values), ans);

  return ans;
}

int main() {
  IN(int, A);
  IN(int, B);
  IN(int, C);

  vector<vector<vector<double> > > values(100, vector<vector<double> >(100, vector<double>(100, -1)));
  cout << fixed << setprecision(6);
  cout << calc(A, B, C, ref(values)) << endl;

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mx=200100;

double ans[101][101][101];
bool vis[101][101][101];
double dfs(int i,int j,int k){
	if(vis[i][j][k]) return ans[i][j][k];
	vis[i][j][k]=1;
	if(!i||!j||!k) return ans[i][j][k]=0.0;
	double fm=300-(i+k+j);
	ans[i][j][k]+=1.0*(100-i)/fm*dfs(i-1,j,k);
	ans[i][j][k]+=1.0*(100-j)/fm*dfs(i,j-1,k);
	ans[i][j][k]+=1.0*(100-k)/fm*dfs(i,j,k-1);
	ans[i][j][k]+=1.0;
	return ans[i][j][k];
}

int main(){
//	ios::sync_with_stdio(0);
	int a,b,c;
//	cin>>a>>b>>c;
	scanf("%d %d %d",&a,&b,&c);
	printf("%.8lf",dfs(100-a,100-b,100-c));
	return 0;
}


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

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

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

	int N;
	cin >> N;

	co((N + 99) / 100);

	Would you please return 0;
}

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

#define vi vector<int>
#define pb push_back
#define vli vector<long long int>
#define mp make_pair
#define pii pair<ll, ll>
typedef long long ll;
#define mii map<int, int>
#define mod 1000000007
#define vstr vector<string>
#define setval(a, v) memset(a, v, sizeof(a))
#define ff first
#define ss second
#define oo (1LL << 30)
#define endl "\n"

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

  if(n%100==0)
  {
      cout<<n/100;
  }
  else {

      cout<<(n/100)+1;
  }

    /*if(n<=100)
    {
        cout<<"1";
    }else
    {
        int cnt=0;
        while(n>100)
        {
            n-=100;
            cnt++;
        }
        cout<<cnt;
    }*/
}


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

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

signed main(){
    double A; cin>>A;
    double B; cin>>B;
    cout<<fixed<<setprecision(10)<<100.- B/A*100.<<endl;

    return 0;
}

#include <iostream>
using namespace std;
int main(void) {
  int A, B;
  cin >> A >> B;
  cout << (A-B)*100./A << endl;
  return 0;
}


/*  CREATED BY
    STREAM_CIPHER
    nov-2020
*/
#include<bits/stdc++.h>
using namespace std;
void __print(long long x) {cerr << x;}void __print(unsigned long long x) {cerr << x;}void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define int long long int
#define double long double
#define fix_precision(n) cout<<fixed<<setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;//5*64M bit ->5*8M byte ->40MB size for long long int (64 bit)
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        int n;
        cin>>n;
        vector<int>a;
        int nn=n;
        if(n%3==0)
        {
        	cout<<"0\n";
        	return 0;
        }
        int sum=0;
        while(nn>0)
        {
        	a.push_back(nn%10);
        	sum+=nn%10;
        	nn/=10;
        }
        int rem_1=0,rem_2=0,rem_0=0;
        for(auto i:a)
        {
        	if(i%3==1)
        		rem_1++;
        	if(i%3==2)
        		rem_2++;
        	if(i%3==0)
        		rem_0++;
        }
        if(sum%3==1)
        {
        	if(rem_1>0)
        	{
        		rem_1--;
        		if(rem_1+rem_2+rem_0>0)
        			cout<<"1\n";
        		else
        			cout<<"-1\n";
        	}
        	else
        	{
        		if(rem_0>0)
        		{
        			cout<<rem_2<<endl;
        		}
        		else
        			cout<<"-1\n";
        	}
        }
        if(sum%3==2)
        {
        	if(rem_2>0)
        	{
        		if(rem_2-1+rem_1+rem_0>0)
        			cout<<"1\n";
        		else
        		{
        			if(rem_1>1)
        			{
        				rem_1-=2;
        				if(rem_0+rem_1+rem_2>0)
        					cout<<"2\n";
        				else
        					cout<<"-1\n";
        			}
        			else
        			{
        				if(rem_0>0)
        					cout<<rem_1+rem_2<<endl;
        				else
        					cout<<"-1\n";
        			}
        		}
        	}
        	else
        	{
        		if(rem_1>1)
    			{
    				rem_1-=2;
    				if(rem_0+rem_1+rem_2>0)
    					cout<<"2\n";
    				else
    				{
    					if(rem_0>0)
        					cout<<rem_1+rem_2<<endl;
        				else
        					cout<<"-1\n";
    				}
    			}
    			else
    			{
    				if(rem_0>0)
        				cout<<rem_1+rem_2<<endl;
    				else
    					cout<<"-1\n";
    			}
        	}
        }

}
//always use s.lower_bound instead of lower_bound(all(s))
//also whenever there exist an standerd method for stl container prefer that
//otherwise this will happen
//https://codeforces.com/contest/1435/submission/96683823//tle
//https://codeforces.com/contest/1435/submission/96703923//accepted


#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int>bit(200001);
void update(int x, int val){
	for(int a = x; a<=200000; a+=a&-a){
		bit[a]+=val;
	}
}
int query(int x){
	int sum = 0;
	for(int a = x; a>0; a-=a&-a){
		sum+=bit[a];
	}
	return sum;
}
signed main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	int r,c,m;
	cin >> r >> c >> m;
	vector<int>mnv(c+1, r+1);
	vector<int>mnh(r+1, c+1);
	for(int i = 0; i<m; i++){
		int x,y;
		cin >> x >> y;
		mnv[y] = min(mnv[y],x);
		mnh[x] = min(mnh[x],y);
	}
	int ans = 0;
	set<pair<int,int>>s;
	for(int i = 2; i<mnh[1]; i++){
		int val = mnv[i]-1;
		ans+=val;
		s.insert({mnv[i],i});
	}
	for(int i = mnh[1]; i<=c; i++){
		update(i,1);
	}
	//cout << ans << "\n";
	update(1,1);
	int cur = 1;
	for(int i = 2; i<mnv[1]; i++){
		if(s.size()>0)
		while(s.size()>0&&(*s.begin()).first+1<=i){
			update((*s.begin()).second,1);
			s.erase(s.begin());
		}
		ans+=query(mnh[i]-1);
		//cout << ans << "\n";
	}
	cout << ans+1 << "\n";
	return 0;
}

/* 	author : sgupta_2001 	*/

#include<bits/stdc++.h>

using namespace std;

using db = double;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

//containers
#define sz(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back
#define pf push_front

//pairs
#define mp make_pair
#define ff first
#define ss second

//loops
#define rep(i, a, b) for(int i = a; i < b; ++i)
#define per(i, a, b) for(int i = b - 1; i >= a; --i)
#define each(x, a) for(auto &x : a)

//popular constants
const int mod = 1e9 + 7; //998244353;
const ll inf = 1e18;
const ld pie = acos((ld) - 1);

//grid problems
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//modulo operations
ll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}

#ifdef SGUPTA_2001
#define deb(x) cerr<< #x <<" "; __print(x); cerr<<'\n';
#else
#define deb(x);
#endif

//debug containers
template<class T> void __print(T x) {cerr<<x;}
template<class T, class U> void __print(pair<T,U> p) {cerr<<"{"<<p.ff<<", "<<p.ss<<"}";}
template<class T> void __print(vector<T> arr) { cerr<<"[ "; for(auto x:arr) { __print(x);cerr<<" "; } cerr<<"]"; }
template<class T> void __print(set<T> st) { cerr<<"{ "; for(auto x:st) { __print(x); cerr<<" "; } cerr<<"}";}
template<class T, class U> void __print(vector<pair<T,U>> arr) { cerr<<"[ "; for(auto x:arr) {__print(x);cerr<<", ";}cerr<<"]";}
template<class T, class U> void __print(unordered_map<T,U> arr) { cerr<<"{ "; for(auto x:arr) {__print(x);cerr<<", ";}cerr<<"}";}
template<class T, class U> void __print(map<T,U> arr) { cerr<<"{ "; for(auto x:arr) {__print(x);cerr<<", ";}cerr<<"}";}
template<typename... T> void read(T&... args) { ((cin>>args),...);}
template<typename... T> void write(T&&... args){((cout<<args<<" "),...);cout<<'\n';}

void solve() {

	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);

	printf("%d\n", N - A + B);

	return;
}

int main() {

	#ifdef SGUPTA_2001
		freopen("input.txt", "r", stdin);
		freopen("error.txt", "w", stderr);
	#endif

	auto start = std::chrono::high_resolution_clock::now();

	int t;
	t=1;
	while(t--) solve();

  auto stop = std::chrono::high_resolution_clock::now();
  auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
  // cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< '\n';

	 /*
	 		STUFF TO LOOK:
			1. Check the constraints
			2. Corner cases(n == 0 || n == 1)
			3. Variables in loops
			4. Make sure two ints aren’t multiplied to get a long long
	*/

	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>

#define amax(a, b) a = max(a, b)
#define amin(a, b) a = min(a, b)

using ll = long long;

using P = std::pair<ll, int>;
#define fi first
#define se second

int main() {
    int n;
    std::cin >> n;
    std::map<ll, int> cnt;
    for (int i=0; i<n; i++) {
        ll ai; std::cin >> ai;
        cnt[ai]++;
    }
    while (cnt.size() > 1) {
        ll x = cnt.begin()->fi;
        auto [X, X_cnt] = *(--cnt.end());
        cnt.erase(X);
        cnt[X-x] += X_cnt;
    }
    std::cout << cnt.begin()->fi << '\n';
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mx INT_MAX
#define mi INT_MIN
#define pb push_back
#define mp make_pair
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define vi vector<int>
#define vpii vector< pair<int,int> >
#define si set<int>

ll md=1e9+7;

ll __gcd(ll a, ll b) {if(b==0) return a; return __gcd(b, a%b);}
ll poww(ll a, ll b) {ll res=1;while(b) {if(b&1){res*=a;res%=md;}a*=a;a%=md;b>>=1;}return res;}
void ainp(int arr[], int n) {for(int i=0;i<n;i++) cin>>arr[i];}

void fast()
{ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}

void solve()
{
int n,i,m=INT_MAX,p=INT_MAX;
cin>>n;
int a[n];
for(i=0;i<n;i++)
{
	cin>>a[i];
	m=min(m,a[i]);
}
for(i=0;i<n;i++)
{
	a[i]=__gcd(m,a[i]);
	p=min(p,a[i]);
}
cout<<p;
}

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


#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using pii = pair<int, int>;
#define rep(i, s, n) for (int i = (int)s; i < (int)n; i++)
#define repr(i, n, s) for (int i = (int)n; (int)s < i; i--)
#define len(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define debug(var) if(DEBUG) do{cout << #var << " : "; print(var);}while(0)
template<typename T> void print(T e){cout << e << '\n';}
template<typename T> void print(const vector<T>& v){string s=""; for(auto& e : v){s+=to_string(e)+' ';} s.pop_back(); cout << s << '\n';}
template<typename T> void print(const vector<vector<T>>& vv){cout << '\n'; for(auto& v : vv){print(v);}}
template<typename T> void print(const set<T>& v){string s=""; for(auto& e : v){s+=to_string(e)+' ';} s.pop_back(); cout << s << '\n';}
template<typename T> void print(const list<T>& v){string s=""; for(auto& e : v){s+=to_string(e)+' ';} s.pop_back(); cout << s << '\n';}
template<typename T> inline bool chmin(T &a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T &a, T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> T mod(T a, T m) {return (a % m + m) % m;}

const int INF32 = INT_MAX / 2;
const long long INF64 = LONG_LONG_MAX / 2;
const long long MOD = 1000000007;
const double PI = acos(-1);
const bool DEBUG = false;

int main() {
    int N;
    cin >> N;
    if (N == 1) {
        print("Yes");
        return 0;
    }
    vector<pair<int, int>> S, T;
    int x1c=0, y1c=0, x2c = 0, y2c = 0;
    rep(i, 0, N) {
        double a, b;
        cin >> a >> b;
        S.push_back(make_pair(a * N, b * N));
        x1c += a;
        y1c += b;
    }
    rep(i, 0, N) {
        double c, d;
        cin >> c >> d;
        T.push_back(make_pair(c * N, d * N));
        x2c += c;
        y2c += d;
    }
    // 重心を原点に移動
    rep(i, 0, N) {
        S[i] = make_pair(S[i].first - x1c, S[i].second - y1c);
        T[i] = make_pair(T[i].first - x2c, T[i].second - y2c);
    }
    // Sの基準vectorを決める。(0, 0以外)
    int ibase;
    rep(i, 0, N) {
        if (abs(S[i].first) + abs(S[i].second) >= 1) {
            ibase = i;
            break;
        }
    }
    // Sの基準との距離、クロス積、内積のtupleを計算。並び替え。
    vector<tuple<int, int, int>> S2;
    rep(i, 0, N) {
        if (i == ibase) continue;
        int x, y, x0, y0, dist, cp, ip;
        tie(x0, y0) = S[ibase];
        tie(x, y) = S[i];
        dist = (int)(pow(x - x0, 2) + pow(y - y0, 2));
        cp = x0 * y - y0 * x;
        ip = x0 * x + y0 * y;
        S2.emplace_back(dist, cp, ip);
    }
    sort(all(S2));
    // Tの各々の基準vectorについて
    bool ans = false;
    rep(i, 0, N) {
        bool ok = true;
        // 　距離、クロス積、内積のtupleを計算
        vector<tuple<int, int, int>> T2;
        rep(j, 0, N) {
            if (j == i) continue;
            int x, y, x0, y0,  dist, cp, ip;
            tie(x0, y0) = T[i];
            tie(x, y) = T[j];
            dist = (int)(pow(x - x0, 2) + pow(y - y0, 2));
            cp = x0 * y - y0 * x;
            ip = x0 * x + y0 * y;
            T2.emplace_back(dist, cp, ip);
        }
        sort(all(T2));
        //　set同士で比較。全部ほぼ一致ならTrue, break
        int eps = 0.1;
        rep(i, 0, N - 1) {
            int dist1, cp1, ip1, dist2, cp2, ip2;
            tie(dist1, cp1, ip1) = S2[i];
            tie(dist2, cp2, ip2) = T2[i];
            if (abs(dist2 - dist1) > eps || abs(cp2 - cp1) > eps || abs(ip2 - ip1) > eps) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans = true;
            break;
        }
    }

    if (ans) {
        print("Yes");
    }
    else {
        print("No");
    }
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N;
vector<ll> X1;
vector<ll> Y1;
vector<ll> X2;
vector<ll> Y2;

ll d(ll x1, ll y1, ll x2, ll y2){
  ll dx = x1 - x2;
  ll dy = y1 - y2;
  return dx * dx + dy * dy;
}
ll c(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3){
  ll dx = x1 - x2;
  ll dy = y1 - y2;
  ll dx2 = x1 - x3;
  ll dy2 = y1 - y3;
  return dx * dy2 - dx2 * dy;
}

vector<pair<ll,pair<ll,ll>>> f(vector<ll>& X, vector<ll>& Y){
  vector<pair<ll,pair<ll,ll>>> res;
  int n = X.size()-2;
  rep(i,n){
    ll z1 = d(X[i],Y[i],X[n],Y[n]);
    ll z2 = d(X[i],Y[i],X[n+1],Y[n+1]);
    ll z3 = c(X[i],Y[i],X[n],Y[n],X[n+1],Y[n+1]);
    res.push_back({z1,{z2,z3}});
  }
  sort(res.begin(),res.end());
  return move(res);
}

int main(){
  cin >> N;
  X1.resize(N);
  Y1.resize(N);
  rep(i,N) cin >> X1[i] >> Y1[i];
  X2.resize(N);
  Y2.resize(N);
  rep(i,N) cin >> X2[i] >> Y2[i];

  if(N == 1){ cout << "Yes\n"; return 0; }

  rep(i,N) rep(j,i) rep(t,2){
    if(d(X2[i],Y2[i],X2[j],Y2[j]) != d(X1[N-2],Y1[N-2],X1[N-1],Y1[N-1])) continue;
    swap(X2[i],X2[N-1]);
    swap(Y2[i],Y2[N-1]);
    swap(X2[j],X2[N-2]);
    swap(Y2[j],Y2[N-2]);
    if(f(X1,Y1) == f(X2,Y2)){ cout << "Yes\n"; return 0; }
    swap(X2[j],X2[N-2]);
    swap(Y2[j],Y2[N-2]);
    swap(X2[i],X2[N-1]);
    swap(Y2[i],Y2[N-1]);
    swap(X2[i],X2[j]);
    swap(Y2[i],Y2[j]);
  }

  cout << "No\n";

  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
int a,b,x,y;
int solve()
{
	if(a==b) return x;
	int dis=abs(a-b);
	dis--;
	int ans=x;
	if(a>b) ans+=dis*min(y,2*x);
	if(a<b) ans+=(dis+1)*min(y,2*x);
	return ans;
}
int main()
{
	//freopen("1.txt","r",stdin);
	scanf("%d%d%d%d",&a,&b,&x,&y);
	cout<<solve()<<endl;
	//fclose(stdin);
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d=0;
	cin>>a>>b>>c;
	if(a==1) d=d+6;
	else if(a==2) d=d+5;
	else if(a==3) d=d+4;
	else if(a==4) d=d+3;
	else if(a==5) d=d+2;
	else if(a==6) d=d+1;
	if(b==1) d=d+6;
	else if(b==2) d=d+5;
	else if(b==3) d=d+4;
	else if(b==4) d=d+3;
	else if(b==5) d=d+2;
	else if(b==6) d=d+1;
	if(c==1) d=d+6;
	else if(c==2) d=d+5;
	else if(c==3) d=d+4;
	else if(c==4) d=d+3;
	else if(c==5) d=d+2;
	else if(c==6) d=d+1;
	cout<<d<<endl;
	return 0;
 }


#include <bits/stdc++.h>

using namespace std;
int n;
int main()
{
    cin >> n;
    for (int i=1; i<=n; i++) {
        cout << (2*i-2)%n+1 << " " << (2*i-1)%n+1 << "\n";
    }
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define irreps(i, m, n) for (long long i = ((long long)(n)-1); i > (long long)(m); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) (long long)(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;
using ld = long double;

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

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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

  ll k; cin>>k;
  ll ans=0;
  reps(i,k){
    for(int j=1; j*i<=k; j++){
      ll x=i*j;
      ans+=k/x;
    }
  }
  cout<<ans<<endl;
}


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

#define ll long long
#define all(x) x.begin(), x.end()

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	for(auto &v: a) cin >> v, v %= 200;
	n = min(8, n);
	vector<vector<int>> dp(200);
	for(int mask = 1; mask < (1 << n); ++mask){
		int cur_mod = 0;
		vector<int> local;
		for(int j = 0; j < n; ++j){
			if(mask & (1 << j)){
				cur_mod = (cur_mod + a[j]) % 200;
				local.push_back(j + 1);
			}
		}
		if(dp[cur_mod].empty()){
			dp[cur_mod] = local;
		}else{
			cout << "Yes" << "\n";
			cout << dp[cur_mod].size() << " ";
			for(auto i : dp[cur_mod]) cout << i << " ";
			cout << "\n";
			cout << local.size() << " ";
			for(auto i : local) cout << i << " ";
			cout << "\n";
			exit(0);
		}
	}
	cout << "No" << "\n";
}

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

int dp[210][210];

int mod(int x) {
    return (x + 200 * 10) % 200;
}

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] %= 200;
    }

    for (int i = 0; i < n; i++) {
        for (int sum = 0; sum < 200; sum++) {
            if (sum == 0) {
                dp[i + 1][mod(sum + a[i])] += 1;
            }
            dp[i + 1][sum] += dp[i][sum];
            dp[i + 1][mod(sum + a[i])] += dp[i][sum];
        }
    }

    bool ok = false;
    int sum = 0, last = 0;
    for (int i = 0; i <= n and ok == false; i++) {
        for (int j = 0; j < 200 and ok == false; j++) {
            if (dp[i][j] >= 2) {
                ok = true;
                sum = j;
                last = i;
                break;
            }
        }
    }

    // for (int i = 0; i <= n; i++) {
    //     for (int j = 0; j < 200; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << sum << " " << last << endl;
    if (ok == false) {
        cout << "No" << endl;
        return 0;
    }

    vector<int> b, c;

    b.push_back(last - 1);
    int cur = mod(sum - a[last - 1]);

    for (int i = last - 1; i - 1 >= 0; i--) {
        if (dp[i][cur] != dp[i - 1][cur]) {
            cur = mod(cur - a[i - 1]);
            b.push_back(i - 1);
        }
    }

    cur = sum;
    if (dp[last - 1][cur] == 0)
        c.push_back(last - 1);
    else {
        for (int i = last - 1; i - 1 >= 0; i--) {
            if (dp[i][cur] != dp[i - 1][cur]) {
                cur = mod(cur - a[i - 1]);
                c.push_back(i - 1);
            }
        }
    }

    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    cout << "Yes" << endl;
    cout << b.size() << " ";
    for (int e : b) cout << e + 1 << " ";
    cout << endl;
    cout << c.size() << " ";
    for (int e : c) cout << e + 1 << " ";
    cout << endl;
}