#include<iostream>
#include<bits/stdc++.h>
#define m_p make_pair
#define fi first
#define se second
#define pb push_back
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define   crap ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
using namespace std;
#define INF 1000000
#define vll vector<ll>
const int M = 1e9+7;
ll fastpower(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return fastpower((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*fastpower((x*x)%M,(n-1)/2,M))%M;
}
ll GCD(ll A, ll B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
bool vowl(char c)
{
  return c=='a'||c=='e'||c=='i'||c=='o'||c=='u';
}
ll modInverse(ll A,ll M)// when M is prime
{
    return fastpower(A,M-2,M);
}
void sieve(ll N) {
        bool isPrime[N+1];
        for(ll i = 0; i <= N;++i) {
            isPrime[i] = true;
        }
        isPrime[0] = false;
        isPrime[1] = false;
        for(ll i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {                    //Mark all the multiples of i as composite numbers
                 for(ll j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
vector<ll> factorize(ll n) {
    vector<ll> res;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

int main()
{
  crap;
  #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      #endif
           double a,b,p,q;
           cin>>a>>b>>p>>q;
           cout<<setprecision(12)<<(b*p+q*a)/(q+b)<<endl;
  return 0;
}

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

#define pb push_back

#define int ll
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

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

template<typename T, typename U>
ostream& operator<<(ostream& o, const map<T,U>& m) {
  o << "{";
  for (const pair<T,U>& p : m)
    o << p.first << ": " << p.second << ",";
  return o << "}";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (const T& x : v)
    o << x << ",";
  return o << "]";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T>>& v) {
  o << "[";
  for (const vector<T>& x : v)
    o << x << ",\n";
  return o << "]";
}

constexpr int MOD = 998244353;

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

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

    int sumc = (c+1)*c/2 % MOD;
    int sumb = (b+1)*b/2 % MOD;
    int suma = (a+1)*a/2 % MOD;
    int res = suma * sumb % MOD * sumc % MOD;
    cout << res << "\n";
}


#include <bits/stdc++.h>
#define int long long
#define float double
#define vi vector<int>
#define pb push_back
#define mod 1000000007
using namespace std;

// int N;
// char mat[1000][1000];
// int vis[1000][1000];
// int dist[1000][1000];
// int dx[]={-1,0,0,1};
// int dy[]={0,1,-1,0};

// bool isValid(int x, int y)
// {
//     if(x>=N || x<0 || y>=N || y<0 || vis[x][y]==1 || mat[x][y]=='T')
//      return false;

//     return true;
// }

// void bfs(int sx, int sy)
// {
//     queue<pair<int, int>>q;
//     q.push({sx,sy});
//     dist[sx][sy]=0;
//     vis[sx][sy]=1;

//     while(!q.empty())
//     {
//         int x=q.front().first;
//         int y=q.front().second;
//         q.pop();
//         for(int i=0;i<4;i++)
//         {
//           if(isValid(x+dx[i], y+dy[i]))
//           {
//               vis[x+dx[i]][y+dy[i]]=1;
//               q.push({x+dx[i],y+dy[i]});
//               dist[x+dx[i]][y+dy[i]]=dist[x][y]+1;
//           }
//         }
//     }
// }

// class Foo{
//     static int i;
//     public:
//       Foo()
//      {
//        cout<< ++i <<" ";
//      }

// };
// int Foo::i=0;

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

int fact[1000000];
int factorial(int n)
{
    fact[0] = 1;
    for (int i = 1; i <= n; i++) {
        fact[i] = (fact[i - 1] * i);
    }
   return fact[n];
}
bool isvowel(char ch)
{
    if(ch=='a' || ch=='e' || ch=='i' || ch=='u' || ch=='o')
    {
        return true;
    }
    return false;
}
int power(int x, int y)
{
    int temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}
int nCk(int n, int k)
{
  if(k>n-k)
   k=n-k;
  int ans=1;
  for(int i=0;i<k;i++)
  {
      ans*=(n-i);
      ans/=(i+1);
  }
  return ans;
}

vi factorization(int n)
{
    vi factors;
    //factors.pb(1);
    for(int d=2; d*d <= n; d++)
    {
        while(n%d==0)
        {
            factors.pb(d);
            n/=d;
        }
    }
    if(n>1)
     factors.pb(n);
    return factors;
}

vi divisors(int n)
{
    vi divisors;

    for(int i=2; i*i <= n; i++)
    {
        if( n%i == 0)
        {
            if(n/i == i)
             divisors.pb(i);
            else
            divisors.pb(i), divisors.pb(n/i);
        }
    }
    return divisors;
}

int sieve[1000001];
void SOE()
{
    sieve[0]=0;
    sieve[1]=0;
    for(int i=2;i<=1000000;i++)
    {
        if(sieve[i])
        {
            for(int j=2; j*i <1000000; j++)
             sieve[j*i]=0;
        }
    }
}

bool isPrime(int x)
{
    if(x==1) return 0;
    for(int i=2; i*i<=x; ++i)
    {
        if(x%i==0)
         return false;
    }
    return true;
}

int nthXor(int n, int a, int b)
{
    if (n == 0)
        return a;
    if (n == 1)
        return b;
    if (n == 2)
        return (a ^ b);

    return nthXor(n % 3, a, b);
}

void dfs(vi adj[], int src, bool visited[])
{
    visited[src]=true;
    for(auto it: adj[src])
    {
        if(visited[it]==false)
          dfs(adj, it, visited);
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
   //	cin >> t;
    while (t--)
    {
      int n; cin>>n;
      int temp = n;
      int digits=0, sum=0;
      map<int, int>mp;
      while(temp){
        mp[temp%10%3]++;
        sum += temp%10;
        temp/=10;
        digits++;
      }
      int ans;
      if(sum % 3 == 0)
       ans = 0;
      else if(sum % 3 == 1){
        if(mp[1]>0 and digits > 1){
            ans = 1;
        }
        else if(mp[2]>=2 and digits > 2){
            ans = 2;
        }
        else ans = -1;
      }
      else if(sum % 3 == 2){
          if(mp[2]>0 and digits > 1){
              ans = 1;
          }
          else if(mp[1] >=2 and digits > 2){
              ans = 2;
          }
          else ans = -1;
      }
      cout<<ans;
    }
}

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

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

	ll m = n;

	int s = 0;
	vector<int> c(3, 0);
	while (m != 0) {
		int d = m % 10;
		s += d;
		++c[d % 3];
		m /= 10;
	}

	int r = s % 3;

	if (r == 0) {
		cout << 0;
		return 0;
	}

	if (c[r] >= 1 && n > 9) {
		cout << 1;
		return 0;
	}

	if (c[3 - r] >= 2 && n > 99) {
		cout << 2;
		return 0;
	}

	cout << -1;

	return 0;
}


#include <iostream>
#include <math.h>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define memset(v, h) memset((v), h, sizeof(v))
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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(){
    ll n, k, m;
    cin >> n >> k >> m;
    ll a[n];
    ll p = 0;
    rep(i,n-1){
        cin >> a[i];
        p+=a[i];
    }
    ll x = m * n;
    ll g = x - p;
    if(g < 0)
    {
        cout << 0 << endl;
    }
    else if(g > k)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << g << endl;
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>

#define ll long long
using P = std::pair<int, int>;

int main()
{
    int N;
    std::string S;
    std::cin >> N >> S;

    int ans = 0;
    for(int i=0; i < N; i++) {
        int na=0, nt=0, nc=0, ng=0;
        for(int j=i; j < N; j++) {
            if(S[j] == 'A') na++;
            else if(S[j] == 'T') nt++;
            else if(S[j] == 'C') nc++;
            else ng++;
            if(na == nt and nc == ng) ans++;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
using db = double;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define V vector
#define P pair<int,int>
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define rev(i,s,n) for(int i=(s);i>=(int)(n);i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define cii(x) int x;cin >> x
#define cci(x,y) int x,y;cin >> x >> y
#define co(x) cout << x << endl
template<class T>void chmax(T &x,T y){x=max(x,y);}
template<class T>void chmin(T &x,T y){x=min(x,y);}

int main(){
  cii(n);
  ss s;ci(s);

  int ans=0;
  rep(l,0,n){
    map<char,int> mp;
  // int a,t,g,c;  a=t=g=c=0;
    mp[s[l]]++;
    rep(r,l+1,n){
      mp[s[r]]++;
      if(mp['A']==mp['T'] && mp['G']==mp['C'])ans++;
    }
  }

  co(ans);
}


#include<bits/stdc++.h>

using namespace std;

long long INF = 1000000000000;
std::vector<long long> AA;
std::vector<long long> visited;

bool comp(int a, int b) {
    return AA[a] < AA[b];
}

long long bfs(long long now, std::vector<long long> &A, vector<vector<long long>> &edges){
    long long m = -INF;
    queue<long long> q;
    q.push(now);
    while(!q.empty()){
        long long p = q.front();
        q.pop();
        int l = edges[p].size();
        for(int i = 0 ; i < l ; i++){
            if(visited[edges[p][i]] == false){
                visited[edges[p][i]] = true;
                q.push(edges[p][i]);
                m = max(m, A[edges[p][i]]);
            }
        }
    }
    return m;
}

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> X, std::vector<long long> Y){
    AA = A;
    vector<long long> index(N);
    for(int i = 0 ; i < N ; i++){
        index[i] = i;
    }
    sort(index.begin(), index.end(), comp);

    vector<vector<long long>> edges(N);
    for(int i = 0 ; i < M ; i++){
        edges[X[i] - 1].push_back(Y[i] - 1);
    }
    visited.resize(N);
    for(int i = 0 ; i < N ; i++){
        visited[i] = false;
        // cout<<index[i]<<" ";
    }
    // cout<<endl;
    long long max_profit = -INF;
    for(int i = 0 ; i < N ; i++){
        if(visited[index[i]] == false){
            // visited[index[i]] = true;
            long long m = bfs(index[i], A, edges);
            max_profit = max(max_profit, m - A[index[i]]);
        }
    }

    printf("%lld\n", max_profit);
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> X(M);
    std::vector<long long> Y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld %lld",&X[i], &Y[i]);
    }
    solve(N, M, std::move(A), std::move(X), std::move(Y));

    return 0;
}

#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(vr) vr.begin(),vr.end()
#define vi vector<int>
#define vll vector<ll>
const int N = 1e5 + 10;

vi G[N];
int vis[N];

void dfs(int u)
{
    vis[u] = 1;
    for (int v : G[u])
        if (!vis[v]) dfs(v);
}

int main()
{
    //freopen("ss.inp", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1, u, v; i <= m; ++i)
    {
        cin >> u >> v;
        G[u].eb(v);
    }
    int res = 0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j) vis[j] = 0;
        dfs(i);
        for (int j = 1; j <= n; ++j) res += vis[j];
    }
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#define st first
#define nd second
#define PQ priority_queue
#define MP make_pair

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;
const int N = 105;
const int MAXN = 1e5 + 10;
const int MOD = 0;
bool dp[MAXN];
int a[N];
int main(){
	int n, ma = 0, sum = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
		ma = max(ma, a[i]);
	}
	int half = sum / 2;
	if (ma >= half) {
		return !printf("%d", max(ma, sum - ma));
	}
	dp[0] = true, ma = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = half; j - a[i] >= 0; j--) {
			dp[j] = dp[j] || dp[j - a[i]];
			if (dp[j]) ma = max(ma, j);
		}
	}
	printf("%d", sum - ma);

}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    vi t(n);
    rep(i, n) {
        cin >> t[i];
    }
    vector<ll> cur(2e5, INF);
    cur[0] = 0;
    rep(i, n) {
        vl nxt(cur.size(), INF);
        rep(j, cur.size()) {
            chmin(nxt[j], cur[j] + t[i]);
            if(j + t[i] < cur.size()) chmin(nxt[j+t[i]], cur[j]);
        }
        swap(cur, nxt);
    }
    ll ans = INF;
    rep(i, cur.size()) {
        chmin(ans, max((ll)i, cur[i]));
    }
    cout << ans << endl;

    return 0;
}


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

#define DEBUG_ON

int main()
{
    ll n;
    cin>>n;
    vector<ll>a(n);
    vector<ll> _a(n);
    vector<ll> _b(n);
    vector<ll> b(n);
    rep(i,n){
        cin>>a.at(i)>>b.at(i);
        _a.at(i) = a.at(i);
        _b.at(i) = b.at(i);
    }

    ll min_ind_a;
    ll min_ind_b;
    ll min_a=10010101;
    ll min_b = 10010101;

    rep(i,n){
        if(min_a>a.at(i)){
            min_a=a.at(i);
            min_ind_a=i;
        }
        if (min_b> b.at(i))
        {
            min_b = b.at(i);
            min_ind_b = i;
        }
    }

    if(min_ind_a==min_ind_b){

        Sort(a);
        Sort(b);
        if (min_a + min_b < a.at(1) && min_a + min_b < b.at(1)){
            cout << min_a + min_b ;
            return 0;
        }
        if(a.at(0)>b.at(1)){
            cout<<a.at(0);
            return 0;
        }
        else if(b.at(0)>a.at(1)){
            cout<<b.at(0);
            return 0;
        }
            cout << min(a.at(1), b.at(1));
            return 0;
    }

    else{
        cout<<max(min_a,min_b);
        return 0;
    }

}

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

int main() {
  long long N;
  cin >> N;
  vector<long long> A(N),B(N);
  vector<vector<long long>> C(N,vector<long long> (N));
  for (long long i=0;i<N;i++) {
    cin >> A.at(i) >> B.at(i);
  }
  long long X=A.at(0)+B.at(0);
  for (long long i=0;i<N;i++) {
    for (long long j=0;j<N;j++) {
      if (i==j) {
        C.at(i).at(j)=A.at(i)+B.at(j);
      }
      if (i!=j) {
        C.at(i).at(j)=max(A.at(i),B.at(j));
      }
      if (X>C.at(i).at(j)) {
        X=C.at(i).at(j);
      }
    }
  }
  cout << X << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using iPair = pair<int,int>;
using lPair = pair<ll, ll>;
using ivector = vector<int>;
using lvector = vector<long>;
using ivv = vector<vector<int>>;
using lvv = vector<vector<ll>>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
#define dump(x) cout << #x << " = " << (x) << endl
#define ALL(x) begin(x),end(x)
#define rep(i,s,e) for(ll i=(s); i<(ll)(e); ++i)
#define repRev(i,s,e) for(ll i=(e-1); i>=(ll)(s); --i)
#define range(i,s,n) for(ll i=(s), i_stop=(s)+(n); i<i_stop; ++i)
#define rangeRev(i,s,n) for(ll i=(s), i_stop=(s)-(n); i>i_stop; --i)
#define foreach(x,container) for(auto &&x:container)
template<typename T> bool chmax(T& a, const T b) {if(a<b) {a=b;return true;} return false;}
template<typename T> bool chmin(T& a, const T b) {if(a>b) {a=b;return true;} return false;}
template<typename T> void printArr(vector<T> &arr){
    for(auto &x:arr) {cout << x << " ";} cout << endl;
}

/*
https://atcoder.jp/contests/abc202/tasks/abc202_e

## 關鍵詞：

## 題意：
一個由N <= 2e5個節點組成的樹。樹根爲頂點1。
給出以下Q <= 2e5個問題：
給定U_i, D_i，求所有深度爲D_i且到達根節點的最短路徑包含U_i的節點數量。

## 思路：
本來的思路：用一個集合記錄每個節點的最短路徑上的頂點，但這樣一定會超時……

https://atcoder.jp/contests/abc202/editorial/1864
用DFS從根節點遍歷整棵樹，同時記錄每個頂點進入和退出的順序，in_i和out_i。
「x到root最短路徑包含y」 a.k.a 「x是y的子孫」的充分必要條件是：
「in_y <= in_x <= out_x <= out_y」，實際上只需要關注in_x即可。
用一個數組按照深度保存節點，並且按照in的順序從小到大排序。
實際求數量只需做兩次二分。

## 感想：

*/

void solve(){
    int n;
    #define maxn 200005
    int in[maxn], out[maxn], depth[maxn]={0};
    ivector son[maxn];
    map<int,ivector> dvector; dvector[0] = {1};

    // 讀取
    cin>>n;
    range(i,2,n-1) {
        int p; cin>>p; son[p].push_back(i);
    }

    // dfs遍歷
    auto dfs = [&](auto self, int ith, int &cnt) -> void {
        in[ith] = cnt++;
        foreach(v,son[ith]) {
            depth[v] = depth[ith] + 1;
            dvector[depth[v]].push_back(v);
            self(self, v, cnt);
        }
        out[ith] = cnt++;
    };
    int cnt = 0;
    dfs(dfs, 1, cnt);

    // 對所有dvector[i]按照in的順序排序
    foreach(x,dvector) {
        auto [d,v] = x;
        sort(ALL(dvector[d]), [&](const int &a, const int &b) {
            return in[a] < in[b];
        });
    }

    // 在[l,r)範圍內，尋找是check成立的最小下標
    auto lower = [&](int l, int r, auto check) -> int {
        while(l<r) {
            int m = l + (r-l) / 2;
            if(!check(m)) l = m+1;
            else r = m;
        }
        return l;
    };

    // 在[l,r)範圍內，尋找是check不成立的最小下標
    auto upper = [&](int l, int r, auto check) -> int {
        while(l<r) {
            int m = l + (r-l) / 2;
            if(check(m)) l = m+1;
            else r = m;
        }
        return l;
    };

    int q; cin>>q;
    while(q--) {
        int u,d; cin>>u>>d;
        if(depth[u]>d) {cout<<0<<endl; continue;}

        // 在x \in dvector[d]當中，尋找所有滿足 in[u] <= in[x] <= out[u]的節點
        auto pl = lower(0, dvector[d].size(), [&](int ith) {
            return in[dvector[d][ith]] >= in[u];
        });
        auto pr = upper(0, dvector[d].size(), [&](int ith) {
            return in[dvector[d][ith]] <= out[u];
        });
        cout<<pr-pl<<endl;
    }
}

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

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

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

using ll = long long;

int main() {
    int n, m;
    std::cin >> n >> m;
    if (n == 1 && m == 0) {
        std::cout << 1 << ' ' << 2 << '\n';
        return 0;
    }
    if (m < 0 || m >= n-1) {
        std::cout << -1 << '\n';
        return 0;
    }
    for (int i=1; i<n-m; i++) {
        std::cout << i << ' ' << i + 100000000 << '\n';
    }
    int cur = n-m;
    for (int i=n-m; i<=n; i++) {
        std::cout << cur << ' ' << cur + 1 << '\n';
        cur += 2;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int maxN  = 1e6 + 10;
#define pb push_back

int a[maxN];
string s;
int n;
vector<int> v[maxN];
int bit[maxN];

void update(int x, int poz)
{
    for (int i = poz;i<maxN;i+=i&-i)
    	bit[i]+=x;

}

int get(int poz)
{
	int ans = 0;

	for (int i = poz;i>0;i-=i&-i)
		ans+=bit[i];

	return ans;
}
int main()
{
	cin>>n;

	for (int i = 1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]++;
	}

    long long ans = 0;

    for (int i = 1;i<=n;i++)
    {
       ans+=i - 1 - get(a[i]);
       update(1, a[i]);
    }

    int cur = 1;
    for (int i = 1;i<=n;i++)
    {
    	printf("%lld\n", ans);
        ans-=a[cur] - 1;
        ans+=n - a[cur];
        cur++;
    }

	return 0;
}

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

#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define mset(A,val) memset(A,val,sizeof(A))
#define fi(a,b) for(int i=a;i<=b;++i)
#define fj(a,b) for(int j=a;j<=b;++j)
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define pii pair<int,int>
#define DEBUG(a...) cout<<#a<<": ";for(auto &it:a)cout<<it<<" ";cout<<"\n";
#define debug(a)cout<<#a<<": "<<a<<"\n";
#define int long long

// ---------------------------------------------------------------------------
const int mod = 1e9+7;
const int maxn = 3e5 + 9;
vi BIT(maxn);
// ---------------------------------------------------------------------------
int sum(int i){
	int ans = 0;
	while(i>0){
		ans+=BIT[i];
		i-=(i&(-i));
	}
	return ans;
}
void update(int i,int x,int n){
	while(i<=n){
		BIT[i]+=x;
		i+=(i&(-i));
	}
}
// ---------------------------------------------------------------------------
void test_case(int tc)
{
	// cout<<"Case #"<<tc<<": ";
	int n;cin>>n;
	vector<int>arr(n+1);fi(1,n)cin>>arr[i],arr[i]++;
	int inversion = 0;
	for(int i=1;i<=n;++i){
		inversion+=(sum(n)-sum(arr[i]));
		update(arr[i],1,n);
	}
	cout<<inversion<<"\n";
	for(int i=1;i<n;++i){
		inversion+=(n-arr[i]);
		inversion-=(arr[i]-1);
		cout<<inversion<<"\n";
	}
}

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

	int t=1;
	//cin>>t;
	for(int tc=1;tc<=t;++tc)test_case(tc);
}


#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define deb(...)
#endif
#define endl "\n"
#define pb push_back
#define int long long
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define all(c) c.begin(),c.end()
#define read(v) for(auto &it:v) cin>>it;
const int inf = 1e18;
const int N   = 2e5 + 5;
const int mod = 1000000007;

void testCase() {
    int n;
    cin >> n;
    int ans = inf;
    for (int i = 0; i < 60; i++) {
        int zx = (1LL << i);
        ans = min(ans, n / zx + i + n % zx);
    }
    cout << ans << endl;

}

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

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

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

typedef long double ld;
typedef long long int ll;
typedef pair<int, int> pi;
typedef pair<long long, long long> pll;

#define ff first
#define ss second
#define pb push_back
#define int long long   // Make sure to use ll everywhere while commenting this, to avoid overflow
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

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

const int N = 3e5 + 5, mod = 1e9 + 7, bit = 62;

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

int getRand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

signed main()
{
	fast;

	int t = 1;
// 	cin >> t;
	f(tc, 1, t)
	{
		int n;
		cin >> n;
		int ans = llinf;
		for (int i = 0; i < bit; i++)
		{
			int val = (1LL << i);
			int c = n % val;
			int d = (n - c);
			if (d % val == 0)
			{
				ans = min(ans, i + c + (d / val));
			}
		}
		cout << ans << endl;
	}
	return 0;
}


//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
constexpr lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountll((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define rep2(i, l, r) for(int i = int(l); i < int(r); i++)
#define repr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define repr2(i, l, r) for(int i = int(r) - 1; i >= int(l); i--)
constexpr int inf9 = 1e9; constexpr lint inf18 = 1e18;
inline void Yes(bool condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
inline void YES(bool condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int x, y; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) cout << (i == start ? "" : " ") << (*i); if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint P(int n, int r){ if(r < 0 || n < r) return 0; return (fact[n] * inv[n - r] % mod); } lint C(int p, int q){ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }
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; }
inline int at(lint i, int j){ return (i >> j) & 1; }
random_device rnd;
bool is_in_board(lint y, lint x, lint H, lint W){ return (0 <= y && y < H && 0 <= x && x < W); }
lint inv2 = power(2, mod - 2, mod);

struct io_init {
    io_init() {
      cin.tie(nullptr); cout.tie(nullptr);
      std::ios::sync_with_stdio(false);
    }
} io_init;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep2(i, 3, s.size()){
        if(s.substr(i - 3, 4) == "ZONe"){
            ans++;
        }
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
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;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define repl(i, a, b) for(int i = a; i < int(b); i++)
#define rep(i, n) repl(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    string s;
    cin >> s;
    vector<int> cnt(10, 0);
    rep(i, s.size()) cnt[s[i] - '0']++;

    if(s.size() == 1) {
        ll num = stoll(s);
        if(num % 8 == 0) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
        return 0;
    } else if(s.size() == 2) {
        bool f = false;
        f = stoll(s) % 8 == 0;
        if(f) {
            cout << "Yes" << endl;
            return 0;
        }
        string t = s;
        reverse(ALL(t));
        f = stoll(t) % 8 == 0;
        cout << (f ? "Yes" : "No") << "\n";
        return 0;
    }

    for(int i = 111; i < 1000; i++) {
        {
            string t = to_string(i);
            bool f = true;
            for(char c : t)
                if(c == '0') f = 0;
            if(!f) continue;
        }
        if(i % 8 != 0) continue;
        string num = to_string(i);
        vector<int> a(10, 0);
        for(char c : num) a[c - '0']++;
        bool ok = true;
        rep(j, 10) if(a[j] > cnt[j]) ok = false;
        if(ok) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}


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

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

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

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

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

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

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

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

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

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

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

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

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) {
        cin >> a[i];
    }
    int cnt = min(n, 8);
    vector<vector<int>> v(200, vector<int>(0));
    for(int i=1;i<(1<<cnt);i++) {
        ll sum = 0;
        vector<int> cur;
        for(int j=0;j<cnt;j++) {
            if(i & (1<<j)) {
                cur.push_back(j + 1);
                sum += a[j];
                sum %= 200;
            }
        }
        if(v[sum].size() != 0) {
            cout << "Yes" << endl;
            cout << cur.size() << ' ';
            for(auto x : cur) cout << x << ' ';
            cout << endl;
            cout << v[sum].size() << ' ';
            for(auto x : v[sum]) cout << x  << ' ';
            cout << endl;
            return;
        }
        v[sum] = cur;
    }
    cout << "No" << endl;
}

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

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(i, v) for(auto& i : v)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    n = min(n, 10);
    rep(bit1, 1 << n) {
        vector<int> v1;
        rep(i, n) if(bit1 >> i & 1) v1.pb(i);
        rep(bit2, 1 << n) {
            vector<int> v2;
            rep(i, n) if(bit2 >> i & 1) v2.pb(i);
            if(v1.empty() || v2.empty() || v1 == v2) continue;
            ll num = 0;
            all(e, v1) num += a[e];
            all(e, v2) num -= a[e];
            if(num % 200 == 0) {
                cout << "Yes" << endl;
                cout << v1.size();
                all(e, v1) cout << " " << e + 1;
                cout << endl;
                cout << v2.size();
                all(e, v2) cout << " " << e + 1;
                cout << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
    ll N;
    cin >> N;
    set<ll> PP; // 10^10以下の累乗数
    for (ll i=2; i<=100000; i++) {
        for (int j=2; (ll)pow(i, j)<=(ll)pow(10, 10); j++) {
            PP.insert((ll)pow(i, j));
        }
    }
    ll res = 0;
    for (auto v: PP) {
        if (v<=N) res++;
    }
    cout << N-res << endl;
    return 0;
}

#include<iostream>
using namespace std;
int main()
{
	int i,num=0;
	char s[12];
	for(i=0;i<12;i++)
	{
		cin>>s[i];
	}
	for(i=3;i<12;i++)
	{
		if(s[i-3]=='Z'&&s[i-2]=='O'&&s[i-1]=='N'&&s[i]=='e')
			num++;
	}
	cout<<num;
	return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define pii pair<int,int>
#define m_p make_pair
#define pb push_back
#define ld long double
#define fi first
#define se second
#define ull unsigned long long
#define mod 1000000007
#define md 998244353
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define int long long
using namespace std;
inline void read(int &x){
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0'||c>'9'){
		if(c=='-')negative=-1;
		c=getchar();
	}
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
const int M=200010;
int n,m;
map<int,int>dp,tmp;
pair<int,int>p[M];
int ans=0;
bool in(int x){
	return x>=0&&x<=2*n;
}
signed main(){
	cin>>n>>m;
	rep(i,m){
		cin>>p[i].fi>>p[i].se;
	}
	sort(p,p+m);
	dp[n]=1;
	int last=-1;
	rep(i,m){
		int cur=p[i].se;
		if(p[i].fi!=last){
			last=p[i].fi;
			map<int,int>::iterator it;
			for(it=tmp.begin();it!=tmp.end();it++){
				dp[it->fi]=it->se;
			}
			tmp.clear();
		}
		if(in(cur)){
			if(dp[cur]==1)tmp[cur]=-1;
		}
		if(in(cur-1)){
			if(dp[cur-1]==1)tmp[cur]=1;
		}
		if(in(cur+1)){
			if(dp[cur+1]==1)tmp[cur]=1;
		}
	}
	map<int,int>::iterator it;
	for(it=tmp.begin();it!=tmp.end();it++){
		dp[it->fi]=it->se;
	}
	tmp.clear();
	for(it=dp.begin();it!=dp.end();it++){
		if(it->se==1)ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=4;
    vector<int> arr(n);
    int sum=0;
    for(int i=0;i<=n-1;i++)
    {
        cin >> arr[i];
        sum+=arr[i];
    }
    string ans="No";
    for(int i=0;i<=n-1;i++)
    {
        if(arr[i]==sum-arr[i])
        {
            ans="Yes";
        }
    }
    for(int i=0;i<=n-1;i++)
    {
        for(int j=i+1;j<=n-1;j++)
        {
            int g=arr[i]+arr[j];
            if(g==sum-g)
            {
                ans="Yes";
            }
        }
    }
    cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=5005,mod=998244353;
int h,w,k;
int dp[N][N];
char a[N][N];

int qpow(int x,int k) {
    int res=1;
    while(k) {
        if(k&1)res=1ll*res*x%mod;
        x=1ll*x*x%mod;
        k>>=1;
    }
    return res;
}
signed main() {
    scanf("%lld %lld %lld",&h,&w,&k);
    for(int i=1; i<=k; i++) {
        int x,y;
        char c;
        scanf("%lld %lld\n%c",&x,&y,&c);
        a[x][y]=c;
    }
    dp[1][1]=1;
    int inv=qpow(3,mod-2);
    for(int i=1; i<=h; i++)
        for(int j=1; j<=w; j++) {
            if(a[i][j]=='R'||a[i][j]=='X')
				dp[i][j+1]=(dp[i][j]+dp[i][j+1])%mod;
            if(a[i][j]=='D'||a[i][j]=='X')
				dp[i+1][j]=(dp[i][j]+dp[i+1][j])%mod;
            if(a[i][j]=='\0') {
                dp[i][j+1]=(dp[i][j]*2*inv%mod+dp[i][j+1])%mod;
                dp[i+1][j]=(dp[i][j]*2*inv%mod+dp[i+1][j])%mod;
            }
        }
    printf("%lld\n",qpow(3,h*w-k)*dp[h][w]%mod);
    return 0;
}

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<stdio.h>
#include<algorithm>
constexpr unsigned long long MOD = 998244353;
constexpr unsigned long long IM = 18479187003;
constexpr unsigned long long MOD32 = 665496236;

    char f[5000][5000];
    unsigned long long dp[5000];
int main(){
    int H=0, W=0, K=0;
    char c=getchar_unlocked();
    while(c<='9'&&c>='0') {H=(H<<1)+(H<<3)+c-'0'; c=getchar_unlocked();}
    c=getchar_unlocked();
    while(c<='9'&&c>='0') {W=(W<<1)+(W<<3)+c-'0'; c=getchar_unlocked();}
    c=getchar_unlocked();
    while(c<='9'&&c>='0') {K=(K<<1)+(K<<3)+c-'0'; c=getchar_unlocked();}

    unsigned long long y = H * W - K;
    while(--K>=0){
        int h=0, w=0;
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {h=(h<<1)+(h<<3)+c-'0'; c=getchar_unlocked();}
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {w=(w<<1)+(w<<3)+c-'0'; c=getchar_unlocked();}
        f[h-1][w-1] = getchar_unlocked();
        getchar_unlocked();
    }
    --H; --W;
    dp[0] = 1;
    for(int i = 0; i < H; ++i){
        for (int j = 0; j < W; ++j){
            switch(f[i][j]) {
                case 'R':
                    dp[j + 1] += dp[j];
                    dp[j] = 0;
                    break;
                case '\0':{
        dp[j] *= MOD32;
#ifdef _MSC_VER
        unsigned long long x;
        _umul128(dp[j], IM, &x);
#else
        unsigned long long x =
            (unsigned long long)(((unsigned __int128)(dp[j])*IM) >> 64);
#endif
        dp[j] +=  - x * MOD+MOD;
             }
                case 'X':
                    dp[j + 1] += dp[j];
            }
        }
            switch(f[i][W]) {
                case 'R':
                    dp[W] = 0;
                    break;
                case '\0':{
        dp[W] *= MOD32;
#ifdef _MSC_VER
        unsigned long long x;
        _umul128(dp[W], IM, &x);
#else
        unsigned long long x =
            (unsigned long long)(((unsigned __int128)(dp[W])*IM) >> 64);
#endif
       dp[W]+=  - x * MOD+MOD;
             }
            }
    }
    for (int j = 0; j < W; ++j){
        switch(f[H][j]) {
            case '\0':{
        dp[j] *= MOD32;
#ifdef _MSC_VER
        unsigned long long x;
        _umul128(dp[j], IM, &x);
#else
        unsigned long long x =
            (unsigned long long)(((unsigned __int128)(dp[j])*IM) >> 64);
#endif
        dp[j] +=  - x * MOD+MOD;
               }
            case 'R':
            case 'X':
                dp[j + 1] += dp[j];
        }
    }

    unsigned long long ans = dp[W];
    unsigned long long x = 3;
    while(y) {
      if(y & 1) {
        ans *= x;
#ifdef _MSC_VER
        unsigned long long x2;
        _umul128(ans, IM, &x2);
#else
        unsigned long long x2 =
            (unsigned long long)(((unsigned __int128)(ans)*IM) >> 64);
#endif
        ans +=  - x2 * MOD+MOD;
               }
      {
        x *= x;
#ifdef _MSC_VER
        unsigned long long x2;
        _umul128(x, IM, &x2);
#else
        unsigned long long x2 =
            (unsigned long long)(((unsigned __int128)(x)*IM) >> 64);
#endif
        x += - x2 * MOD + MOD;}
      y >>= 1;
    }
    printf("%d", ans % MOD);

    return 0;
}


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

#ifdef LOCAL
#include "debug.h"
#endif

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

#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define repi(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())

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

ll nxt() {
	ll x; cin >> x; return x;
}

void setIO(string s) {
	#ifndef LOCAL
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
	#endif
}

void yes() {
	cout << "Yes\n";
}

void no() {
	cout << "No\n";
}

const ll mod = 1e9 + 7;
const ll INF = 2e9;

void solve() {
	int n, s, d; cin >> n >> s >> d;
	rep(i, 0, n) {
		int x, y; cin >> x >> y;
		if (x < s && y > d) {
			yes();
			return;
		}
	}
	no();
}

int32_t main(){
	// setIO("trapped");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cout << fixed << setprecision(10);

	int T = 1;
	// cin >> T;

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

#include <bits/stdc++.h>
using namespace std;
int main(){
int n,s,d,c=0;
cin>>n>>s>>d;
for(int i=0;i<n;i++){
   int x,y;
    cin>>x>>y;
    if(x<s&&y>d){
    c+=1;
    }

}
if(c>0)cout<<"Yes";
else cout<<"No";
return 0;
}


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

// Consecutive additon/subtraction is bad
// if x < y /4 , then its optimal to

long long int do_brute(long long int x, long long int y){
  if(x == y)
    return 0;
  if(y%2 == 0){
    if(y >= 2*x)
      return 1 + do_brute(x,y/2);
    else
      return min(y-x,1+x-y/2);
  }
  else
    return 1 + min(do_brute(x,y+1),do_brute(x,y-1));
}

int main(){
  long long int x,y,oper = 0;
  cin>>x>>y;
  if(x >= y)
    cout<<x-y;
  else{
    while(4*x < y){
      if(y%2 == 0)
        y/=2;
      else if(y%4 == 1)
        --y;
      else
        ++y;

      ++oper;
    }

    oper += do_brute(x,y);
    cout<<oper;
  }
  return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define rep(i, m, n) for (int i = m; i <= n; i++)
#define per(i, m, n) for (int i = m; i >= n; i--)
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
using namespace std;

ll x, y;
unordered_map<ll, ll> M;

ll solve(ll num) {
    if (M.count(num)) return M[num];
    if (num == 1) return abs(x - num);
    if (num & 1) {
        return M[num] = min(min(abs(num - x), solve((num + 1) / 2) + 2), solve((num - 1) / 2) + 2);
    }
    return M[num] = min(abs(num - x), solve(num / 2) + 1);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> x >> y;
    cout << solve(y) << "\n";
    return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> h(n), w(m);
	rep(i, n) cin >> h[i];
	rep(i, m) cin >> w[i];
	sort(h.begin(), h.end());
	vector<int> l(n / 2 + 1), r(n / 2 + 1);
	for (int i = 0; i < n / 2; i++) l[i + 1] = l[i] + h[2 * i + 1] - h[2 * i];
	for (int i = n / 2; i > 0; i--) r[i - 1] = r[i] + h[2 * i] - h[2 * i - 1];
	int ans = 1e9;
	rep(i, m) {
		int itr = lower_bound(h.begin(), h.end(), w[i]) - h.begin();
		if (itr & 1) itr ^= 1;
		ans = min(ans, abs(w[i] - h[itr]) + l[itr / 2] + r[itr / 2]);
	}
	cout << ans << endl;
	return 0;
}

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

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

const int mod = 1e9 + 7;
const double pi = acos(-1.0);
const int inf = INT_MAX;

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

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

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

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

	vector<int> diff1(n), diff2(n);
	for (int i = 1; i < n; i += 2) {
		diff1[i] = a[i] - a[i - 1];
	}
	for (int i = 3; i < n; i += 2) {
		diff1[i] += diff1[i - 2];
	}

	for (int i = n - 2; i >= 0; i -= 2) {
		diff2[i] = a[i + 1] - a[i];
	}

	for (int i = n - 4; i >= 0; i -= 2) {
		diff2[i] += diff2[i + 2];
	}

	int ans = INT_MAX;
	for (int x : b) {
		int i = upper_bound(a.begin(), a.end(), x) - a.begin();

		if (i % 2 != 0) {
			i--;
		}
		int val1 = (i == 0 ? 0 : diff1[i - 1]);
		int val2 = abs(a[i] - x);
		int val3 = (i + 1 == n ? 0 : diff2[i + 1]);
		ans = min(ans, val1 + val2 + val3);
	}
	cout << ans << '\n';
	return 0;
}


#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 300005
#define MOD 1000000007
#define INF 1000000000000000000
#define EPS 0.0000000001
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int main()
{
    int n;
    //int p[]={2,3,5,7,11,13,17,19,23,29};
    scanf("%d",&n);
    /*long long x=1;
    int i;
    for(i=0;i<10&&p[i]<=n;i++)
    {
        int m=n;
        while(m>=p[i])
        {
            m=m/p[i];
            x=x*p[i];
        }
    }
    printf("%lld",x+1);*/
    printf("2329089562801");
    return 0;
}

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main(){
  ll n;
  cin>>n;
  ll x=2;
  for(ll y=3;y<=n;y++){
    x = lcm(x,y);
  }
  cout << x+1 << endl;
  return 0;
}


#pragma GCC optimize(2)
#include<unordered_map>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<set>
#define Buff ios::sync_with_stdio(false)
#define rush() int Case = 0; int T; cin >> T;  while(T--)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define per(i, a, b) for(int i = a; i >= b; i --)
#define reps(i, a, b) for(int i = a; b; i ++)
#define clc(a, b) memset(a, b, sizeof(a))
#define Buff ios::sync_with_stdio(false)
#define readl(a) scanf("%lld", &a)
#define readd(a) scanf("%lf", &a)
#define readc(a) scanf("%c", &a)
#define reads(a) scanf("%s", a)
#define read(a) scanf("%d", &a)
#define lowbit(n) (n&(-n))
#define pb push_back
#define lson rt<<1
#define rson rt<<1|1
#define ls lson, l, mid
#define rs rson, mid+1, r
#define y second
#define x first
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>PII;
const double eps = 1e-6;
const int INF = 1e9 + 7;
const int N = 2007;
const int M = 1e6 + 7;
const ll mod = 1e9 + 7;
ll dp[N][N];
ll sum[4][N][N];
char a[N][N];
signed main()
{
    Buff;
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            cin >> a[i][j];
    dp[1][1] = sum[1][1][1] = sum[2][1][1] = sum[3][1][1] = 1;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            if(a[i][j] == '#' || (i == j && j == 1))
                continue;
            else
            {
                dp[i][j] = (sum[1][i - 1][j] + sum[2][i][j - 1] + sum[3][i - 1][j - 1]) % mod;
                sum[1][i][j] = (sum[1][i - 1][j] + dp[i][j]) % mod;
                sum[2][i][j] = (sum[2][i][j - 1] + dp[i][j]) % mod;
                sum[3][i][j] = (sum[3][i - 1][j - 1] + dp[i][j]) % mod;
            }
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

constexpr int64_t MOD = 1000000007;
int64_t solve(int H, int W, const vector<string> & S) {
    vector<vector<int64_t>> count(H+1, vector<int64_t>(W+1));
    vector<vector<int64_t>> count_horizontal(H+1, vector<int64_t>(W+1));
    vector<vector<int64_t>> count_vertical(H+1, vector<int64_t>(W+1));
    vector<vector<int64_t>> count_diagonal(H+1, vector<int64_t>(W+1));

    // 初期値設定
    count.at(1).at(1) = 1;
    count_horizontal.at(1).at(1) = 1;
    count_vertical.at(1).at(1) = 1;
    count_diagonal.at(1).at(1) = 1;

    for (int y=1; y <= H; y++) {
        for (int x=1; x <= W; x++) {
            if (x == 1 and y == 1) {
                continue;
            }

            if (S.at(y-1).at(x-1) == '#') {
                count.at(y).at(x) = 0;
                count_horizontal.at(y).at(x) = 0;
                count_vertical.at(y).at(x) = 0;
                count_diagonal.at(y).at(x) = 0;
                continue;
            }

            int64_t count_h = count_horizontal.at(y).at(x-1);
            int64_t count_v = count_vertical.at(y-1).at(x);
            int64_t count_d = count_diagonal.at(y-1).at(x-1);
            int64_t sum_count = ((count_h + count_v) % MOD + count_d) % MOD;

            count.at(y).at(x) = sum_count;
            count_horizontal.at(y).at(x) = (sum_count + count_h) % MOD;
            count_vertical.at(y).at(x) = (sum_count + count_v) % MOD;
            count_diagonal.at(y).at(x) = (sum_count + count_d) % MOD;
        }
    }

    return count.at(H).at(W);
}

// generated by online-judge-template-generator v4.7.1 (https://github.com/online-judge-tools/template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    // failed to analyze input format
    // TODO: edit here
    int H;
    int W;
    cin >> H;
    cin >> W;
    vector<string> S(H);
    REP (i, H) {
        cin >> S.at(i);
    }
    auto ans = solve(H, W, S);
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define Rep(i,n) for(ll i=0;i<ll(n);i++)
#define Repd(i,n) for(ll i=n-1;i>=0;i--)
#define For(i,a,b) for(ll i=a;i<=ll(b);i++)
#define Ford(i,a,b) for(ll i=a;i>=ll(b);i--)
#define Fora(i,I) for(const auto& i:I)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;
const ll val = 0;
ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}

int main(void) {
    int ans,x,y,z;
    cin>>x>>y>>z;
    float takahashi = (float)y / x;
    ans = takahashi * z;
    if(takahashi*z == (float)ans) {
        --ans;
    }
    cout<<ans<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf (ll)2e18
#define mod 1000000007
//#define mod 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
const ll N=200005 ;
ll dp[N][7],n ;
string s,x ;
ll solve(ll id,ll rem)
{
	if(id==n)
	{
		if(rem==0) return 1;
		return 0 ;
	}
	else if(dp[id][rem]!=-1) return dp[id][rem] ;
	else
	{
		ll ans ;
		if(x[id]=='A')
		{
			ans=1 ;
			ans&=solve(id+1,(10*rem)%7) ;
			ans&=solve(id+1,(rem*10+s[id]-'0')%7) ;
		}
		else
		{
			ans=0 ;
			ans|=solve(id+1,(10*rem)%7) ;
			ans|=solve(id+1,(rem*10+s[id]-'0')%7) ;
		}
	    //cout<<id<<" "<<rem<<ans<<endl ;
		return dp[id][rem]=ans ;
	}
}
int main()
{
	fast ;
	cin>>n>>s>>x ;
	for(ll i=0;i<N;i++) for(ll j=0;j<7;j++) dp[i][j]=-1 ;

	if(solve(0,0)) cout<<"Takahashi" ;
	else cout<<"Aoki" ;

}


#include<bits/stdc++.h>
using namespace std;
    #define author          "Sihare0riginals"
    #define ss              string
    #define lli             long long int
    #define ld              long double
    #define f               first
    #define s               second
    #define all(v)          v.begin(),v.end()
    #define I(a,i)          memset(a,i,sizeof(a));
    #define pb              push_back
    #define mp              make_pair
    #define L(i,start,end)  for(lli i=start;i<=end;i++)
    #define R(i,start,end)  for(lli i=start;i>=end;i--)
    #define ip(n)           cin>>n;lli ip[n+1];L(i,1,n)cin>>ip[i];
const lli LINF = 1e18,mod=1e9+7;
void Bl0ck_M0mb0();

signed main()
{
    Bl0ck_M0mb0();
    lli t=1;
    //cin>>t;
    while(t--){
        ss s1;
        cin>>s1;
        lli n,l=0,cnt1=0,cnt2=0;
        n=s1.length();
        n--;
        while(n>=0&&s1[n]=='0')
        {
            n--;
            cnt1++;
        }
        while(l<s1.length()&&s1[l]=='0')
        {
            cnt2++;
            l++;
        }
        //cout<<l<<" "<<n<<" "<<cnt1<<" "<<cnt2<<endl;
        bool poss=true;
        while(l<=n)
        {
            if(s1[l]!=s1[n])
            {
                poss=false;
                break;
            }
            l++;
            n--;
        }
        if(poss&&cnt1>=cnt2)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}

void Bl0ck_M0mb0(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("ip.txt","r",stdin);
    freopen("op.txt","w",stdout);
    #endif
}
/*
#define dbg1D(i,start,end,arr) for(lli i=start;i<=end;i++) cout<<i<<"th : "<<arr[i]<<endl;
#define dbg2D(i,j,s1,e1,s2,e2,arr) for(lli i=s1;i<=e1;i++){cout<<i<<"th :";for(lli j=s2;j<=e2;j++)cout<<arr[i][j]<<" ";cout<<endl;}
#define M map<lli,lli> \n #define sz(s) s.size()-1
#define P pair<lli,lli>
#define V vector<lli>
lli dx[4]={-1, 0, 0, +1};
lli dy[4]={0, -1, +1, 0};
lli power(lli a,lli b,lli m){ if(b==0) return 1; if(b==1) return a%m;
    lli t=power(a,b/2,m); t=(t*t)%m; if(b&1) t=(t*a)%m; return t;}
lli modInverse(lli a, lli m) { return power(a, m-2, m); } */

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

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

const int N = 1e5 + 1;
int arr[N], n;

double fun(double x){
    double ans =0 ;
    for(int i =0 ; i < n;  i++){
        ans += (x + (double)(arr[i]) - min((double)(arr[i]), 2.0*x));
    }
    return ans;
}

void solve()
{
    cin>> n;
    int mn = 1e9;
    for(int i =0 ; i < n;i ++){
        cin>> arr[i];
        mn = min(arr[i], mn);
    }
    double l = (double(mn) / 2.0), r = 1e9, e = 1e-7;
    while(r - l >= e){
        double m1 = l + (r - l) / 3;
        double m2 = r - (r - l) / 3;
        double v1 = fun(m1);
        double v2 = fun(m2);
        if(v1 > v2){
            l = m1;
        }else{
            r = m2;
        }
    }
    double x = r;
    double ans = fun(x) / (double(n));
    cout<< ans << '\n';
}

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


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vc = vector<T>;
template<class T> using vvc = vc<vc<T>>;
template<class T> using vvvc = vc<vvc<T>>;
template<class T> using vvvvc = vvc<vvc<T>>;
template<class T> using PQ = priority_queue<T>;
template<class T> using invPQ = priority_queue<T, vector<T>, greater<T>>;
using IP = pair<int, int>;
using LP = pair<ll, ll>;
#define all(x) begin(x), end(x)
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
#define rep3(i, m, n) for (int i = (m); (i) < (int)(n); i++)
#define repr(i, n) for (int i = (n) - 1; (i) >= 0; i--)
#define rep3r(i, m, n) for (int i = (n) - 1; (i) >= (int)(m); 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; }

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

    int t, N;
    cin >> t >> N;

    auto isok = [&] (ll x) -> bool {
        if (x - (x+1)*100/(100+t) < N) return true;
        else return false;
    };

    ll ok = 0, ng = 1000000000000;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (isok(mid)) ok = mid;
        else ng = mid;
    }

    if ((ng+1)*100/(100+t) * (100+t)/100 == ng) cout << ok << endl;
    else cout << ng << endl;
}

#ifndef DEBUG
    #define NDEBUG
#endif
#include <bits/stdc++.h>
#define def(v) int &v = e[i].v
#define cls(a) memset (a, 0, sizeof (a))
#define mset(a, b) memset (a, b, sizeof (a))
#define go(i,e,u,...) for (int i = (u), ##__VA_ARGS__; i; i = e[i].nt)
#define fir(i,a,b,...) for (int i = (a), ##__VA_ARGS__; i <= (b); ++i)
#define firr(i,a,b,...) for (int i = (a), ##__VA_ARGS__; i >= (b); --i)
#ifdef DEBUG
    #define debug(format,...) (void)(fprintf (stderr, "debug in %d: " format "\n", __LINE__, ##__VA_ARGS__))
    #define dbug(x) (void)(std::cerr << #x " = " << (x) << std::endl)
#else
    #define debug(...) (void)0
    #define dbug(...) (void)0
#endif
typedef long long LL;
template<class T>
bool rei (T& x) {
    bool f = true;
    int ch;
    for (ch = getchar (); !isdigit (ch); ch = getchar ()) {
        if (ch == EOF) return false;
        f = ch != '-';
    }
    x = 0;
    if (f) do x = x * 10 + (ch & 15); while (isdigit (ch = getchar ()));
    else do x = x * 10 - (ch & 15); while (isdigit (ch = getchar ()));
    return true;
}
template<class T1, class T2> T1& cmax (T1& a, const T2& b) {return a < b ? a = b : a;}
template<class T1, class T2> T1& cmin (T1& a, const T2& b) {return a > b ? a = b : a;}
using namespace std;
signed main () {
    LL t, n; rei (t), rei (n);
    printf ("%lld\n", (100 * n + t - 1) / t + n - 1);
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define all(a) a.begin(), a.end()
#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
ll bp(ll a,ll b,int Mod=mod)
{
    ll res=1;
    a%=Mod;
    while(b>0)
    {
        if(b&1)
        res=(a*res)%Mod;
        a=(a*a)%Mod;
        b/=2;
    }
    return res;
}
main()
{
   IO
   int a,b;
   cin>>a>>b;
   if(b>a)
   { int su=0;
   	 for(int x=1;x<=b;x++)
   	   {cout<<-(x+10000)<<" ";su-=(x+10000);}
   	for(int x=1;x<=a-1;x++)
   	  {cout<<x<<" ";su+=x;}
    cout<<-su;
   }
   else
   {
   	int su=0;
   	 for(int x=1;x<=a;x++)
   	   {cout<<x+10000<<" ";su+=(x+10000);}
   	for(int x=1;x<=b-1;x++)
   	  {cout<<-x<<" ";su-=x;}
    cout<<-su;
   }
}

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define int long long
#include <map>
#include <queue>
#include <set>
int fact[200001];  //https://atcoder.jp/contests/dp/tasks/dp_t
int inv[200001];
int de[200001];
ll mod=1000000007;
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
bool digits[49];
int low,high;
int n,k,totalcost;
int w[100100],v[100100];
int a[100100];
int prefix[100100];
int count1;
int ans;
//int a[3][3];
int connected;
string s1,s2;
bool isprime(ll x) {
    //return a[x];
	/*for(ll i = 2; i * i <= x; i++) {
		if(x % i == 0)
			return false;
	}
	return true;*/
}
void print(vector<int> sum)
{
    cout<<"vector is \n";
    for(int i=0;i<sum.size();i++)
    {
        cout<<sum[i]<<" ";
    }
    cout<<endl;
}

void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(21-(a+b+c))<<"\n";
}

signed main(){
    ios_base::sync_with_stdio(false);
    cout.tie(0);cin.tie(0);
    //cout.precision(10);
    ll _t=1;
    //cin>>_t;
    while(_t--)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;
typedef long double ld;

const ll inf = 1e18;
const ll mod = 1e9+7;

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

    ll L=0,R=2e9;

    while(R-L>1){
        ll m=(R+L)/2;
        if(m*(m+1)/2<=n+1)L=m;
        else R=m;
    }

    cout<<n-L+1<<endl;
}

#include<cstdio>
#define lli long long
lli n,a;
int main()
{
	scanf("%lld",&n),++n,a=n;
	for(register int i=1;;++i)
		if(n<i)return printf("%lld",a),0;
		else n-=i,--a;
	printf("%lld",a);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double lf;
typedef long double Lf;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;
const int maxk = 305;
const int INF = 998244353;

class Number{
public:
	int dat;
	Number(){}
	Number(int dat_): dat(dat_){}
	inline Number&operator += (const Number &oth){ (dat += oth.dat) -= (dat >= INF ? INF : 0); return *this; }
	inline Number&operator -= (const Number &oth){ (dat -= oth.dat) += (dat < 0 ? INF : 0); return *this; }
	inline Number&operator *= (const Number &oth){ dat = 1ll * dat * oth.dat % INF; return *this; }
	inline Number operator + (const Number &oth)const{ Number ret = *this; ret += oth; return ret; }
	inline Number operator - (const Number &oth)const{ Number ret = *this; ret -= oth; return ret; }
	inline Number operator * (const Number &oth)const{ Number ret = *this; ret *= oth; return ret; }
}a[maxn], binom[maxk][maxk], pw[2][maxn], s[maxk];

const Number inv2 = (INF + 1) / 2;

int n, k;

inline void precalc(){
	int p = 0, q = 1;
	REP(i, 0, k){
		binom[i][0] = 1;
		REP(j, 1, i)
			binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
		FOR(j, 0, n){
			pw[q][j] = (!i ? 1 : pw[p][j] * a[j]);
			s[i] += pw[q][j];
		}
		swap(p, q);
	}
	return;
}

int main(){
	scanf("%d%d", &n, &k);
	FOR(i, 0, n)
		scanf("%d", &a[i].dat);

	precalc();

	REP(x, 1, k){
		Number ans = 0;
		REP(i, 0, x){
			Number res = s[i] * s[x - i] - s[x];
			ans += res * binom[x][i];
		}
		printf("%d\n", (ans * inv2).dat);
	}
	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); ++i)

ll INF = 1ll << 60;

int main(){
    ll n, q;
    cin >> n >> q;
    vl a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    vector<pll> k(q);
    rep(i, 0, q){
        ll t;
        cin >> t;
        k[i] = {t, i};
    }
    sort(k.begin(), k.end());

    vl ans(q);
    int id = 0;
    rep(i, 0, q){
        ll t = k[i].first;
        if(id == 0){
            if(a[0]-1 >= t){
                ans[k[i].second] = t;
                continue;
            }
        }
        while(id < n-1 && a[id+1]-(id+2) < t){
            id++;
        }
        ans[k[i].second] = t+id+1;
    }

    rep(i, 0, q){
        cout << ans[i] << endl;
    }

    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(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    ll x = a[0];
    set<ll>st;
    rep(i,n)st.insert(a[i]);
    ll X = *st.rbegin();
    while(X!=x){
        st.erase(X);
        ll nx = X-x;
        st.insert(nx);
        X = *st.rbegin();
        chmin(x,nx);
    }
    cout << X << endl;
    return 0;
}

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define all(x) (x).begin(), (x).end()
typedef long long ll;

using namespace std;
//srand (time(NULL));
//rand()%10 //random 1-9
int arr[200005] = {0};
//queue<pair<int,int> pq;
//bool done = false;
//bool vis[105][105] = {0};
//int memo[105][105] = {0};
//vector<int> v;
//pair<int,int> arr;
int mov[2][4] = {{1 ,-1, 0, 0},
				 {0 , 0, 1,-1}};

int MOD = 1e9+7;

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

void solve()
{
	int n,tmpgcd;
	cin >> n;
	cin >> tmpgcd;
	for(int i=2;i<=n;i++)
	{
		int tmp;
		cin >> tmp;
		tmpgcd = gcd(tmpgcd,tmp);
	}
	cout << tmpgcd << endl;
}

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


#include<iostream>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	if(n%2 == 1){
      cout<<"Black\n";
    }
  	else{
      cout<<"White\n";
    }
  	return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

bool poss(string s, int x) {
    int len = s.size();
    if(to_string(x).size() > len)
        return false;
    vector<int> cnt(10, 0);
    for(char c : s) {
        int d = c - '0';
        cnt[d] ++;
    }
    vector<int> need(10, 0);
    for(int i = 0; i < min(len, 3); ++i) {
        need[x % 10]++;
        x /= 10;
    }
    for(int i = 0; i < 10; ++i)
        if(cnt[i] < need[i])
            return false;
    return true;
}

int main() {
    string s;
    cin >> s;
    for(int x = 8; x < 1000; x += 8) {
        if(poss(s, x)) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


#include <bits/stdc++.h>

using namespace std;

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

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

	while (!(n % 10)) n /= 10;

	vector<int> f, b;
	while (n) {
		f.emplace_back (n % 10);
		n /= 10;
	}

	b = f;
	reverse (b.begin(), b.end());

	if (b == f) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

#include<bits/stdc++.h>

using namespace std;

bool palindromeasis(string s,int low,int high)
{
    int flag=1;
    while(low<=high)
    {
        if(s[low]==s[high])
        {
            low++;
            high--;
        }
        else
        {
            flag=0;
            break;
        }
    }
    if(flag==0)
        return false;
    return true;
}

bool palindrome(string s)
{
    if(palindromeasis(s,0,s.length()-1))
        return true;

    int j=s.length()-1;
    while(s[j]=='0')
        j--;

    if(j<s.length() && palindromeasis(s,0,j))
        return true;

    return false;
}

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

        if(palindrome(s))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int,int> pii;

int N, M;
const int MOD = 998244353;
const int D = 20;
int f[200010][D + 1];
int fac[200010], ifac[200010];
vector<int> dv[200010];

int quick_pow(int a,int x) {
    int ret = 1;
    while(x) {
        if (x & 1) ret = 1LL * ret * a % MOD;
        a = 1LL * a * a % MOD;
        x >>= 1;
    }
    return ret;
}

int C(int n, int k) {
    if (k > n || k < 0) return 0;
    return 1LL * fac[n] * ifac[k] % MOD * ifac[n - k] % MOD;
}

int main() {
    fac[0] = ifac[0] = 1;
    for (int i=1;i<=200000;i++) {
        fac[i] = 1LL * fac[i - 1] * i % MOD;
        ifac[i] = quick_pow(fac[i], MOD - 2);
    }
    scanf("%d%d",&N,&M);
    for (int i=1;i<=M;i++) {
        for (int j=i*2;j<=M;j+=i) {
            dv[j].push_back(i);
        }
    }
    for (int i=1;i<=M;i++) {
        f[i][1] = 1;
        for (auto d: dv[i]) {
            for (int j=2;j<=D;j++) {
                f[i][j] = (f[i][j] + f[d][j - 1]) % MOD;
            }
        }
    }
    int ans = 0;
    for (int i=1;i<=M;i++) {
        for (int j=1;j<=D;j++) {
            ans = (ans + 1LL * C(N - 1, j - 1) * f[i][j] % MOD) % MOD;
        }
    }
    printf("%d\n",ans);
}

//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>w(n);
  rep(i,0,n)cin>>w[i];
  ll mxw=*max_element(ALL(w));
  vector<P>p(m);
  rep(i,0,m){
    cin>>p[i].se>>p[i].fi;
    if(p[i].fi<mxw){
      cout<<-1<<endl;
      return 0;
    }
  }
  //荷重、長さ
  //p.EB(INF,INF);
  p.EB(0,0);
  sort(ALL(p));
  rep(i,0,(ll)p.size()-1){
    chmax(p[i+1].se,p[i].se);
  }
  //debug(p,p.size());
  vector<ll>v(n);
  iota(ALL(v),0);
  res=INF;
  do{
    vector<ll>pos(n);
    rep(i,1,n){
      ll nw=w[v[i]];
      ll mx=0;
      rrep(j,0,i){
        nw+=w[v[j]];
        P q=*(--lower_bound(ALL(p),MP(nw,0LL)));
        chmax(mx,q.se-(pos[i-1]-pos[j]));
      }
      pos[i]=pos[i-1]+mx;
    }
    /*if(is_sorted(ALL(v))){
      debug(v,3);debug(pos,3);cout<<endl;
    }*/
    chmin(res,pos[n-1]);
  }while(next_permutation(ALL(v)));
  cout<<res<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define pb push_back
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define int long long
#define Mod 1000000007
#define maxn 200005
#define MAX 4294967296  // 2^32
const int M=1e9+7;
#define ip pair<int,int>
#define test(t) ll t;cin>>t;while(t--)

using namespace std;

long long gcd(int x,int y){
    if(y>x)swap(x,y);
    if(y==0)return x;
    return gcd(y,x%y);
}
int power(int x,int y){
if(y==0)return 1;
int t=1;
int ans=1;
while(y!=0){
    if(y%2)ans=(ans%Mod*x%Mod)%Mod;
x=(x%Mod*x%Mod)%Mod;

y/=2;
}

return ans;
}
int prime[100005]={0};
vector<int>v;

int a[1001][3];
void solve(){
 int n,m,k;
 cin>>n>>m>>k;
 n-=m;
 n+=k;
 cout<<n;

}

signed main(){

    // std::string binary = std::bitset<8>(n).to_string();
    ios::sync_with_stdio(0);
    cin.tie(0);

{solve();}

}

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

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b

using namespace std;

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

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    vector<pair<int,int>> p;
    rep(i,0,n){
        int x,y;
        cin>>x>>y;
        p.pb({x,y});
    }
    int ans = 0;
    rep(i,0,p.size()){
        rep(j,i+1,p.size()){
            int x = p[j].ft - p[i].ft;
            int y = p[j].sd - p[i].sd;
            x = abs(x);
            y = abs(y);
            if ( y <= x ){
                ans++;
            }
        }
    }

    cout<<ans<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main()
{
    int N,X,i;
    char S[200005];
    scanf("%d%d",&N,&X);
    scanf("%s",S);
    for(i=0;S[i]!='\0';i++){
        if(S[i]=='x'){
            if(X==0)X=0;
            else --X;
        }
        if(S[i]=='o')++X;
    }
    printf("%d",X);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    string S; cin >> S;
    int ans = 0;
    for(int i=0; i<=9999; i++){
        vector<bool> flag(10);
        int X = i;
        for(int j=0; j<4; j++){
            flag[X%10] = true;
            X /= 10;
        }
        bool flag2 = true;
        for(int j=0; j<10; j++){
            if(S[j]=='o' && !flag[j]) flag2 = false;
            if(S[j]=='x' && flag[j]) flag2 = false;
        }
        ans += flag2;
    }
    cout << ans << endl;
}


//W4P3R
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define re register int
#define fr first
#define sd second
#define pa pair<int,int>
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define MEM(a) memset(a,0,sizeof(a))
#define N 200010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
inline int lowbit(int x){return x&(-x);}
int n,m,k;
const int mod=998244353;
inline int ksm(int a,int b)
{
	int ans=1;
	while(b){if(b&1)ans=1LL*ans*a%mod;b>>=1;a=1LL*a*a%mod;}
	return ans;
}
inline int Z(int x){return (x>=mod?x-mod:x);}
int main()
{
	//ios::sync_with_stdio(false);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=read(),k=read();
	if(n>m)swap(n,m);int ans=0;
	if(n==1)
	{
		swap(n,m);
		FOR(x,1,k)
		{
			int v=1LL*(x-1)*ksm(x,mod-2)%mod,s=1LL*Z(1+mod-ksm(v,n))%mod*ksm(Z(1+mod-v),mod-2)%mod;
			s=1LL*s*ksm(x,n-1)%mod;
		//	cout<<"WTF:"<<x<<" "<<s<<endl;
			ans=Z(ans+s);
		}
		cout<<ans<<'\n';return 0;
	}
	FOR(x,1,k)
	{
		int v=1LL*(x-1)*ksm(x,mod-2)%mod,s=1LL*Z(1+mod-ksm(v,n))%mod*ksm(Z(1+mod-v),mod-2)%mod;
		s=1LL*s*ksm(x,n-1)%mod;
		//cout<<"WTF:"<<x<<" "<<s<<endl;
		ans=Z(ans+1LL*s*ksm(k-x+1,m)%mod);
	}
	cout<<ans<<'\n';
	return 0;
}
//gl

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void*wmem;
char memarr[96000000];
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
  sort(a, a+N);
}
template<class T1> void rsortA_L(int N, T1 a[], void *mem = wmem){
  sortA_L(N, a, mem);
  reverse(a, a+N);
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
long long A[100000];
long long B[100000];
int os;
int es;
long long o[100000];
long long e[100000];
int main(){
  int i;
  wmem = memarr;
  long long res;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int e98WHCEY;
    for(e98WHCEY=(0);e98WHCEY<(N);e98WHCEY++){
      rd(B[e98WHCEY]);
    }
  }
  {
    int FmcKpFmN;
    long long xr20shxY;
    if(N==0){
      xr20shxY = 0;
    }
    else{
      xr20shxY = A[0];
      for(FmcKpFmN=(1);FmcKpFmN<(N);FmcKpFmN++){
        xr20shxY += A[FmcKpFmN];
      }
    }
    res =xr20shxY;
  }
  for(i=(0);i<(N);i+=(2)){
    o[os++] = B[i] - A[i];
  }
  for(i=(1);i<(N);i+=(2)){
    e[es++] = B[i] - A[i];
  }
  rsortA_L(os, o);
  rsortA_L(es, e);
  for(i=(0);i<(os);i++){
    res +=max_L(o[i]+e[i], 0);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20201018-2

// --- original code ---
// int N;
// ll A[1d5], B[1d5];
// int os, es;
// ll o[1d5], e[1d5];
// {
//   ll res;
//   rd(N,A(N),B(N));
//
//   res = sum(A(N));
//   rep(i,0,N,2) o[os++] = B[i] - A[i];
//   rep(i,1,N,2) e[es++] = B[i] - A[i];
//   rsortA(os, o);
//   rsortA(es, e);
//   rep(i,os) res += max(o[i]+e[i], 0);
//
//   wt(res);
// }


/**
 *  created: 18/04/2021, 15:08:05
**/

#include <bits/stdc++.h>

using namespace std;

const int max_n = 100111, mod = 1000000007;

int n, a[max_n], ans = 1;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    ++n;
    sort(a, a + n);
    for (int i = 1; i < n; ++i) {
        ans = 1LL * ans * (a[i] - a[i - 1] + 1) % mod;
    }
    printf("%d\n", ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define pa pair<long long, int>

const int mod = 998244353, i2 = mod + 1 >> 1;
int n, a[200010];
long long pow2[200010], inv2[200010], ans = 0;
vector<pa> s;

int main()
{
    scanf("%d", &n);
    pow2[0] =inv2[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        pow2[i] = (pow2[i - 1] << 1) % mod;
        inv2[i] = inv2[i - 1] * i2 % mod;
    }
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n);
    s.push_back({a[1], 1});
    for (int i = 2; i <= n; i++)
        if (a[i] == a[i - 1])
            s.back().second++;
        else
            s.push_back({a[i], 1});
    long long now = 0;
    int num = 0;
    for (int i = 0; i < s.size(); i++)
    {
        (ans += s[i].first * s[i].first % mod * (pow2[s[i].second] - 1) % mod) %= mod;
        (ans += s[i].first * (pow2[s[i].second] - 1) % mod * pow2[num] % mod * now % mod) %= mod;
        num += s[i].second;
        (now += s[i].first * (pow2[s[i].second] - 1) % mod * inv2[num] % mod) %= mod;
    }
    printf("%lld\n", ans);
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d",&N);
  int A[N];
  int sum = 0;
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
    if(A[i]>10){
      sum += A[i]-10;
    }
  }
  printf("%d",sum);

  return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque>
#include <string>

using namespace std;

int n;
int a[100010];
set<int> numSet;

int main()
{
	scanf("%d", &n);
	for (int i = 0 ; i < n ; i++) {
		scanf("%d", &(a[i]));
		numSet.insert(a[i]);
	}

	set<int>::iterator iBegin;
	set<int>::reverse_iterator iLast;

	while (numSet.size() > 1) {
		iBegin = numSet.begin();
		iLast = numSet.rbegin();
		int minNum = *iBegin;
		int maxNum = *iLast;

		numSet.erase(maxNum);
//		printf("%d\n", maxNum);
		maxNum = maxNum % minNum;
		if (maxNum == 0)
			maxNum = minNum;
		numSet.insert(maxNum);
	}

	iBegin = numSet.begin();
	int lastNum = *iBegin;

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


#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
inline int read() {
	int x=0,f=1;char c=getchar();
	while(c<48||c>57){if(c=='-')f=-1;c=getchar();}
	while(c>=48&&c<=57)x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
using namespace std;
char s[105][105];
int main() {
	int n=read(),m=read(),x=read(),y=read();
	rep(i,1,n)scanf("%s",s[i]+1);
	int ly=y;while(ly>=1&&s[x][ly]!='#')ly--;
	int ry=y;while(ry<=m&&s[x][ry]!='#')ry++;
	int lx=x;while(lx>=1&&s[lx][y]!='#')lx--;
	int rx=x;while(rx<=n&&s[rx][y]!='#')rx++;
	printf("%d\n",rx-lx+ry-ly-3);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define pqueue priority_queue
#define umap unordered_map
#define uset unordered_set
#define bits(x) __builtin_popcount((x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x) / gcd(x, y) * (y))
#define inf 4557430888798830399LL
#define mst(dp, val) memset(dp, val, sizeof(dp))
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repd(i, a, b, d) for (int i = a; i <= b; i += d)
#define rep_(i, a, b) for (int i = a; i >= b; --i)
#define repd_(i, a, b) for (int i = a; i >= b; i -= d)
#define mxm(a, b) a = max(a, b)
#define mnm(a, b) a = min(a, b)
#define L size()
#define pb push_back
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << "=" << x << endl
#define readArr(a, n) for (int i = 1; i <= n; i++) cin >> a[i];
#define printArr(a, n) for (int i = 1; i <= n; i++) cout << a[i] << " "; cout << endl;
#define mod 1000000007
#define Add(x, d) x = (x + (d)) % mod
#define print(e) cout << (e) << endl
// #define MULTI_CASES
// #define PRE
const int N = 2e5 + 5;
// int a[N];

void solve() {
    int A, B, C;
    cin >> A >> B >> C;
    C = C % 2 ? 1 : 2;
    int a = pow(A, C), b = pow(B, C);
    if (A == B || a == b) print("=");
    if (a > b) print(">");
    if (a < b) print("<");
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    #ifdef MULTI_CASES
        #ifdef PRE
            pre();
        #endif
        int t; cin >> t;
        while (t--) solve();
    #else
        solve();
    #endif
    return 0;
}


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

    int main()
    {
        int n,m;
        cin >> n >> m;
        if(m%n==0)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }

#include <math.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define max(p, q) ((p) > (q) ? (p) : (q))
#define min(p, q) ((p) < (q) ? (p) : (q))
#define mod
using ll = long long;
using P = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T> >;
const ll INF = 1e18 + 1;
ll f(ll a, ll n, ll p)
{
  if (n == 0)
    return 1;
  if (n == 1)
    return a % p;
  if (n % 2 == 1)
  {
    ll x = f(a, (n - 1) / 2, p);
    return a * x * x % p;
  }
  ll y = f(a, n / 2, p);
  return y * y % p;
}
int main()
{
  ll n, m;
  cin >> n >> m;
  ll ans = f(10, n, m * m);
  ans /= m;
  cout << ans % m << endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll inf=INF*INF;
const ll mod=998244353;
const ll MAX=140010;

template< class T >
struct BIT
{
  vector< T > data;

  BIT(int sz)
  {
    data.assign(++sz, 0);
  }

  T sum(int k)
  {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x)
  {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

signed main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    BIT<ll>bit(n+1);
    ll ans=0;
    rep(i,n){
        ans+=bit.sum(n)-bit.sum(a[i]);
        bit.add(a[i],1);
    }
    rep(i,n){
        cout<<ans<<endl;
        ans+=n-1-a[i];
        ans-=a[i];
    }
}

#include "bits/stdc++.h"
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ll int
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}
template<typename T, typename U> static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;}
const int N = 2e5 + 10;
vi adj[N];

vi lvl[N];
int in[N];
int out[N];
int cnt = 0;
int L[N];

void dfs(int v,int l = 0){
    in[v] = ++cnt;
    // trace(v,cnt);
    lvl[l].pb(cnt);
    L[v] = l;

    for(auto i: adj[v]){
        dfs(i, l + 1);
    }
    out[v] = cnt;
}
int solve(){
    int n;
    cin >> n;
    for(int i = 2; i <= n; i++){
        int x;
        cin >> x;
        adj[x].pb(i);
    }
    dfs(1);

    // return 0;
    int q;
    cin >> q;
    while(q--){
        int u, d;
        cin >> u >> d;
        // d -= L[u];
        int ans = upper_bound(all(lvl[d]), out[u]) - lower_bound(all(lvl[d]), in[u]);
        cout << ans << endl;

    }

    return 0;
}
signed main(){
    asdf
    // freopen("inputf.in", "w", stdout);

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


#include<bits/stdc++.h>
using namespace std;
#define il inline
#define rg register
il int read()
{
	int re=0,k=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')k=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){re=re*10+ch-48;ch=getchar();}
	return re*k;
}
il void write(int x)
{
	if(x<0) return putchar('-'),write(-x),void();
	if(x<10)return putchar(x+48),void();
	return write(x/10),putchar(x%10+48),void();
}
int col[200005],l,n,m;
int fa[200005],head[200005],tot;
int find(int x)
{
	if(x==fa[x])return x;
	return fa[x]=find(fa[x]);
}
struct ss{
	int node,nxt,w;
}e[400005];
void add(int u,int v,int w)
{
	e[++tot].nxt=head[u];
	head[u]=tot;
	e[tot].node=v;
	e[tot].w=w;
}

void dfs(int x,int fa,int c)
{
//	cerr<<x
	col[x]=c;
	for(rg int i=head[x];i;i=e[i].nxt)
	{
		int y=e[i].node;
		if(y==fa)continue;
		if(c==e[i].w)
		{
			dfs(y,x,c%n+1);
		}
		else
		{
			dfs(y,x,e[i].w);
		}
	}
}
signed main()
{
	n=read();m=read();
	for(rg int i=1;i<=n;i++)
		fa[i]=i;
	for(rg int i=1,a,b,c;i<=m;i++)
	{
		a=read();b=read();c=read();
		int x=find(a);
		int y=find(b);
		if(x==y)continue;
		fa[x]=y;
		add(a,b,c);
		add(b,a,c);
	}

	dfs(1,0,1);
	for(rg int i=1;i<=n;i++)
		write(col[i]),puts("");
}

#include <bits/stdc++.h>

using namespace std;

typedef long long i64;
typedef unsigned long long ui64;
typedef vector<i64> vi;
typedef vector<vi> vvi;
typedef pair<i64, i64> pi;

#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)
inline void RI(i64 &i) {scanf("%lld", &(i));}
inline void RVI(vi &v) { for(i64 i=0;i<sz(v);++i) { RI(v[i]); } }
inline void RVVI(vvi &vv) { for(i64 i=0;i<sz(vv);++i) { RVI(vv[i]); } }
inline void WI(const i64 &i) {printf("%lld\n", i);}
inline void WVI(const vi &v, char sep=' ') { for(i64 i=0;i<sz(v);++i) { if(i != 0){ printf("%c", sep); } printf("%lld", v[i]);} printf("\n"); }
inline void WS(const string &s) { printf("%s\n", s.c_str()); }
inline void WB(bool b, const string &yes, const string &no) { if(b){ WS(yes);} else { WS(no);} }
inline void YESNO(bool b) { WB(b, "YES", "NO"); }
#define BUF_LENGTH 1000000
inline void RS(string &s) {static char buf[BUF_LENGTH]; scanf("%s", buf); s = buf;}
template<typename T> inline bool IN(T &S, const typename T::key_type &key) {
  return S.find(key) != S.end();
}

struct BIT {
    // definition
    using size_type = long long; // must be signed
    using value_type = int;
    static value_type plus(value_type a, value_type b) {
        return a + b;
    }
    const value_type identity = 0;

    BIT(size_type N) : tree(N+1, identity) {
    }

    void add(size_type i, value_type x) {
        ++i; // convert to 1-based
        while(i < tree.size()) {
            tree[i] += x;
            i += i & (-i);
        }
    }

    value_type sum0(size_type i) {
        // open boundary in 0-based index = close boundary in 1-based index
        value_type ans = identity;
        while(i > 0) {
            ans += tree[i];
            i -= i & (-i);
        }
        return ans;
    }

    value_type sum(size_type l, size_type r) {
        return sum0(r) - sum0(l);
    }

    vector<value_type> tree;
};

int main(int argc, char *argv[]) {
  i64 i, j, k;
  i64 N; RI(N);
  vi a(N); RVI(a);

  BIT tree(N);
  i64 T = 0;
  REP(0, N, i) {
    T += tree.sum(a[i], N);
    tree.add(a[i], 1);
  }

  i64 T0 = T;
  REP(0, N, i) {
    cout << T << endl;
    T -= a[i];
    T += (N - 1 - a[i]);
  }
  assert(T == T0);

  return 0;
}