#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

int n;
LL y, x[100];
map<pair<LL, LL>, LL> mp;

LL dfs(int i, LL y) {
  if (mp.find({i, y}) != mp.end()) {
    return mp[{i, y}];
  }
  LL g = y / x[i];

  if (y % x[i] == 0) {
    if (i == n - 1 || g < x[i + 1] / x[i]) {
      mp[{i, y}] = 1;
    } else {
      mp[{i, y}] = 0;
    }
    return mp[{i, y}];
  } else {
    LL yl = g * x[i];
    LL yr = (g + 1) * x[i];
    LL t = 0;
    if (i == n - 1 || g < x[i + 1] / x[i]) {
      t += dfs(i - 1, abs(y - yl));
    }
    if (i == n - 1 || g + 1 < x[i + 1] / x[i]) {
      t += dfs(i - 1, abs(y - yr));
    }
    mp[{i, y}] = t;
  }
  return mp[{i, y}];
}
int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  scanf("%d", &n);
  cin >> y;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  LL ans = dfs(n - 1, y);
  cout << ans << endl;

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) * 1.0 / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

#include <bits/stdc++.h>

#define TRACE(x) cerr << #x << " = " << x << endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second

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

#define SZ(x) (int)(x).size()

using namespace std;

typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef vector<int> VI;

template<class Num>
Num mabs(Num A){
  if(A < 0) return -A;
  return A;
}

int main(){
	int n;
	ll x;
	scanf("%d %lld", &n, &x);
	vector<ll> coin(n);
	REP(i, n)
		scanf("%lld", &coin[i]);

	vector<ll> X(n);

	reverse(coin.begin(), coin.end());
	ll tx = x;
	REP(i, n){
		ll ide = x / coin[i];
		X[i] = ide;
		x -= ide * coin[i];
	}

	reverse(coin.begin(), coin.end());
	reverse(X.begin(), X.end());
	x = tx;

//	cout << "reprezentacija x " << endl;
//	for(ll p : X)
//		cout << p << ' ';
//	cout << endl;

	vector<vector<ll> > ways(n + 2, vector<ll>(2, 0ll));

	ways[n - 1][0] = ways[n - 1][1] = 1;
	for(int i = n - 2; i >= 0; i--){
		if(X[i] == 0){
			ways[i][0] += ways[i + 1][0];
			int pt = i + 1;
			while(pt < n - 1 && coin[pt + 1] / coin[pt] - 1 == X[pt]) pt++;
			ways[i][1] = ways[i][0] + ways[pt][1];
		}
		else{
			ways[i][0] += ways[i + 1][0];
			int pt = i + 1;
			while(pt < n - 1 && coin[pt + 1] / coin[pt] - 1 == X[pt]) pt++;
			ways[i][0] += ways[pt][1];
			ways[i][1] = ways[i][0];
		}
	}

//	cout << "check " << endl;
//	REP(i, n)
//		cout << ways[i][0] << ' ';
//	cout << endl;
//
	printf("%lld\n", ways[0][0]);

  return 0;
}


#include<cstdio>
#include<algorithm>
#define N 300011
using namespace std;
int a[N];
bool cmp(int x,int y)
{
	return x<y;
}
int main()
{
	long long n;
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	long long ans=0,count=0;
	a[0]=-1e9;
	for (int i=1;i<=n;i++)
	{
		if (a[i]!=a[i-1])
		{
			ans=(ans+count*(count-1)/2);
			count=0;
		}
		count++;
	}
	ans=(ans+count*(count-1)/2);
	printf("%lld\n",n*(n-1)/2-ans);
}

#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define bits(x,i) (((x) >> (i)) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 3e5 + 5;
int n;
map<int,int> cnt;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	long long ans = 0;
	up(i,1,n){
		int x; cin >> x;
		cnt[x]++;
		ans += i - cnt[x];
	}
	cout << ans;
}


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

int a[26];  ///アルファベットの番号を格納
int t[10];  //数字 いろんな順番になる
string s[3];
int sz=0;
long f(string s){
    if (t[a[s[0]-'a']]==0) return -1;
    long ans = 0;
    rep(p, s.size()){
        ans = ans*10+t[a[s[p]-'a']];
    }
    return ans;
}
int main(){
    rep(i, 26) a[i] = -1;
    rep(i, 10) t[i] = i;
    rep(i, 3){
        cin >> s[i];
        rep(j, s[i].size()){
            if (a[s[i][j]-'a']==-1){
                a[s[i][j]-'a']=sz++;
            }
        }
    }
    if (sz>10){
        cout << "UNSOLVABLE" << endl;
        return 0;
    }
    do{
        long N[3];
        int check = 1; //check=0のとき条件満たしてないので即効out
        rep(i, 3){
            N[i] = f(s[i]);
            if (N[i]==-1) check=0;
        }

        if (N[0]+N[1]==N[2]&&check){
            rep(i,3) cout << N[i] <<endl;
            return 0;
        }
    }while(next_permutation(t, t+10));
    cout << "UNSOLVABLE" << endl;
    return 0;
}

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  Int a=count(s.begin(),s.end(),'1');
  Int b=count(t.begin(),t.end(),'1');
  if(a<b) drop(-1);
  if((a-b)&1) drop(-1);
  set<Int> ss;
  for(Int i=0;i<n;i++)
    if(s[i]=='1') ss.emplace(i);

  Int ans=0;
  for(Int i=0;i<n;i++){
    if(t[i]!='1') continue;
    auto it=ss.lower_bound(i);
    if(it==ss.end()) drop(-1);
    ans+=*it-i;
    ss.erase(*it);
  }

  while(!ss.empty()){
    Int x=*ss.begin();ss.erase(x);
    Int y=*ss.begin();ss.erase(y);
    ans+=y-x;
  }
  cout<<ans<<newl;
  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);
    }
}

bool intersect(pair<double, double> a, pair<double, double> b) {
    return max(a.first, b.first) <= min(a.second, b.second);
}

void solve() {
    int n; cin >> n;
    vector<pair<double, double>> arr(n);
    for (int i = 0; i < n; i++) {
        double t, a, b; cin >> t >> a >> b;

        if (t == 1);
        if (t == 2) b -= 0.1;
        if (t == 3) a += 0.1;
        if (t == 4) {a += 0.1; b -= 0.1;};
        arr[i] = {a, b};
    }

    ll int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (intersect(arr[i], arr[j])) {
                // cout << i << ' ' << j << endl;
                ans++;
            }
        }
    }

    cout << ans << 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>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, -1, 0, 1};
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
char inverse_char(char c) {
  if(isupper(c)) return tolower(c);
  else return toupper(c);
}
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, cost;
};

int main() {
  int N; cin >> N; int M; cin >> M;
  vector<ll> A(M), B(M); REP(i, M) cin >> A[i] >> B[i];
  int K; cin >> K;
  vector<ll> C(K), D(K); REP(i, K) cin >> C[i] >> D[i];
  // bit全探索
  // bitに1が立っていればDにボールを入れる
  ll ans = 0; // 最大いくつの条件が満たされているか
  // bit全探索
  for(int bit = 0; bit < (1 << K); ++bit) {
    vector<ll> t(N + 1, 0);
    for(int i = 0; i < K; ++i) {
      if(bit & (1 << i)) {
        t[C[i]]++;
      } else {
        t[D[i]]++;
      }
    }
    ll res = 0;
    REP(i, M) {
      if(t[A[i]] > 0 && t[B[i]] > 0) res++;
    }
    chmax(ans, res);
  }
  cout << ans << endl;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
  int n;
  const int Nmax = 200002;
  vector<int> count(Nmax,Nmax);
  cin >> n;
  int p;
  for(int i=0;i<n;i++) {
    cin >> p;
    if(count[p] == Nmax) count[p] = i+1;
  }

  int output = 1;
  for(int i=0;i<Nmax;i++) {
    if(output < count[i]){
      while(output < count[i]) {
	cout << i << endl;
	output++;
	if(output > n) return 0;
      }
    }
    if(output > n) break;
  }
  return 0;
}

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

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

#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rsz resize
#define bk back()
#define pb push_back
#define ins insert
#define del erase
#define inf INT_MAX
#define db cout << "here" << endl;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
#define nl endl
const int MOD = 1e9+7;
const ld PI = acos((ld)-1);
mt19937 rng; // or mt19937_64
template<class T> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; }
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
const int MX = 300002;
const int INF = MX+MX;
void solve() {
	int n ;
	cin >> n ;
	int ar[n];
	F0R(i,n) {
		cin >> ar[i];
	}
	int flag[MX];
	F0R(i,200002) flag[i]=false;
	int j = 0;
	F0R(i,n) {
		flag[ar[i]]= true;
		if(j!=ar[i])
		cout << j << endl;
		else {
			for(; j <= 200001; j++)
			if(flag[j]==false)
			break;
			cout << j << endl;
		}
	}
}
int main() {
	int t;
	t=1;
	while(t--)
	solve();
}


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

int main() {
	string a, b;
	cin >> a >> b;
	int aa = 0, bb = 0;
	rep(i, 0, 3) {
		aa += a[i] - '0';
		bb += b[i] - '0';
	}
	cout << max(aa, bb) << endl;
}

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

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

  int sa = 0, sb = 0;
  for (int i = 0; i < 3; i++) {
    sa += a.at(i) - '0';
    sb += b.at(i) - '0';
  }

  if (sa > sb) {
    cout << sa << endl;
  } else {
    cout << sb << endl;
  }
}


#include<bits/stdc++.h>

using   namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define  all(v)       (v).begin(),(v).end()
#define  rall(v)      (v).rbegin(),(v).rend()
#define  pb           push_back
#define  pob          pop_back
#define  eb           emplace_back
#define  ins          insert
#define  mp           make_pair
#define  ff           first
#define  ss           second
#define  pf           push_front
#define  bs           binary_search
#define  lb           lower_bound
#define  ub           upper_bound
#define  sz(a)        (ll)a.size()
#define  dec(x)       fixed<<setprecision(x)
#define  lcm(a,b)     (a*b/__gcd(a,b))

typedef  priority_queue<ll>  pq;
typedef  priority_queue<ll,vector<ll>,greater<ll> > pqmn;
typedef  pair<ll,ll> pll;
typedef  vector<ll> vll;
typedef  vector<pll> vpll;
typedef  vector<vector<ll> > vvll;
typedef  vector<string> vstr;
typedef  set<ll> sll;
typedef  set<pll> spll;
typedef  map<ll,ll> mll;

const    ll inf=LLONG_MAX;
const    ll mod=1e9+7;
const    ld pi=acos(-1);
const    ll N=100001;

void solution()
{
    int n;
    cin>>n;
    cout<<100-n%100;
}

int main()
{
	//freopen("t","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solution();
    }
    return 0;

}


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

int main(){
  long long n,m;
  cin >> n >> m;

  long long P=998244353;
  long long dp[m+10];
  dp[0]=1;
  dp[1]=0;
  dp[2]=n * (n - 1) / 2;

  if(m <= 2){ cout << dp[m]; return 0; }

  long long fact[n+1],inv[n+1],fact_inv[n+1];

  fact[1]=1;
  fact[0]=1;
  inv[1]=1;
  fact_inv[1]=1;
  fact_inv[0]=1;

  for (long long i = 2; i <= n ; i++) {
    fact[i] = fact[i - 1] * i % P;
    inv[i] = P - inv[P % i] * (P / i) % P;
    fact_inv[i] = fact_inv[i - 1] * inv[i] % P;
  }

  for(long long i = 3 ; i <= m + 5 ; i++){
    dp[i] = 0;
    if(i % 2 == 1){ continue; }

    for(long long j = 0 ; j <= min(i / 2 , n / 2) ; j++){
      long long plus = dp[(i - 2 * j) / 2];
      plus %= P;
      plus *= fact[n];
      plus %= P;
      plus *= fact_inv[n - (2 * j)];
      plus %= P;
      plus *= fact_inv[2 * j];
      plus %= P;
      dp[i] += plus;
      dp[i] %= P;
    }
  }

  cout << dp[m];

  return 0;
}

#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
#include<set>
#include <array>
using namespace std;
#define ll long long
#define endl '\n'
#define mod 998244353
#define pb push_back
#define ff first
#define ss second
#define con continue
#define ub upper_bound
#define lb lower_bound

#define si(x) int(x.size())
#define sum_all(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
const double pi = 2 * acos(0.0);
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, -1, 0, 1 };

const int dx8[] = { -1, 0, 1, 0,1,1,-1,-1 };
const int dy8[] = { 0, -1, 0, 1,1,-1,1,-1 };

ll min(ll a, ll b)
{
    if (a < b)return a;
    return b;
}
ll max(ll a, ll b)
{
    if (a > b)return a;
    return b;
}
ll ceil1(ll a, ll b)
{
    return(a + b - 1) / b;
}
void read(vector<ll>& arr)
{
    for (ll i = 0; i < si(arr); i++)
        cin >> arr[i];

}

void read_graph(vector<vector<ll>>& g, ll m)
{
    while (m--)
    {
        ll x, y; cin >> x >> y;
        x--, y--;
        g[x].pb(y);
        g[y].pb(x);
    }
}

vector<vector<ll>> c;

ll ncr(ll n, ll r)
{
    if (n == r) return 1;
    if (r<0 or r > n) return 0;
    return c[n][r];
}
void pre(ll lim = 5003)
{
    c = vector<vector<ll>>(lim + 1, vector<ll>(lim + 1));
    c[0][0] = 1;
    for(ll i=1;i<=lim;i++)
        for (ll j = 0; j <= lim; j++)
        {
            c[i][j] = ncr(i-1,j) + ncr(i-1,j-1);
            c[i][j] %= mod;
        }
}

void solve()
{
    ll n, m;
    cin >> n >> m;
    int lim = 5001;
    pre();

    if (m % 2 == 1)
    {
        cout << 0 << endl;
        return;
    }

    vector<vector<ll>> dp(32, vector<ll>(n + 13));
    // base case
    for (int i = 0; i <= n; i += 2)
    {
        dp[0][i / 2] = ncr(n, i);
    }

    //cout << ncr(n, 2) << endl;
    for (int i = 1; i < 13; i++)
    {

            for (int k = 0; k <= n; k += 2)
            {
                if ((m & (1ll << i)) > 0)
                {
                    for (int j = 1; j <= n; j+=2)
                    {

                        ll x = (j + k) / 2;
                        dp[i][x] += (dp[i - 1][j] * ncr(n, k))%mod;
                        dp[i][x] %= mod;
                    }
                }
                else
                {
                    for (int j = 0; j <= n; j+=2)
                    {

                        ll x = (j + k) / 2;
                        dp[i][x] += (dp[i - 1][j] * ncr(n, k))%mod;
                        dp[i][x] %= mod;
                    }
                }
            }

    }

    cout << dp[12][0] << endl;

}

int 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 t; cin >> t; while (t--)
    solve();

}


/*
ID: jerrywcy
LINK: https://atcoder.jp/contests/arc107/tasks/arc107_a
TITLE: A - Simple Math
LANG: C++
STATUS:
*/
#include <bits/stdc++.h>
#define DEBUG

#define init(array,x) memset(array,x,sizeof(array))

using namespace std;

typedef long long ll;

const int inf=0x3f3f3f3f;
const ll mod=998244353;

ll a,b,c;

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

int main()
{
    a=read();b=read();c=read();
    a=a*(a+1)/2%mod;b=b*(b+1)/2%mod;c=c*(c+1)/2%mod;
    printf("%lld\n",a*b%mod*c%mod);

    return 0;
}

/*

  Author: klmcoder
  Date  : 20210227 1735 hrs.
  Info  : atcoder [abc193-A]

*/
#include <iostream>
#include <iomanip>

int main(void)
{
  int a, b;
  float p;

  std::cin >> a >> b;

  p = (((float)a-b)/(float)a)*100.0;
  std::cout << p << "\n";

  return 0;
}


#include <bits/stdc++.h>
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;
}

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

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pll pair<lli,lli>
#define ve vector<lli>
#define vep vector<pair<lli,lli> >
#define fr(i,a,n) for(lli i=a;i<(n);i++)
#define frj(j,a,n) for(lli j=a;j<(n);j++)
#define frx(i,a,n) for(lli i=a;i>(n);i--)
#define frxj(j,a,n) for(lli j=a;j>(n);j--)
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define db(x) cout << "[ " << x << " ]" << endl
#define db2(x,y) cout<<x<<" "<<y<<endl
#define dbarr(arr,a,n) fr(i,a,n) cout<<arr[i]<<" "; cout<<endl
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

lli solve(){
    lli r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;
    if(r1==r2 && c1==c2)return 0;
    if(r1+c1==r2+c2 || r1-r2==c1-c2 || (abs(r1-r2)+abs(c1-c2))<4)return 1;
    if((abs(r1-r2)+abs(c1-c2))<7)return 2;
    if(r2-c2<=r1-(c1-3) && r2-c2>=r1-(c1+3))return 2;
    if(r2+c2<=r1+c1+3 && r2+c2>=r1+c1-3)return 2;
    if((r1+c1)%2==(r2+c2)%2)return 2;
    return 3;
}

int main(){
    fast;
    lli t=1;
    // cin>>t;
    while(t--){
       cout<<solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
const int maxn=2e5+5;
int n,m,k;
long double dp[maxn][2];
long double sum[maxn][2];
int main(){
    cin>>n>>m>>k;
    for(int i=1,x;i<=k;i++){
        cin>>x;
        dp[x][0]=1;
    }
    for(int i=n-1;i>=0;i--){
        if(abs(dp[i][0]-1)>1e-10){
        dp[i][1]=(sum[i+1][1]-sum[i+1+m][1])/m+1;
        dp[i][0]=(sum[i+1][0]-sum[i+1+m][0])/m;
        }
        sum[i][0]=sum[i+1][0]+dp[i][0];
        sum[i][1]=sum[i+1][1]+dp[i][1];
    }
    double ans=dp[0][1];
    if(abs(dp[0][0]-1)<1e-10){
        puts("-1");
        return 0;
    }
     ans/=(1.0f-dp[0][0]);

    printf("%.3f\n",ans);

    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ll long long
using namespace std;
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  vector<int>v(a-1);
  int sum=0;
  rep(i,a-1){
    cin>>v[i];
  sum+=v[i];
}
  if(c*a-sum>b){
    cout<<-1<<endl;
  }
  else if(c*a-sum<=0){
    cout<<0<<endl;
  }
  else{
    cout<<c*a-sum<<endl;
  }
}


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

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

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

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

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

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

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

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

	Would you please return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define ALL(v) (v).begin(), (v).end()
#define LLA(v) (v).rbegin(), (v).rend()
#define SZ(v) (v).size()
#define INT(...)                                                               \
    int __VA_ARGS__;                                                           \
    read(__VA_ARGS__)
#define LL(...)                                                                \
    ll __VA_ARGS__;                                                            \
    read(__VA_ARGS__)
#define DOUBLE(...)                                                            \
    double __VA_ARGS__;                                                        \
    read(__VA_ARGS__)
#define CHAR(...)                                                              \
    char __VA_ARGS__;                                                          \
    read(__VA_ARGS__)
#define STRING(...)                                                            \
    string __VA_ARGS__;                                                        \
    read(__VA_ARGS__)
#define VEC(type, name, size)                                                  \
    vector<type> name(size);                                                   \
    read(name)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;
template <class T> inline vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> inline auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}

void read() {}
template <class T> inline void read(T &a) { cin >> a; }
template <class T, class S> inline void read(pair<T, S> &p) {
    read(p.first), read(p.second);
}
template <class T> inline void read(vector<T> &v) {
    for(auto &a : v)
        read(a);
}
template <class Head, class... Tail>
inline void read(Head &head, Tail &...tail) {
    read(head), read(tail...);
}
template <class T> inline void chmax(T &a, T b) { (a < b ? a = b : a); }
template <class T> inline void chmin(T &a, T b) { (a > b ? a = b : a); }

ll pow10(int a) {
    ll ret = 1;
    rep(i, a) ret *= 10;
    return ret;
}

ll calc(map<int, int> mp) {
    ll res = 0;
    for(int i = 1; i <= 9; i++) {
        res += i * pow10(mp[i]);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    LL(K);
    STRING(s, t);
    map<int, int> smp, tmp;
    rep(i, 4) {
        smp[s[i] - '0']++;
        tmp[t[i] - '0']++;
    }
    ll all = 0, win = 0;
    vector<int> used(10);
    for(int i = 1; i <= 9; i++) {
        used[i] = smp[i] + tmp[i];
    }
    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            auto smp2 = smp, tmp2 = tmp;
            smp2[i]++, tmp2[j]++;
            bool ok = 1;
            for(int k = 1; k <= 9; k++) {
                if(smp2[k] + tmp2[k] > K)
                    ok = 0;
            }
            if(ok) {
                all += (K - used[i]) * (K - used[j] - (i == j));
                ll ssc = calc(smp2), tsc = calc(tmp2);
                if(ssc > tsc) {
                    win += (K - used[i]) * (K - used[j] - (i == j));
                }
            }
        }
    }
    cout << fixed << setprecision(15) << (double)win / (double)all << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define int long long int
#define popcount(x) __builtin_popcountll(x)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define fr first
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define ld long double
const int INF = __LONG_LONG_MAX__;
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroint-loops")

int power(int b,int e,int m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
int power( int b, int e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}
bool isPowerOfTwo(int x)
{
    // x wiint check if x == 0 and !(x & (x - 1)) wiint check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}

void solve()
{
   int n;
   cin>>n;
   vector <int> v(n);
   for(auto &i:v) cin>>i;
   	int x=0,y=0,curr=0;
   for(int i=2;i<=1000;i++)
   {
   	  x=0;
   	  for(int j=0;j<n;j++)
   	  {
   	  	if(v[j]%i==0)
   	  		x++;
   	  }
   	  // cout<<y<<"\n";
   	  if(x>curr)
   	  {
   	  	curr=x;
   	  	y=i;
   	  }
   }
   cout<<y;
}

signed main()
{
  fastio
  int tt=1;
  // cin>>tt;
   // freopen("input.txt", "r" , stdin);
  // freopen("output.txt", "w", stdout);
  while(tt--)
  {
      solve();
      cout<<"\n";
  }
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll M1 = 1e9+7;
void files(){
 freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);

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

}
int main(){
  fast();
  ll n;
  cin>>n;
  vector<ll> d(n,0);
  vector<ll> sum(n+1,0);
  vector<ll> m(n+1,0);
  for(int i=0; i<n; i++){
    cin>>d[i];
    sum[i+1]=sum[i]+d[i];
    m[i+1]=max(m[i],sum[i+1]);
  }

  ll c=0,ans=0;
  for(int i=1; i<=n; i++){
    ll k=c+m[i];
    ans=max(ans,k);
    c=c+sum[i];
  }
  cout<<ans;
  return 0;
}


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

int x, y;

int main(){
  cin >> x >> y;
  if(x==y)cout << x << endl;
  else cout << 3 - x - y << endl;

  return 0;
}

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

int main(){
  int A,B;cin>>A>>B;
  int X=B-A;
  for(int i=X;i>0;i--){
    if((B/i-1)*i>=A){
      cout<<i<<endl;
      return 0;
    }
  }
}


#include <bits/stdc++.h>
//#include <atcoder/modint>
//#include <atcoder/math>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; i <= n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c = a % i_7;
    if(c >= 0) return c;
    return c + i_7;
}
long long po(long a, long b){
    if(b == 0) return 1;

    long long z = po(a , b / 2);
    z = mod(z * z);
    if(b % 2 != 0) z = mod(a * z);
    return z;
}

bool prime_(int n){
    if(n == 1){
        return false;
    }else if(n == 2){
        return true;
    }else{
        for(int i = 2; i <= std::sqrt(n); i++) if(n % i == 0) return false;
        return true;
    }
}

long long gcd_(long long a, long long b){
    if(a < b) std::swap(a,b);
    if(a % b == 0) return b;
    else return gcd_(b, a % b);
}

long long lcm_(long long x, long long y){
    return (x / gcd_(x,y)) * y;
}

using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//using mint = modint998244353;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  //using namespace std;

  int n;
  cin>>n;
  long long x[n];
  int c[n];
  REP(i, n){
    cin>>x[i]>>c[i];
    c[i]--;
  }

  vector<long long> balls[n];
  REP(i, n) balls[c[i]].push_back(x[i]);
  vector<int> colors;
  REP(i, n){
    if(balls[i].empty()) continue;
    colors.push_back(i);
    sort(ALL(balls[i]));
  }
  //sort(ALL(colors));
  int num = colors.size();
  vector<vector<long long>> dp(num, vector<long long>(2, INF));
  REP(i, num){
    int color = colors[i];
    int cnt = balls[color].size();
    long long width = balls[color][cnt - 1] - balls[color][0];
    if(i == 0){
      dp[i][0] = abs(balls[color][0]) + width;
      dp[i][1] = abs(balls[color].back()) + width;
      continue;
    }
    dp[i][0] = min(dp[i][0], abs(balls[color][0] - balls[colors[i - 1]][0]) + width + dp[i - 1][1]);
    dp[i][0] = min(dp[i][0], abs(balls[color][0] - balls[colors[i - 1]].back()) + width + dp[i - 1][0]);
    dp[i][1] = min(dp[i][1], abs(balls[color].back() - balls[colors[i - 1]][0]) + width + dp[i - 1][1]);
    dp[i][1] = min(dp[i][1], abs(balls[color].back() - balls[colors[i - 1]].back()) + width + dp[i - 1][0]);
  }
  long long ans = min(dp[num - 1][0] + abs(balls[colors[num - 1]].back()), dp[num - 1][1] + abs(balls[colors[num - 1]][0]));
  cout << ans << endl;

  return 0;
}

#include <algorithm>
#include <iostream>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cmath>
#include <climits>
#include <queue>
#include <bitset>
#include <set>
#include <assert.h>
#include <map>
using namespace std;
typedef vector<vector<long> > dim2veclo;
typedef vector<vector<int> > dim2vecin;
typedef vector<vector<double> > dim2vecdo;
typedef vector<vector<long long> > dim2vecll;
typedef vector<int> vecin;
typedef vector<long> veclo;
typedef vector<double> vecdo;
typedef vector<long long> vecll;
typedef vector<bool> vecbo;
typedef vector<vector<bool> > dim2vecbo;
typedef long long ll;
typedef vector < pair<ll, ll> > vecpa;
typedef vector<string> vecst;
typedef pair<ll, ll> pail;
typedef pair<int, int> pain;
typedef vector<vecpa > dim2vecpa;

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

int dx[4] = { -1, 0, 1, 0 };
int dy[4] = { 0, 1, 0, -1 };

const ll MOD = 1000000007;

int dist(double x1, double y1, double x2, double y2) {
    return (int)((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int angG(double X, double Y, double x2, double y2, double x3, double y3) {
    double gaiseki = (x2 - X) * (y3 - Y) - (y2 - Y) * (x3 - X);
    return (int)(asin(gaiseki / (dist(X, Y, x2, y2) * dist(X, Y, x3, y3))) * 100000);
}

int angN(double X, double Y, double x2, double y2, double x3, double y3) {
    double naiseki = (x2 - X) * (x3 - X) + (y2 - Y) * (y3 - Y);
    return (int)(acos(naiseki / (dist(X, Y, x2, y2) * dist(X, Y, x3, y3))) * 100000);
}

int main() {
    int n; cin >> n;
    vecdo a = vecdo(n);
    vecdo b = vecdo(n);
    vecdo c = vecdo(n);
    vecdo d = vecdo(n);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, n) cin >> c[i] >> d[i];
    if (n == 1) {
        cout << "Yes";
        return 0;
    }
    if (n == 2) {
        if (dist(a[0], b[0], a[1], b[1]) == dist(c[0], d[0], c[1], d[1])) {
            cout << "Yes";
        }
        else cout << "No";
        return 0;
    }

    ll length = dist(a[0], b[0], a[1], b[1]);

    bool res = false;

    vector<pair<int, pair<int, int>>> ans = vector<pair<int, pair<int, int>>>(n - 2);
    for (int i = 2; i < n; i++) {
        ans.push_back(make_pair(dist(a[0], b[0], a[i], b[i]), make_pair(angN(a[0], b[0], a[1], b[1], a[i], b[i]), angG(a[0], b[0], a[1], b[1], a[i], b[i]))));
    }
    sort(ans.begin(), ans.end());

    rep(i, n) rep(j, n) {
        if (i == j) continue;
        if (length != dist(c[i], d[i], c[j], d[j])) continue;
        bool flag = true;
        rep(k, n) {
            if (i == k) continue;
            if (j == k) continue;
            pair<int, pair<int, int>> isOK = make_pair(dist(c[i], d[i], c[k], d[k]), make_pair(angN(c[i], d[i], c[j], d[j], c[k], d[k]), angG(c[i], d[i], c[j], d[j], c[k], d[k])));
            if (!binary_search(ans.begin(), ans.end(), isOK)) {
                flag = false;
                break;
            }
        }
        if (flag) {
            res = true;
            break;
        }
    }
    if (res) cout << "Yes";
    else cout << "No";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef double db;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vl;
typedef vector<pii> vpii; typedef vector<pll> vpll;
#define FOR(n) for(int i=0;i<n;++i)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll gcd(ll a, ll b) { return a % b ? gcd(b, a % b) : b; }
const ll mod = 1e9 + 7; const ll inf = 0x3f3f3f3f;
ll qpow(ll a, ll b) { ll t = 1; while (b != 0) { if (b & 1)t = (t * a) % mod; a = (a * a) % mod; b >>= 1; }return t; }
int n;
char a[4];
int m;
ll f[1005] = { 0,1 };
ll p[1005] = { 1,2 };
void pre() {
	for (int i = 2; i < 1003; ++i) {
		f[i] = f[i - 1] + f[i - 2];
		f[i] %= mod;
		p[i] = p[i - 1] * 2;
		p[i] %= mod;
	}
}
signed main() {
	pre();
	cin >> n;
	FOR(4)cin >> a[i];
	if (n == 2 || n == 3) {
		cout << 1 << endl;
		return 0;
	}
	int cnt = 1;
	FOR(4) {
		m += (a[i] - 'A') * cnt;
		cnt *= 2;
	}
	switch (m)
	{
	case 2:case 3:case 5:case 13: {
		cout << p[n - 3] << endl;
		return 0;
	}
	case 1:case 6:case 7:case 9: {
		cout << f[n - 1] << endl;
		return 0;
	}
	default:
		cout << 1 << endl;
		break;
	}
	return 0;
}

#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
//typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T>
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template<typename T>
inline void prt(vector<vector<T> >& vv){ for(const auto& v : vv){ prt(v); } }
template <typename T>
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T>
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T>
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

/*

*/

int main(){
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
    ll t;
    cin >> t;
    rep(tes,t){
        ll n;
        cin >> n;
        ll a = 0;
        while(n%2==0){
            a++;
            n /= 2;
        }
        if(a==0)cout<<"Odd"<<endl;
        else if(a==1)cout<<"Same"<<endl;
        else cout<<"Even"<<endl;
    }

	return 0;
}


#include <stdio.h>
#define FOR(i, n) for (int i = 0; i < n; i++)
#define FORREV(i, n) for (int i = (n - 1); i >= 0; i--)
#define FORA(i, a, n) for (int i = a; i <= n; i++)
#define INF 1000000000
typedef long long int ll;
typedef unsigned long long int ull;

int sumOfDigits(int N)
{
    int sum = 0;

    while (N > 0)
    {
        sum += (N % 10);
        N /= 10;
    }

    return sum;
}

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

    (sumOfDigits(A) > sumOfDigits(B)) ? printf("%d\n", sumOfDigits(A)) : printf("%d\n", sumOfDigits(B));

    return 0;
}

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

using namespace std;

#define ll                 long long
#define faster             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define line               "\n"
#define sp                 " "

void sol() {
	string a, b;
	cin >> a >> b;
	int sum_1 = 0, sum_2 = 0;

	for (auto s : a)
		sum_1 += (s - '0');

	for (auto s : b)
		sum_2 += (s - '0');

	cout << max(sum_1, sum_2) << line;
}

int main()
{
	faster
	// int t;
	// cin >> t;
	// while (t--)
	sol();

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define eps 1e-9
#define INF 2000000000              // 2e9
#define LLINF 2000000000000000000ll // 2e18 (llmax:9e18)
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define drep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)

#define popcount __builtin_popcount
#define next __next
#define prev __prev

#ifndef LOCAL
#define dmp(...) ;
#else
#define dmp(...)                                                               \
  cerr << "[ " << #__VA_ARGS__ << " ] : " << dump_str(__VA_ARGS__) << endl
#endif

// ---------------- Utility ------------------

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

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

template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

// ----------------- Input -------------------

template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  return is >> p.first >> p.second;
}

template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}

// ----------------- Output ------------------

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

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

template <class T>
ostream &operator<<(ostream &os, const deque<T> &d) {
  for (const T &e : d) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &s) {
  os << "{ ";
  for (const T &e : s) os << e << " ";
  return os << "}";
}

template <class T, class U>
ostream &operator<<(ostream &os, const map<T, U> &m) {
  os << "{ ";
  for (const auto &[key, val] : m) os << "( " << key << " -> " << val << " ) ";
  return os << "}";
}

template <class TupleTy, size_t... I>
void dump_tuple(ostream &os, const TupleTy t, std::index_sequence<I...>) {
  (..., (os << (I == 0 ? "" : ",") << std::get<I>(t)));
}

template <class... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
  os << "(";
  dump_tuple(os, t, std::make_index_sequence<sizeof...(Args)>());
  return os << ")";
}

void dump_str_rec(ostringstream &) {}

template <class Head, class... Tail>
void dump_str_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << ", " << head;
  dump_str_rec(oss, forward<Tail>(tail)...);
}

template <class T, class... U>
string dump_str(T &&arg, U &&... args) {
  ostringstream oss;
  oss << arg;
  dump_str_rec(oss, forward<U>(args)...);
  return oss.str();
}

// --------------- Fast I/O ------------------

void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

// ------------------ ACL --------------------

// #include <atcoder/modint>
// constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
// using mint = atcoder::static_modint<MOD>;
// ostream &operator<<(ostream &os, const mint &v) {
//   return os << v.val();
// }

// ------------ End of template --------------

#define endl "\n"
using ll = long long;
using pii = pair<int, int>;

void solve() {
  int V, T, S, D;
  cin >> V >> T >> S >> D;
  if (D < V * T || D > V * S)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return;
}

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

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

#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define PI 3.141592653589

ll INF = 1LL << 60;

void rot( pair<double,double>& p, double theta ){

  pair<double,double> tempp = p;
  p.first = tempp.first * cos(theta) - tempp.second * sin(theta);
  p.second = tempp.first * sin(theta) + tempp.second * cos(theta);

}

void move( pair<double,double>& p, pair<double,double> move ){

  p.first = p.first + move.first;
  p.second = p.second + move.second;

}

double dot( pair<double,double> p, pair<double,double> q ){

  return p.first*q.first+p.second*q.second;

}

double norm( pair<double,double> p ){

  return sqrt( p.first*p.first+p.second*p.second );

}

int main(){

  ll N;
  cin >> N;
  double x0, y0;
  double xN2, yN2;
  cin >> x0 >> y0;
  cin >> xN2 >> yN2;
  pair<double,double> p0( x0,y0 );
  pair<double,double> pN2( xN2, yN2 );
  pair<double,double> pN20( x0-xN2, y0-yN2 );
  pair<double,double> center( (x0+xN2)/2, (y0+yN2)/2 );
  pair<double,double> px(1,0);

  double m = sqrt( pow(p0.first-pN2.first,2)+pow(p0.second-pN2.second,2) )/2;
  double r = sqrt( 2*m*m*(1-cos(2*PI/N)) ); //radius
  //cout << m << " "<< r << endl;

  double theta = acos( dot( pN20, px )/norm(pN20) );
  if( pN20.second < 0){
	theta = 2*PI - theta;
  }
  //cout << theta*180/PI << endl;

  pair<double,double> p1( r, 0 );
  //cout << p1.first << " " << p1.second << endl;
  rot( p1, PI - ((N-2)*PI)/(2*N) );

  move( p1, pair<double,double>( m, 0 ) );
  //cout << p1.first << " " << p1.second << endl;

  rot( p1, theta );
  move( p1, center);

  cout << fixed << setprecision(10) << p1.first << " " << p1.second << endl;

  return 0;

}


#include <bits/stdc++.h>
using namespace std;
const int kN = 505;
const int kInf = 1e9 + 7;

int n;
int a[kN][kN];

void No() {
  puts("No"); exit(0);
}
int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  }

  for(int i = 0; i < n - 1; i++) {
    int diff = a[i + 1][0] - a[i][0];
    for(int j = 0; j < n; j++) {
      if(a[i + 1][j] - a[i][j] != diff) No();
    }
  }

  for(int j = 0; j < n - 1; j++) {
    int diff = a[0][j + 1] - a[0][j];
    for(int i = 0; i < n; i++) {
      if(a[i][j + 1] - a[i][j] != diff) No();
    }
  }

  vector<int> x(n), y(n);

  int mn = kInf, nx = -1, ny = -1;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      if(mn > a[i][j]) {
        mn = a[i][j], nx = i, ny = j;
      }
    }
  }

  for(int i = 0; i < n; i++) x[i] = mn + a[i][0] - a[nx][0];
  for(int i = 0; i < n; i++) y[i] = a[0][i] - a[0][ny];

  puts("Yes");
  for(int i = 0; i < n; i++) printf("%d ", x[i]); puts("");
  for(int i = 0; i < n; i++) printf("%d ", y[i]); puts("");

  return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <iomanip>
#define ll long long int
#define inf 1000000000000
#define mod 1000000007

// templates
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define sz(x) (int)x.size()
#define ps(x,y)   fixed<<setprecision(y)<<x
#define fo(i,a,b) for(int i=a;i<b;i++)
#define ro(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define sc(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pr(n) printf("%d\n",n)
#define pl(n) printf("%lld\n",n)
#define prs(n) printf("%d ",n)
#define pls(n) printf("%lld ",n)
using namespace std;

ll GCD(ll a, ll b, ll& x, ll& y) {
	if (b == 0) {
		x = 1LL;
		y = 0LL;
		return a;
	}
	ll x1, y1;
	ll d = GCD(b, a % b, x1, y1);
	x = y1;
	y = x1 - y1 * 1LL * (a / b);
	return d;
}
void solve()
{
	ll n, s, k;
	sl(n), sl(s), sl(k);
	ll x, y;
	ll gc = __gcd(n, k);
	if (s % gc) {
		pl(-1LL);
	}
	else {
		// y->loops x->moves x*k+s=y*n => (x*k-y*n=-s)
		n /= gc, s /= gc, k /= gc;
		gc = GCD(k, n, x, y);
		ll mod_inv = (x % n + n) % n;
		ll ans = ((-s * mod_inv) % n + n) % n;
		pl(ans);
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	scanf("%d", &t);
	while (t--) {
		solve();
	}

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int n,s,d,x,y;
    cin>>n>>s>>d;
    int flag=0;

    for(int i=0;i<n;i++)
    {
         cin>>x>>y;
         if(x<s&&y>d)
         flag=1;
    }
    if(flag==1)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;

	return 0;
}

  #include<bits/stdc++.h>
  using namespace std;
  using ll = long long;
  #define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
  #define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
  #define repc(i,f,n) for(char i=(f); (i) <= (n); i++)
  #define PI 3.14159265358979323846264338327950L
  #define debug(x) cout<<#x<<" :: "<<x<<"\n";
  #define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
  #define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
  #define P pair<int, int>
  #define Pl pair<ll, ll>
  #define dvec vector<vector<ll>>
  #define OUT(x) cout << x << endl; return 0;
  //printf("%.10f\n")
  //cout << fixed << setprecision(10);
  template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
  template<class T> inline bool chmaxe(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 ll MOD = 1000000007ll;
  const ll INF = 1e+18;
  const int iINF = 1e9;
  const double EPS = 1e-8;

  int main()
{
  ll N, S, D; cin >> N >> S >> D;
  rep(i, 0, N){
    ll x, y; cin >> x >> y;
    if(x >= S) continue;
    if(y <= D) continue;
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
}


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

typedef long long int ll;
typedef unsigned long long int ul;

int main()
{
  ll n,a;
  cin>>n;
  a=n*1.08;
  if(a<206)
  {
    cout<<"Yay!\n";
  }

  else if(a>206)
  {
    cout<<":(\n";
  }
  else
  {
    cout<<"so-so\n";
  }
  return 0;
}

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

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//#define int long long
#define reset(x) memset(x,0,sizeof(x))
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define all(a) a.begin(),a.end()
#define PI 3.1415926535897932384626433832795
#define INF 1000000000
#define MOD 1000000007
#define MOD2 1000000009
#define EPS 1e-6
#define pb push_back
#define fi first
#define se second
#define mp make_pair

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
    int n; cin >> n;
   	int a = floor(n * 1.08);
   	if (a < 206)
   	{
   		cout << "Yay!";
   	}
   	else if (a == 206)
   	{
   		cout << "so-so";
   	}
   	else
   	{
   		cout << ":(";
   	}
}


//include <atcoder>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#define flush fflush(stdout)
#define endl '\n'
#define all(v) v.begin(), v.end()
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod1 = (int)1e9 + 7, mod2 = (int)998244353;
const int INF = (int)1e9 + 10;
const ll LINF = (ll)1e18 + 10;
const int di[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dj[8] = {0, 1, 0, -1, -1, 1, -1, 1};

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep1(i, a, b) for (i = a; i < b; i++)

template <typename T>
T my_abs(T x){
    return (x >= 0)? x : -x;
}

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

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

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

bool incld_bit(ll bit, int i){
    return ((bit>>i) & 1) == 1;
}

// --------------------------------------------------------------------------------

#define N 2000007
#define commod mod1
ll fac[N], inv[N], finv[N];

void cominit(int n) {
    int i;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (i = 2; i < n + 2; i++) {
        fac[i] = fac[i - 1] * i % commod;
        inv[i] = commod - inv[commod % i] * (commod / i) % commod;
        finv[i] = finv[i - 1] * inv[i] % commod;
    }
    return;
}

ll com(int n, int r) {
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    if (r == 0 || r == n) return 1;
    return (fac[n] * finv[r]) % commod * finv[n - r] % commod;
}

int main(void){
    int i, j;
    int n, m, k;

    cin >> n >> m >> k;

    if (n - m > k){
        cout << 0 << endl;
        return 0;
    }

    cominit(n + m);

    int ans;
    ans = (com(n + m, n) + mod1 - com(n + m, m + k + 1)) % mod1;

    cout << ans << endl;

    return 0;
}

#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
#include <bitset>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef vector<long double> vld;
typedef vector<vld> vvld;
typedef unordered_map<ll, ll> uii;
typedef unordered_map<ll, ll> uuii;
typedef unordered_map<ll, ll> uuuii;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef bitset<64> bs;
const ll LINF = 1e17;
const long double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define ALL(X) (X).begin(),(X).end()

template <typename T> T gcd(T a, T b) {return (a == 0) ? b : gcd(b%a, a);}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b;}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}

int main(int argc, const char* argv[]){

#if defined(__LOCAL__)
    std::string file_name = argv[1]; ifstream in_file(file_name.c_str()); cin.rdbuf(in_file.rdbuf());
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

    ll N, M; cin >> N >> M;

    map<ll, vpl> yz;
    rep(_, M){
        ll x, y, z; cin >> x >> y >> z;
        yz[x].pb({y,z});
    }

    vvl dp(N+1, vl(1ll<<N, 0));
    dp[0][0] = 1;

    rep(i, N){
        rep(st, 1ll<<N){
            if(dp[i][st] == 0) continue;

            rep(k, N){
                if(bit(st, k)) continue;

                ll nst = st | (1ll<<k);
                bool ok = true;
                for(const auto& yzp : yz[i+1]){
                    ll y = yzp.first, z = yzp.second;
                    ll cnt_st = nst & ((1ll << y) - 1);
                    if(z < popcnt(cnt_st)){
                        ok = false; break;
                    }
                }

                if(ok){
                    dp[i+1][nst] += dp[i][st];
                }
            }
        }
    }

    cout << dp[N][(1ll<<N)-1] << endstr;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
    int n,x,i,j;
    cin>>n>>x;
    char s[n+1];
    cin>>s;
    for(i=0;i<n;i++)
    {
        if(s[i]=='o')
        {
            x++;
        }
        else
        {
            x--;x=max(x,0);
        }
    }
    cout<<x<<endl;
}

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

int main() {
  int N, X;
  string S;
  cin >> N >> X >> S;

  int point = X;
  rep (i, N) {
    if (S.at(i) == 'o')
      point++;
    else
      point = max(0, point-1);
  }

  cout << point << endl;
}


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

int solve()
{
    int n;
    string f, t;
    cin >> n >> f >> t;
    int n1f = 0, n1t = 0;
    for(int i = 0; i < n; ++i)
    {
        if(f[i] == '1')
            n1f++;
        if(t[i] == '1')
            n1t++;
    }
    if(n1f != n1t)
    {
        cout << "-1\n";
        return 0;
    }
    vector<int> mv(n,0);
    int posf=0, post=0;
    while(posf<n && post<n){
        while(f[posf]!='1' && posf<n)
            posf++;
        while(t[post]!='1' && post<n)
            post++;
        f[posf]='0';
        t[post]='0';
        mv[posf]=post-posf;
    }
    // move to the right
    int groupmove=0;
    int sol=0;
    for(int i=0; i<n; i++)
    {
        if(mv[i]>0){
            sol+=mv[i]-groupmove;
            groupmove+=mv[i]-groupmove;
        }
        if(mv[i]==0 && groupmove>0){
            groupmove--;
        }
    }
    // to the left
    groupmove=0;
    for(int i=n-1; i>=0; i--)
    {
        if(mv[i]<0){
            sol+=-mv[i]-groupmove;
            groupmove+=-mv[i]-groupmove;
        }
        if(mv[i]==0 && groupmove>0){
            groupmove--;
        }
    }

    //debug( mv);
    cout << sol << "\n";
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ntest = 1;
    for(int test = 0; test < ntest; ++test)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
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<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll mod=998244353;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

ll dp[3001][6001];

ll rec(ll n, ll k){
    if(n < k) return 0;
    if(k == 0){
        if(n == 0) return 1;
        else return 0;
    }
    if(~dp[n][k]) return dp[n][k];
    ll ret = (rec(n - 1, k - 1) + rec(n, 2 * k)) %mod;
    return dp[n][k] = ret;
}

int main(){
    memset(dp, -1, sizeof(dp));
    ll n, k;cin >> n >> k;
    cout << rec(n, k) << endl;
    return 0;
}

/*
 * @Author: RBQRBQ
 * @Date: 2020-11-02 10:48:40
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-11-02 11:02:18
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
const ll mod (998244353);
ll mul(ll a,ll b)
{
    return 1ll*a*b%mod;
}
ll dp[4000][4000];
ll n,k;
int main()
{
    read(n),read(k);
    for(int i=0;i<=3999;i++)
    for(int j=0;j<=3999;j++)
    if(i<j) dp[i][j]=0;
    for(int i=0;i<=3999;i++)
    dp[i][i]=1;
    for(int i=1;i<=3999;i++)
    for(int j=3999;j>=1;j--)
    if(2*j<=3999)
    dp[i][j]=(dp[i-1][j-1]+dp[i][2*j])%mod;
    else
    {
        dp[i][j]=dp[i-1][j-1];
    }

    cout<<dp[n][k];
}


#include<bits/stdc++.h>
#include<bits/extc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace __gnu_pbds;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t){
	while(*sdbg != ',') { cerr<<*sdbg++; } cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<": "; for(auto i:x) cerr<<i<<" "; cerr<<endl;}}
#define debugr(l,r,x) {{cerr<<#x<<": "; for(int i=l;i<=r;i++) cerr<<x<<" "; cerr<<endl;}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debugr(l,r,x)
#define cerr while(0) cerr
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define int long long
typedef __int128 INT;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define priority_queue std::priority_queue
#define F first
#define S second
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	vi v;
	for(int i=1; i<=10000; i++){
		if(i%3==0 || i%5==0 || i%7==0 || i%11==0) v.push_back(i);
	}
	debug(v.size());
	int n;
	cin>>n;
	for(int i=0; i<n-1; i++){
		cout<<v[i]*2<<" ";
	}
	cout<<1155<<endl;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;
#define F(i,s,e) for(ll i=s;i<e;++i)
#define IA(array,size) F(i,0,size) cin >> array[i];
#define PA(array,size) F(i,0,size) cout << array[i] << " "; cout << endl;
constexpr int32_t MOD=1000000007;

int main(){
    ll n;
    cin >> n;
    ll p[n];
    IA(p,n);
    ll ans=0;
    bool ng[200010];
    F(i,0,200010){
        ng[i]=0;
    }
    F(i,0,n){
        ng[p[i]]=1;
        if(!ng[ans]){
            cout << ans << endl;
        }
        else{
            while(ng[ans]){
                ++ans;
            }
            cout << ans << endl;
        }
    }

    return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(c % 2 == 0){
    if(abs(a) == abs(b)) cout << "=" << endl;
    else if(abs(a) > abs(b)) cout << ">" << endl;
    else cout << "<" << endl;
  }else{
    if(a == b) cout << "=" << endl;
    else if(a > b) cout << ">" << endl;
    else cout << "<" << endl;
  }
  return 0;
}

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

int main(){
  char C1,C2,C3; cin>>C1>>C2>>C3;
  if(C1==C2 && C2==C3)
    cout<<"Won"<<endl;
  else
    cout<<"Lost"<<endl;
}


#include <bits/stdc++.h>

int count(std::vector<std::vector<int>> vecs) {
    int max = vecs[0][0] - 1;
    int cnt = 0;
    for (int i = 0; i < vecs.size(); i++) {
        if (max < vecs[i][0]) {
            cnt++;
            max = vecs[i][1];
        }
    }
    return cnt;
}

int validation_check(std::vector<std::vector<int>> vecs) {
    std::sort(vecs.begin(), vecs.end(), [] (auto lhs, auto rhs) { return lhs[0] < rhs[0]; });
    int a = count(vecs);
    std::sort(vecs.begin(), vecs.end(), [] (auto lhs, auto rhs) { return lhs[1] < rhs[1]; });
    int b = count(vecs);
    return a - b;
}

std::vector<std::vector<int>> run(int N, int M) {

    std::vector<std::vector<int>> vecs(N, std::vector<int>(2, -1));
     if (M == 0) {
        for (int i = 0; i < N; i++) {
            vecs[i][0] = 2 * i + 1;
            vecs[i][1] = 2 * (i + 1);
        }
    } else if (std::abs(M) > N - 2) {
    } else if (M > 0) {
        vecs[0][0] = 1;
        vecs[0][1] =  2 * (M + 2);
        int i = 1;
        for (;i <= M + 1; i++) {
            vecs[i][0] = 2 * i;
            vecs[i][1] = 2 * i + 1;
        }
        for (; i < N; i++) {
            vecs[i][0] = 2 * i + 1;
            vecs[i][1] = 2 * (i + 1);
        }
    }

    // std::cout << vecs[0][0] << std::endl;
    // if (vecs[0][0] > -1) {
    //     int res = validation_check(vecs);
    //     std::cout << res << " " << M << std::endl;
    //     if (res != M) {
    //         std::cout << "N = " << N << ", M = " << M << std::endl;
    //         for (auto vec : vecs) {
    //             std::cout << vec[0] << " " << vec[1] << std::endl;
    //         }
    //         std::exit(0);
    //     }
    // }
    return vecs;
}

int main() {

    // std::mt19937 gen{std::random_device{}()};
    // std::uniform_int_distribution<> dist(1, 20);
    // for (int i = 0; i < 100; i++) {
    //     int N = dist(gen);
    //     int M = dist(gen) - 10;
    //     run(N, M);
    // }
    int N, M;
    std::cin >> N >> M;
    auto vecs = run(N, M);
    if (vecs[0][0] == -1) {
        std::cout << -1 << std::endl;
    } else {
        for (auto vec : vecs) {
            std::cout << vec[0] << " " << vec[1] << std::endl;
        }
    }
}

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

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

#define vec vector
#define PB push_back

#define MP make_pair
#define MT make_tuple
#define F first
#define S second

using ll = long long int; // watch out for overflows in your code
using pii = pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void debug() { cout << "\n"; };
template <typename T, typename... Targs>
void debug(T t, Targs... args) {
    cout << t << " ";
    debug(args...);
}

template <typename T1, typename T2>
inline ostream& operator << (ostream& os, const pair<T1,T2>& p) {
    return os << "(" << p.F << ", " << p.S << ")";
}

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

template <typename T>
inline ostream& operator << (ostream& os, const vec<vec<T>>& m) {
    for(auto& v : m) {
        for(auto& t : v) {
            os << t << " ";
        }
        os << "\n";
    }
    return os;
}

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

template <typename K, typename V>
inline ostream& operator << (ostream& os, const map<K,V>& m) {
    for(auto& p : m) {
        os << p.F << " -> " << p.S << "\n";
    }
    return os;
}

string s, t, u;
int n;

set<char> ccs;
void consume(const string& S) {
    ffor(i, 0, S.size() - 1) {
        ccs.insert(S[i]);
    }
}

vec<int> m(26, -1);

bool check(const string& S) {
    return m[S[0]-'a'] != 0;
}

ll encode(const string& S) {
    ll x = 0;
    ffor(i, 0, S.size()-1) {
        x += (ll) m[S[i]-'a'];
        if(i < (int) S.size()-1) {
            x *= 10LL;
        }
    }
    return x;
}

vec<char> ccv;
vec<int> aa;

bool csearch(int i) {
    if(i == n) {
        return check(s) &&
               check(t) &&
               check(u) &&
               encode(s) + encode(t) == encode(u);
    }
    char c = ccv[i];
    //bool ret = false;
    ffor(d, 0, 9) {
        if(aa[d]) {
            aa[d] = 0;
            m[c-'a'] = d;
            if(csearch(i+1)) return true;
            m[c-'a'] = -1;
            aa[d] = 1;
        }
    }
    return false;
}

bool compute() {
    n = (int) ccs.size();
    if(n > 10) return false;
    aa.assign(10, 1);
    for(char c : ccs) ccv.PB(c);
    return csearch(0);
}

////////////////////////////////////////////////////////////////////////

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

    cin >> s >> t >> u;
    consume(s);
    consume(t);
    consume(u);

    bool ans = compute();
    if(ans) {
        cout << encode(s) << "\n";
        cout << encode(t) << "\n";
        cout << encode(u) << "\n";
    }
    else {
        cout << "UNSOLVABLE\n";
    }

    //debug(s, t, u);

    //ffor(i, 0, 25) m[i] = i+1;
    //debug(encode(string("abcdef")));
    //debug(encode("12039"));
    //debug(encode("1293"));
}


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

int main() {
  int H, W, X, Y;
  cin >> H >> W >> X >> Y;
  X = X-1;
  Y = Y-1; //添え字にした
  vector<vector<char>> data(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  } //2元配列入れた

  int count = 0;
  for (int i = X; i < H; i++) {
    if(data.at(i).at(Y) == '#'){
      break;
    }
    count++;
  }
  for (int i = X; i > -1; i--) {
    if(data.at(i).at(Y) == '#'){
      break;
    }
    count++;
  }
  for (int i = Y; i < W; i++) {
    if(data.at(X).at(i) == '#'){
      break;
    }
    count++;
  }
  for (int i = Y; i > -1; i--) {
    if(data.at(X).at(i) == '#'){
      break;
    }
    count++;
  }

  count = count -3;
  cout << count << endl;

}


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

// Pragmas
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

// Macros
#define F first
#define S second
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)

// Aliases
using ll = long long;
using ull = unsigned long long;
using ld = long double;

// Constants
constexpr ll INF = 2e18;
constexpr ld EPS = 1e-9;
constexpr int MOD = 1e9 + 7;

// :D
#define int long long

// Custom hash map
struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
// Use int type for keys
template <typename T1, typename T2>
using safe_map = unordered_map<T1, T2, custom_hash>;

// Operator overloads
// cin >> pair<T1, T2>
template<typename T1, typename T2>
istream& operator>>(istream &istream, pair<T1, T2> &p)
{
    istream >> p.first >> p.second;
    return istream;
}
// cin >> vector<T>
template<typename T>
istream& operator>>(istream &istream, vector<T> &v)
{
    for (auto &it : v) cin >> it;
    return istream;
}
// cout << pair<T1, T2>
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, const pair<T1, T2> &p)
{
    ostream << p.first << " " << p.second;
    return ostream;
}
// cout << vector<T>
template<typename T>
ostream& operator<<(ostream &ostream, const vector<T> &c)
{
    for (auto &it : c) cout << it << " ";
    return ostream;
}

// Utility functions
template <typename T>
void print(T &&t)
{
    cout << t << "\n";
}
template <typename T, typename... Args>
void print(T &&t, Args &&... args)
{
	cout << t << " ";
	print(forward<Args>(args)...);
}

template <typename T>
int32_t size_i(T &container) { return static_cast<int32_t>(container.size()); }

// Mathematical functions
int GCD(int a, int b)
{
	if (!b) return a;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return (a * b) / GCD(a, b);
}
int modpow(ll x, int n, int m = MOD) {
    ll res = 1;
    while (n > 0)
	{
        if (n & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        n >>= 1;
    }
    return res;
}

int binpow(int x, int n) {
    int res = 1;
    while (n > 0)
	{
        if (n & 1)
            res = res * x;
        x = (x * x);
        n >>= 1;
    }
    return res;
}
// @param m should be prime
int modinv(int x, int m = MOD)
{
	return modpow(x, m - 2, m);
}

mt19937 rng;
int getRandomNumber(int l, int r)
{
    uniform_int_distribution<int> dist(l, r);
    return dist(rng);
}

// Flags to use: -std=c++17 -O2 -Wshadow -DLOCAL_PROJECT -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -fsanitize=address -fsanitize=undefined
////////////////////////////////// START CODE HERE //////////////////////////////////

void preSolve()
{
    rng = mt19937(chrono::steady_clock::now().time_since_epoch().count());
}

void solve(int tc)
{
    vector<int> a(3);
    cin >> a;
    sort(all(a));
    print(a[1] + a[2]);
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);
    cout << setprecision(3) << fixed;

    preSolve();
    int tests = 1;
    // cin >> tests;
    for (int t = 1; t <= tests; t++)
        solve(t);
    return 0;
}

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

const int MAX_N = 2020;
vector<int> road[MAX_N];
int N, M, A, B;
int vised[MAX_N], visId;
int x;
ll sum;
ll DFS(int s){
    if(vised[s] == visId){
        return 0;
    }
    vised[s] = visId;
    ll cnt = 1;
    for(auto e : road[s]){
        cnt += DFS(e);
    }
    return cnt;
}
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> A >> B;
        road[A].emplace_back(B);
    }
    for(int i = 1; i <= N; i++){
        visId = i;
        sum += DFS(i);
    }
    cout << sum << '\n';
    return 0;
}


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

using i64 = long long;
using u64 = unsigned long long;

struct debug {
    ~debug(){cerr << endl;}
    template<class c> debug& operator<<(c x) {cerr << x; return *this;}
    template<class c, class d>
    debug& operator<<(pair<c, d> x) {*this << "(" << x.first << ", " << x.second << ")";
        return *this;}
    template<class c> debug& operator<<(vector<c> x) { *this << "[";
        int f = 0; for(auto it : x) { *this << (f?", ":""); *this << it; f = 1;}
        *this << "]"; return *this;}
};

#define dbg(x) "[" << #x << ": " << x << "]  "
#define Wa() cerr << "[LINE: " << __LINE__ << "] -> "; debug() <<
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(NULL)

int dp[1000+3][1000+3];

vector<int> a, b;

int f(int i, int j)
{
    if(i == 0 || j == 0) {
        return abs(i-j);
    }
    int& ret = dp[i][j];
    if(ret != -1) return ret;

    ret = min({f(i-1, j) + 1, f(i, j-1) +1, f(i-1, j-1) + (a[i-1] != b[j-1])});
    return ret;
}

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

    a = vector<int> (n);
    b = vector<int> (m);
    for(int& i : a) cin >> i;
    for(int& i : b) cin >> i;

    memset(dp, -1, sizeof dp);

    cout << f(n, m) << '\n';
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr long long INF = 1000000000 + 100;
constexpr long long LINF = 1000000000000000000 + 100;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

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

    vector<vector<ll>> dp(n+10, vector<ll>(m+10, LINF));
    dp[0][0] = 0;
    rep(i, n+1){
        rep(j, m+1){
            chmin(dp[i+1][j], dp[i][j]+1);
            chmin(dp[i][j+1], dp[i][j]+1);
            if(A[i]==B[j]){
                chmin(dp[i+1][j+1], dp[i][j]);
            }else{
                chmin(dp[i+1][j+1], dp[i][j]+1);
            }
        }
    }
    cout << dp[n][m] << ln;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a+b>=15&&b>=8)
    {
        cout<<1;
        return 0;
    }
    else if(a+b>=10&&b>=3)
    {
        cout<<2;
        return 0;
    }
    else if(a+b>=3)
    {
        cout<<3;
        return 0;
    }
    else
    {
        cout<<4;
        return 0;
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define lld long double
#define inf 1000000000
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define mod2 998244353
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; ++i)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define w(x)  int x; cin>>x; while(x--)
#define in(a) for(auto &x: a)cin>>x;
void print(bool n){if(n)cout<<"YES\n";else cout<<"NO\n";}
signed main(){
    fastio
	int a,b;
	cin>>a>>b;
	if(a+b>=15 && b>=8)cout<<1<<'\n';
	else if(a+b>=10 && b>=3)cout<<2<<'\n';
	else if(a+b>=3)cout<<3<<'\n';
	else cout<<4<<'\n';
}


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

using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<pint> p(N);
    rep(i,N){
        cin >> p[i].first >> p[i].second;
    }
    int count = 0;
    for(int i = 0;i < (N - 1);i++){
        for(int j = i + 1;j < N;j++){
            float x = abs(p[i].first - p[j].first);
            float y = abs(p[i].second - p[j].second);
            float g = y / x;
            //cout << g << endl;
            if((0 <= g) && (g <= 1)){
                //cout << x << ' '<< y << endl;
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include <bitset>
// #include <atcoder/all>
#include <fstream>
#include <random>
#include <cassert>

//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;
// using namespace atcoder;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e16;
const ll INF = 1e16;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const long double PI = 3.1415926535897932;

using Graph = vector<vector<ll>>;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(15);		// 15桁表示指定

	ll n;
	cin >> n;

	ll ans = n;

	ll b = 2;

	for (int i = 1; i <= 60; i++)
	{
		ll a = n / b;
		ll c = n % b;
		ans = min(ans, a + i + c);
		b *= 2;
	}

	cout << ans << endl;

	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n, ans=0;
	cin >> n;
	ll maxa=0, x, y;
	vector<ll> a, b;
	rep(i, n){
		cin >> x;
		a.push_back(x);
	}
	rep(i, n){
		cin >> x;
		b.push_back(x);
	}

	rep(i, n){
		chmax(maxa, a[i]);
		chmax(ans, maxa*b[i]);
		cout << ans << endl;
	}
	return 0;
}

///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           nd(a,b,c)                   mp(mp(a,b),c)
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=2e18;
const int mod=1e9+7;
const int M=200005;
int a[M],b[M],n;
 main()

{
    fast
    cin>>n;
    f(i,1,n)
    {
        cin>>a[i];
    }
    f(i,1,n)
    {
        cin>>b[i];
    }
    int ses=0,mx=0;
    f(i,1,n)
    {
        mx=max(mx,a[i]);
        ses=max(ses,mx*b[i]);
        cout<<ses<<"\n";
    }
    return 0;

}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pi 				(acos(-1.0))

#define fff ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

int main() {

	fff;

long long r, x, y; cin>>r>>x>>y;

long double d = sqrt(x*x*1.0 + y*y*1.0);

long long dd= ceil(d/r);

  if(dd==1LL && ((x*x)+(y*y))%(r*r))
 dd++;
 cout << dd<<endl;

	return 0;
}

#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define tp          tuple<int,int,int>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;
int ara[10];

int solve(int id , int taken , int tgt) {
    if(id == 5) return taken == tgt;
    return ( solve(id+1, taken + ara[id] , tgt) | solve(id+1 , taken , tgt) );

}

int main()  {
    fastio;
    int tot = 0;

    for(int i = 1; i <= 4 ; i++ ) cin>>ara[i] , tot += ara[i];
    if(tot%2) {
        cout<<"No\n";
        return 0;
    }

    int ok = solve(1 , 0 , tot/2)<<'\n';

    if(ok) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265
#define seive_len 10000001

typedef long long int lli;

vector<bool> seive(seive_len, true);
const int MOD = 1000000007;
lli primeSeive[seive_len];

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

lli lcm(lli a, lli b) {
  lli gcd_ = gcd(a, b);
  lli lcm_ = (a*b)/gcd_;
  return lcm_;
}

lli ncr(lli n, lli r) {
  lli res = 1;
  if(r > n-r)
    r = n-r;

  for(lli i=0;i<r;i++) {
    res *= (n-i);
    res /= (i+1);
  }
  return res;
}

lli ncrMODp(lli n, lli r) {
  if(r > n-r)
    r = n-r;
  lli prow[r+1];
  memset(prow, 0, sizeof(prow));
  prow[0] = 1;
  for(lli i=1;i<=n;i++) {
    for(lli j=min(i, r);j>0;j--) {
      prow[j] = (prow[j]+prow[j-1])%MOD;
    }
  }
  return prow[r];
}

lli fastPower(lli a, lli b) {
  lli res=1;
  while(b > 0) {
    if(b&1)
      res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}

lli fastPowerMODp(lli a, lli b) {
  a %= MOD;
  lli res = 1;
  while(b) {
    if(b%2 == 1)
      res = (res*a)%MOD;
    a = (a*a)%MOD;
    b >>= 1;
  }
  return res;
}

void multiply(lli a[][2], lli b[][2]) {
  lli res[2][2];
  memset(res, 0, sizeof(res));
  for(lli i=0;i<2;i++) {
    for(lli j=0;j<2;j++) {
      for(lli k=0;k<2;k++) {
        res[i][j] += a[i][k]*b[k][j]%MOD;
      }
    }
  }
  for(lli i=0;i<2;i++)
    for(lli j=0;j<2;j++)
      a[i][j] = res[i][j];
}

void matrixExpo(lli a[][2], lli n) {
  if(n == 0 || n == 1)
    return;
  lli b[][2] = {{1,1}, {1,0}};
  matrixExpo(a, n/2);
  multiply(a, a);
  if(n%2)
    multiply(a, b);
}

void makeSeive() {
  for(lli i=2;i*i<=seive_len;i++) {
    if(seive[i]) {
      for(lli j=i*i;j<=seive_len;j+=i)
        seive[j] = false;
    }
  }
}

void makePrimeSeive() {
  for(lli i=1;i<seive_len;i++)
    primeSeive[i] = i;
  for(lli i=4;i<seive_len;i+=2)
    primeSeive[i] = 2;
  for(lli i=3;i*i<seive_len;i++) {
    if(primeSeive[i] == i) {
      for(lli j=i*i;j<seive_len;j+=i) {
        if(primeSeive[j] == j)
          primeSeive[j] = i;
      }
    }
  }
}

bool isPrime(lli n) {
  for(lli i=2;i<=sqrt(n);i++) {
    if(n%i == 0)
      return false;
  }
  return true;
}

void getInput(vector<lli>& a, lli n) {
  lli x;
  for(lli i=0;i<n;i++) {
    cin >> x;
    a.push_back(x);
  }
}

void testCase() {
    lli n;
    cin >> n;
    vector<lli> a(n), b(n);
    for(lli i=0;i<n;i++)
        cin >> a[i] >> b[i];
    lli sum = 0, suma = 0;
    for(lli i: b)
        sum += i;
    for(lli i: a)
        suma += i;
    vector<pair<lli, lli>> c;
    for(lli i=0;i<n;i++)
        c.push_back({2*a[i]+b[i], i});
    sort(c.rbegin(), c.rend());
    sum = 0;
    lli i = 0;
    while(sum <= suma) {
        sum += a[c[i].second]+b[c[i].second];
        suma -= a[c[i].second];
        i++;
    }
    cout << i;
}

int main() {
  	// ios_base::sync_with_stdio(false);
  	// cin.tie(NULL);
  	lli t=1;
  	// cin >> t;
    // makePrimeSeive();
  	makeSeive();
    // FILE* fp;
    // fp = fopen("out.txt", "w");
  	for(lli i=1;i<=t;i++) {
      // fprintf(fp, "Case #%d:\n", i);
      // cout << "Case #" << i << ":" << ' ';
  		// cout << "Scenario #" << i << ":" << endl;
  		testCase();
      cout << '\n';
  	}
  	return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<vector>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const ll maxn = 200010;
ll a[200010],b[200010],ans[200010];
struct st{
	ll a,b,c,d;
}p[200010];
bool cmp(st aa,st bb){
	return aa.d+aa.a>bb.d+bb.a;
}
int main(){
	ll n;
	cin>>n;
	ll s=0;
	ll a,b;
	for(ll i=0;i<n;i++){
		cin>>p[i].a>>p[i].b;
		p[i].c=p[i].b-p[i].a;
		p[i].d=p[i].b+p[i].a;
		s-=p[i].a;
	}
	sort(p,p+n,cmp);
	ll cnt=0,j=0;
	while(s<=0){
		s+=p[j].d+p[j].a;
		j++;
		cnt++;
	}
	cout<<cnt<<endl;
}


/* dont stick to an approach */
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#include <numeric>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long int ull;
typedef long double ldb;

#define PB push_back

#define For(i, n) for (ll i = 0; i < n; i++)

#define PYES cout<<"YES\n"
#define PNO cout<<"NO\n"
#define PYes cout<<"Yes\n"
#define PNo cout<<"No\n"

#define vll             vector<ll>
#define rev(v)          reverse(v.begin(),v.end())
#define srt(v)          sort(v.begin(),v.end())
#define grtsrt(v)       sort(v.begin(),v.end(),greater<int>())
#define mnv(v)          *min_element(v.begin(),v.end())
#define mxv(v)          *max_element(v.begin(),v.end())
#define all(v)          v.begin(),v.end()

#define Fas ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

const int M= 1e9 +7;

//--------------------------------------------functions-------------------------------------------------//

ll power(ll a,ll b){int result=1;while(b>0){if(b%2 == 1){result *= a;} a *= a;b /= 2;}return result;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
ll countSetBits(ll x){ll Count=0;while(x>0){if(x&1) Count++;x=x>>1;}return Count;}
bool isPerfectSquare(ll n){ll sr = sqrt(n);if (sr * sr == n)return true;else return false;}
ll mod(ll x){return ((x%M + M)%M);}
ll add(ll a, ll b){return mod(mod(a)+mod(b));}
ll mul(ll a, ll b){return mod(mod(a)*mod(b));}
ll powerM(ll a,ll b){ll res=1;while(b){if(b%2==1){res=mul(a,res);}a=mul(a,a);b/=2;}return res;}
//------------------------------------sieve of erantothenes-----------------------------------------------//

vector<bool> sieve_of_eratothenes(ll n){
    vector<bool> a(n+1,1);
    a[0]=0;
    a[1]=0;
    for(ll i=2;i<=sqrt(n);i++){
        if(a[i]==1){
            for(ll j=2;i*j<=n;j++){
                a[j*i]=0;
            }
        }
    }
    return a;
}
//----------------------------------------nCr mod------------------------------------------------------//
ll modInverse(ll n){
    return powerM(n,M-2);
}
ll nCrM(ll n,ll r){
    if(n<r) return 0;
    if(r==0) return 1;
    vector<ll> fact(n+1);
    fact[0]=1;
    for(ll i=1;i<=n;i++){
        fact[i]=mul(fact[i-1],i);
    }
    return mul(mul(fact[n],modInverse(fact[r])),modInverse(fact[n-r]));
}
//-----------------------------------------------solve-----------------------------------------------------//
void solve(){
    ll 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;
    }
}
int main(){
    Fas;

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

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int a, b;
int main(){
	scanf("%d%d", &a, &b);
	if((a+b) >= 15 && b >= 8){
		puts("1");
	}else if((a+b) >= 10 && b >= 3){
		puts("2");
	}else if((a+b) >= 3){
		puts("3");
	}else puts("4");
}


#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>PII;
typedef long long ll;
ll split(ll n) {
    ll i, j, te, x, xlen;
    for (i = 1, xlen = 0; (te = i * (i - 1) / 2) < n; i++) {
        x = n - te;
        if (x % i == 0) {
            x /= i;
            xlen++;
        }
    }
    return xlen;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	if(n==1){
		cout<<2<<endl;
	}
	else cout<<2*split(n)<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define fast_io cin.tie(0);ios_base::sync_with_stdio(0);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() { cout << endl; exit(0);}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cout << " " << to_string(H); debug_out(T...);}
template <typename Head, typename... Tail> void show(Head H, Tail... T) {cout <<H<<" "; show(T...);}
template <typename Head, typename... Tail> void pret(Head H, Tail... T) {cout <<H<<" "; pret(T...);}
#define pr(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
#define int ll
typedef long double ld;
typedef vector<int> vi;
#define disp(x) cout<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(int)b;i++)
#define fo(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define mp make_pair
#define pb emplace_back
#define F first
#define S second
#define endl '\n'
//cout.setf(ios::fixed);cout.precision(18)
const int MOD = 1e9+7;
const int maxn = 1e7 +10;

bool f(int n, int tot){
	tot *= 2;
	if(tot % n != 0) return 0;
	tot /= n;
	tot -= (n - 1);
	// show(n, tot);
	return ((tot % 2) == 0 and tot / 2 > 0);
}

int32_t main(){
    fast_io;
	int n;
    cin >> n;
    int ans = 0;
    fo(i, 1, maxn){
    	if(f(i, n)) ans++;
    }
    show(ans * 2);
    return 0;
}


#pragma GCC optimize("O3")
// #include <atcoder/all>
// using namespace atcoder;
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

// using mint = modint998244353;
// ostream& operator<<(ostream& out, mint m){
//   out << m.val();
//   return out;
// }

const int P = 998244353;
void add(int &a,int b){
  a += b;
  if(a >= P)
    a -= P;
}
void sub(int &a,int b){
  a -= b;
  if(a < 0)
    a += P;
}
int mul(int a,int b){
  return a * b % P;
}
int n;
int res = 0;
vector<vector<int>> dp;
vector<int> t;
void add(int x){
  int pom = t[x];
  int a = SZ(dp);
  int b = SZ(dp[0]);
  vector<vector<int>> dp2(a + 1,vector<int>(b + pom));
  R(i,a)R(j,b){
    add(dp2[i + 1][j + pom], mul(dp[i][j], i + 1));
    if(j <= pom){
      add(dp2[a - i][pom - j], mul(dp[i][j], a - i));
    }else{
      add(dp2[i][j - pom], mul(dp[i][j], a - i));
    }
  }
//   debug(dp,pom,dp2);
  swap(dp,dp2);
}
void licz(int po,int ko){
  if(po + 1 == ko){
    debug(po,dp);
    R(i,SZ(dp)){
      R(j,min(SZ(dp[0]), t[po])){
        sub(res, dp[i][j]);
      }
    }
    debug(po,t[po],res);
    return;
  }
  int m = (po + ko) / 2;
  auto pam = dp;
  for(int i = po; i < m; i++)add(i);
  licz(m,ko);
  swap(dp,pam);
  for(int i = m; i < ko; i++)add(i);
  licz(po,m);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  t.resize(n);
  res = 1;
  R(i,n){
    cin >> t[i];
    res = mul(res, i + 1);
  }
  debug(res);
  dp.resize(1,vector<int>(1,1));
  licz(0,n);
  cout << res << "\n";
}

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

typedef long long ll;
typedef unsigned long long ull;

#define mp make_pair
#define fr first
#define sc second

template<class T> T T_INF(){ return 1000000000000000000; }
template<> int T_INF<int>(){ return 1000000000; }

template<int MOD> struct modint{
	ull val;
	modint(ull x){ val=x%MOD; }
	modint(){}
	friend modint modpow(modint x,ull k){
		modint ret(1ULL);
		while(k>0){
			if(k&1ULL)ret*=x;
			x*=x;
			k>>=1;
		}
		return ret;
	}
	modint& operator +=(const modint& rhs){
		this->val+=rhs.val;
		if(this->val>=MOD)this->val-=MOD;
		return *this;
	}
	friend modint operator+(modint lhs, const modint& rhs){
		lhs+=rhs;
		return lhs;
	}
	modint& operator -=(const modint& rhs){
		this->val+=MOD-rhs.val;
		if(this->val>=MOD)this->val-=MOD;
		return *this;
	}
	friend modint operator-(modint lhs, const modint& rhs){
		lhs-=rhs;
		return lhs;
	}
	modint& operator *=(const modint& rhs){
		this->val*=rhs.val;
		this->val%=MOD;
		return *this;
	}
	friend modint operator*(modint lhs, const modint& rhs){
		lhs*=rhs;
		return lhs;
	}
	static vector<modint> inv_;
	static void precalc_inv_(int k){
		int t=inv_.size();
		inv_.resize(k);
		for(int i=t;i<k;i++){
			inv_[i]=modpow(modint(i),MOD-2);
		}
	}
	modint& operator /=(const modint& rhs){
		//if(rhs.val<inv_.size()){
		//	(*this)*=inv_[rhs.val];
		//}
		//else {
			(*this)*=modpow(rhs,MOD-2);
		//}
		return *this;
	}
	friend modint operator/(modint lhs, const modint& rhs){
		lhs/=rhs;
		return lhs;
	}

	static vector<vector<modint>> C_;
	static vector<modint> fac,inv_fac;
	static void precalc_C_(int k){
		C_.resize(k,vector<modint>(k));
		for(int i=0;i<k;i++){
			C_[i][0]=C_[i][i]=1;
			for(int j=1;j<=i-1;j++){
				C_[i][j]=C_[i-1][j-1]+C_[i-1][j];
			}
		}
	}
	static void precalc_fac(int k){
		fac.resize(k);
		inv_fac.resize(k);
		fac[0]=inv_fac[0]=1;
		for(int i=1;i<k;i++){
			fac[i]=fac[i-1]*i;
			inv_fac[i]=modpow(fac[i],MOD-2);
		}
	}
	static modint C(ll n,ll k,int type=0){
		if(k<0||k>n)return 0;
		if(type==0){
			return C_[n][k];
		}
		else {
			return fac[n]*inv_fac[k]*inv_fac[n-k];
		}
	}
};
template<int MOD> vector<modint<MOD>> modint<MOD>::inv_;
template<int MOD> vector<vector<modint<MOD>>> modint<MOD>:: C_;
template<int MOD> vector<modint<MOD>> modint<MOD>::fac;
template<int MOD> vector<modint<MOD>> modint<MOD>::inv_fac;

const int MOD=998244353;
typedef modint<MOD> mi;

int n;
int w[102];
mi dp[102][10002];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&w[i]);

	for(int i=0;i<102;i++)for(int j=0;j<10002;j++)dp[i][j]=0;
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=i;j>=0;j--)for(int k=0;k<10002;k++){
			if(k+w[i]<10002)dp[j+1][k+w[i]]+=dp[j][k];
		}
	}
	int sum=0;
	for(int i=0;i<n;i++)sum+=w[i];
	if(sum%2==1){
		puts("0");
		return 0;
	}
	mi::precalc_fac(102);
	mi ret=0;
	for(int i=1;i<=n;i++){
		ret+=dp[i][sum/2]*mi::fac[i]*mi::fac[n-i];
	}
	cout<<ret.val<<endl;
}