#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

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

// Function to return the sum of arr[0..index]
// This function assumes that the array is preprocessed
// and partial sums of array elements are stored in BITree[]
int getSum(int BITree[], int index)
{
    int sum = 0; // Initialize result

    // Traverse ancestors of BITree[index]
    while (index > 0) {
        // Add current element of BITree to sum
        sum += BITree[index];

        // Move index to parent node in getSum View
        index -= index & (-index);
    }
    return sum;
}

// Updates a node in Binary Index Tree (BITree) at given index
// in BITree. The given value 'val' is added to BITree[i] and
// all of its ancestors in tree.
void updateBIT(int BITree[], int n, int index, int val)
{
    // Traverse all ancestors and add 'val'
    while (index <= n) {

        // Add 'val' to current node of BI Tree
        BITree[index] += val;

        // Update index to that of parent in update View
        index += index & (-index);
    }
}

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

int main() {

	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int n; cin>>n;
    vi a(n);
    forn(i,n) cin>>a[i];
    // vi s;
    int BIT[n + 1];
    for (int i = 1; i <= n; i++)
        BIT[i] = 0;

    vi suff(n,0);
    // s.pb(a[n-1]);
    ll ans = 0;

    for (int i = n - 1; i >= 0; i--) {

        // Get count of elements smaller than arr[i]
        suff[i] = getSum(BIT, a[i]);
        ans += suff[i];
        // Add current element to BIT
        updateBIT(BIT, n, a[i]+1, 1);
    }

    // for(int i=n-2;i>=0;i--)
    // {
    //     auto it = lower_bound(all(s),a[i]);
    //     int h = it - s.begin();
    //     suff[i] = h;
    //     // it--;
    //     ans += h;
    //     s.insert(it,a[i]);
    //     // for(auto it:s) cout<<it<<':'; cout<<endl;
    // }
    // forn(i,n) cout<<suff[i]<<' ';
    cout<<ans<<'\n';
    int sz = 0;
    forn(i,n-1)
    {
        // auto it = lower_bound(all(s),a[i]);
        int h = a[i] - suff[i];
        ans += (n-1-i-2*suff[i]);
        ans -= h;
        ans += (sz-h);
        // s.insert(it,a[i]);
        sz++;
        // for(auto it:s) cout<<it<<':'; cout<<endl;
        cout<<ans<<'\n';
    }

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
ostream& operator<<(ostream&o,const pair<auto,auto>&p){return o<<"<"<<p.first<<", "<<p.second<<">";}
ostream& operator<<(ostream&o,const vector<auto>&v){o<<'[';int f=0;for(auto&x:v)(f?o<<", ":o)<<x,f=1;return o<<']';}
#ifdef BIZON
    #define rr(...) [](const auto&...x){ char c='='; cerr << boolalpha << "\e[1;38;5;68m" << #__VA_ARGS__ << " "; ((cerr<<"\e[0;38;5;61m"<<exchange(c,',')<<"\e[0m "<<x),...); cerr<<endl; }(__VA_ARGS__);
#else
    #define rr(...) 0;
    #define endl '\n'
#endif
#define ALL(c) begin(c), end(c)
#define II(...) __VA_ARGS__; [](auto&...x){(cin>>...>>x);}(__VA_ARGS__);
#define ii(...) int II(__VA_ARGS__)
inline bool umin(auto&x, const auto&y){ return y<x && (x=y, 1); }
inline bool umax(auto&x, const auto&y){ return y>x && (x=y, 1); }
using ll = long long;

int main(){
    if(auto f="in.txt"; fopen(f,"r") && freopen(f,"r",stdin));
    ios::sync_with_stdio(0);cin.tie(0);

    ii(n)
    vector<int> a(n);
    for(auto &_ : a) cin>>_;

    vector<ll> s(n+1);
    vector<map<ll,int>> m(2);
    m[n%2][0] = 1;
    ll ans = 0;
    for(int i=n-1;i>=0;--i){
        s[i] = a[i] - s[i+1];

        ans+= m[i%2][s[i]];
        ans+= m[1-i%2][-s[i]];

        ++m[i%2][s[i]];
    }

    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,a,b;
	double x;
	scanf("%d %d",&a,&b);
	x=1.0*b*a/100;
	printf("%f\n",x);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define fr(a, b, c) for (int a = b; a <= c; a++)
#define rep(a, b, c) for (int a = b; a < c; a++)
#define db cout << "db: "
#define trav(a, x) for (auto &a : x)
#define all(con) con.begin(), con.end()
#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define int long long
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int mod = 1000000007;

void solve()
{
   int A , B ;
   cin>>A>>B ;
   float ans ;
   ans = (A*B/100.00) ;
   cout<<ans<<endl ;
}

signed main()
{
    boost;
    // cout << fixed << setprecision(10);
    int start = 1;
    fr(i, 1, start) solve();

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[2005];

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    ll mn = INF;
    REP(i, N) {
        mn = std::min(mn, A[i]);
    }
    std::map<ll, ll> mp;
    REP(i, N) {
        ll n = 1;
        while (n * n <= A[i] && n <= mn) {
            if (A[i] % n == 0) {
                {
                    auto it = mp.find(n);
                    if (it == mp.end()) {
                        mp[n] = A[i];
                    }
                    else {
                        it->second = gcd(it->second, A[i]);
                    }
                }
                ll x = A[i] / n;
                if (x <= mn) {
                    auto it = mp.find(x);
                    if (it == mp.end()) {
                        mp[x] = A[i];
                    }
                    else {
                        it->second = gcd(it->second, A[i]);
                    }
                }
            }
            n++;
        }
    }
    ll ans = 0;
    for (auto &p : mp) {
        if (p.first == p.second)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

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

map<int, int> mp;
void add(int a, int b)
{
	if (!mp.count(a)) mp[a] = b;
	else mp[a] = __gcd(mp[a], b);
}

int main()
{
	int n; scanf("%d", &n);
	vector<int> a(n);
	for (auto &x: a) scanf("%d", &x);
	sort(a.begin(), a.end());

	for (auto x: a)
	{
		for (ll j = 1; j * j <= x; j++)
		{
			if (x % j) continue;
			add(j, x);
			add(x / j, x);
		}
	}

	int mi = a[0], ans = 0;
	for (auto x: mp)
	{
		if (x.first > mi) break;
		if (x.first == x.second) ans++;
	}
	printf("%d\n", ans);

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  char S, T;
  cin >> S >> T;
  if(S == 'N') {
    cout << T << endl;
  }
  else {
    if(T == 'a') {
      cout << "A" << endl;
    }
    else if(T == 'b') {
      cout << "B" << endl;
    }
    else {
      cout << "C" << endl;
    }
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(long i=0; i<(long)(n);i++)
#define REP(i,s,t) for(long i=s; i<t; i++)
#define RNG(i,s,t,u) for(long i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  char s,t;
  cin >> s >> t;
  if(s == 'Y'){
    if(t == 'a') cout << "A" << endl;
    else if(t == 'b') cout << "B" << endl;
    else cout << "C" << endl;
  }
  else cout << t << endl;
  //cout << 'A'-'a' << endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    double  gx,gy,sx,sy;
    cin>>sx>>sy>>gx>>gy;
    double res=(sy*gx+sx*gy)/(sy+gy);
    cout<<setprecision(10)<<res<<endl;
}

#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
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 (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#define ynmes(a) (a) ? mes("Yes") : mes("No")
#define YNmes(a) (a) ? mes("YES") : mes("NO")
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{
     double sx, sy, gx, gy,  ssy = 0,x=0;
    cin >> sx >> sy >> gx >> gy;
    if(sy>0)
    {
        ssy = sy * (-1);
       // debug(ssy);
    }else
    {
        ssy = sy;
        //debug(ssy);
    }
    x = (gx - sx) * ssy * (-1) / (gy - ssy) + sx;
    printf("%lf", x);
}


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

#define rep2(i,k,n) for(i64 i=(i64)(k);i<(i64)(n);i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) begin(x),end(x)
#ifdef ENV_LOCAL
#define dump if (1) cerr
#else
#define dump if (0) cerr
#endif

using namespace std;
using namespace std::string_literals;
//using namespace harudake;

using i32 = int32_t;
using i64 = int64_t;
using f64 = double;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;

// ax+by=gcd(a,b)
// |x|+|y| -> min
// x <= y
i64 extgcd(i64 a, i64 b, i64& x, i64& y) {
  i64 g = a; x = 1; y = 0;
  if (b) g = extgcd(b, a%b, y, x), y -= (a / b) * x;
  return g;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 t;
  cin>>t;
  while(t--) {
    i64 x,y,p,q;
    cin>>x>>y>>p>>q;
    x += y;
    p += q;
    i64 x2 = x*2;
    i64 a,b;
    i64 g = extgcd(x2, p, a, b);
    b *= -1;
    dump<<g<<" "<<a<<" "<<b<<endl;
    i64 INF = 8e18;
    i64 ans = INF;
    rep2(y1,1,y+1) {
      rep2(q1,1,q+1) {
        i64 y2 = y1 + x;
        i64 yq = y2 - q1;
        if (yq % g != 0) continue;
        i64 scale = yq / g;
        i64 lcm = x2 * p / g;
        i64 pg = p / g;
        i64 a1 = a % pg * scale % pg;
        i64 t = (a1 * x2 + lcm - y2) % lcm;
        dump<<y2<<" "<<q1<<" "<<t<<endl;
        if (t < 0) {
          t = (lcm + t % lcm) % lcm;
        } else {
          t %= lcm;
        }
        ans = min(ans, t);
      }
    }
    if (ans < INF) {
      cout<<ans<<"\n";
    } else {
      cout<<"infinity"<<endl;
    }
  }
  return 0;
}

#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli __int128
#define ldouble long double
using namespace std;

/*
(2x + 2y)n + x <= t < (2x + 2y)n + x + y
  range = y (max 500)
(p + q)n + p <= t < (p + q)(n + 1)
  range = q (max 500)

try all combinations of mod (500^2)

t - (2x + 2y)n - x == remY
t - (2x + 2y)n = remY + x
t = remY + x + (2x + 2y)n1

t - (p + q)n - p == remQ
t - (p + q)n = remQ + p
t = remQ + p + (p + q)n2

remQ + p + (p + q)n2 = remY + x + (2x + 2y)n1
(p + q)n2 - (2x + 2y)n1 = remY + x - remQ - p

*/

lli read() {
    lli x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
void print(lli x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

lli abslol(lli num)
{
  return num < 0 ? -num : num;
}

lli gcd(lli a, lli b, lli& x, lli& y)
{
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  lli x1, y1;
  lli d = gcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - y1 * (a / b);
  return d;
}

bool find_any_solution(lli a, lli b, lli c, lli &x0, lli &y0, lli &g)
{
  g = gcd(abslol(a), abslol(b), x0, y0);
  if (c % g) {
    return false;
  }

  x0 *= c / g;
  y0 *= c / g;
  if (a < 0) x0 = -x0;
  if (b < 0) y0 = -y0;
  return true;
}

const lli inf = LONG_LONG_MAX;
lli x, y, p, q;

lli findMinSolution(lli remY, lli remQ)
{
  // t - (2x + 2y)n - x == remY
  // t - (2x + 2y)n = remY + x
  // t = remY + x + (2x + 2y)x0

  // t - (p + q)n - p == remQ
  // t - (p + q)n = remQ + p
  // t = remQ + p + (p + q)y0

  // remQ + p + (p + q)y0 = remY + x + (2x + 2y)x0
  // -(2x + 2y)x0 + (p + q)y0 = remY + x - remQ - p
  lli x0, y0, g;
  lli a = -(2*x + 2*y), b = p + q, c = remY + x - remQ - p;
  if (find_any_solution(a, b, c, x0, y0, g))
  {
    lli t1 = remY + x + (2*x + 2*y)*x0, t2 = remQ + p + (p + q)*y0;
    bool isNegative = a / g < 0;

    // lli lo = 0, hi = 1e18;
    // while (lo < hi)
    // {
    //   lli mid = (lo + hi + 1) >> 1;
    //   if ((y0 + mid*(a / g)) != 0 && LONG_LONG_MAX / abslol(y0 + mid*(a / g)) < (p + q))
    //     hi = mid - 1;
    //   else
    //     lo = mid;
    // }
    // lli maxHi = lo;

    // lo = -1e18, hi = 0;
    // while (lo < hi)
    // {
    //   lli mid = (lo + hi) >> 1;
    //   if ((y0 + mid*(a / g)) != 0 && LONG_LONG_MAX / abslol(y0 + mid*(a / g)) < (p + q))
    //     lo = mid + 1;
    //   else
    //     hi = mid;
    // }
    // lli minLo = lo;

    lli lo = -1e18, hi = 1e18;
    while (lo < hi)
    {
      lli mid = (lo + hi + isNegative) >> 1;
      lli e = remQ + p + (p + q)*(y0 + mid*(a / g));

      // DEBUG printf("\t\t%lld %lld\n", mid, e);
      if (isNegative)
      {
        if (e >= 0) lo = mid;
        else hi = mid - 1;
      }
      else
      {
        if (e >= 0) hi = mid;
        else lo = mid + 1;
      }
    }

    x0 -= lo * b / g;
    y0 += lo * a / g;

    // DEBUG printf("\t%lld %lld - %lld %lld | %lld %lld\n", remY, remQ, t1, t2, 0LL, b / g);
    return remQ + p + (p + q)*y0;
  }
  else
    return inf;
}

int main()
{
  int t; scanf("%d", &t);
  for (int tt = 1; tt <= t; tt++)
  {
    // scanf("%lld %lld %lld %lld", &x, &y, &p, &q);
    x = read();
    y = read();
    p = read();
    q = read();
    lli ans = inf;
    for (int i = 0; i < y; i++)
      for (int j = 0; j < q; j++)
        ans = min(ans, findMinSolution(i, j));

    if (ans == inf) printf("infinity\n");
    else
    {
      print(ans);
      printf("\n");
    }
  }

  return 0;
}


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

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

if (c%2==0){
    a = abs(a);
    b = abs(b);
}

if ( a < b ){
    cout << "<" << endl;
} else if ( a > b ){
    cout << ">" << endl;
} else {cout << "=" << endl;}

return 0;
}

#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define eb emplace_back
#define mk make_pair
using namespace std;
void vec(vector<int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
void vec_ll(vector<long long int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
void vec_ull(vector<ull> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
int parsestring(string temp){
    int num= 0;
    int digs = temp.size() - 1;
    for(int i = 0 ;i<=digs;i++){
        num += pow(10 , digs -i)*(temp[i] - '0');
    }
    return num;
}

ll divs(int a){
  int ans = 0;
  for(int i = 1;i<=int(pow(a , 0.5)) ; i++){
    if(a%i == 0){
      if(a /i == i){ans++;}
      else{ans += 2;}
    }
  }
  return ans;
}

ll divs_num(ll a){
  ll ans = 0;
  for(int i = 1;i<=int(pow(a ,0.5)) ;i++){
    if(a % i == 0){
      if(a/i == i){ans++;}
      else{ans+=2;}
    }
  }
  return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b,c;
    cin>>a>>b>>c;
    if(c %2 == 0){

        if(abs(a) > abs(b)){cout<<'>'<<endl;}
        else if(abs(a) == abs(b)){cout<<'='<<endl;}
        else{cout<<'<'<<endl;}

    }
    else{
      if((a >=0 && b >=0)){
        if(abs(a) > abs(b)){cout<<'>'<<endl;}
        else if(abs(a) == abs(b)){cout<<'='<<endl;}
        else{cout<<'<'<<endl;}
      }
      else if(a< 0 && b < 0){
        if(abs(a) > abs(b)){cout<<'<'<<endl;}
        else if(abs(a) == abs(b)){cout<<'='<<endl;}
        else{cout<<'>'<<endl;}
      }
      else{
        if(a<0){
          cout<<'<'<<endl;
        }
        else if(b < 0){
          cout<<'>'<<endl;
        }
      }
    }
  }


#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define ll long long
#define rep(i,n) for(int i = 0;i < (int)n;i ++)
#define mod % 1000000007
using namespace std;

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n+1,0);
  vector<ll> s(n+1,0);
  rep(i,n)cin >> a[i];
  rep(i,n)s[i+1] = a[i]+s[i];
  vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
  ll ans = 0;
  dp[0][0] = 1;
  rep(i,n){
    vector<ll> Q(i+1,0);
    ll S = 0;
    rep(j,n+1){
      dp[i+1][j] = Q[S] mod;
      Q[S] = (Q[S] + dp[i][j]) mod;
      S = (S+a[j])%(i+1);
    }
  }
  rep(i,n+1){
    ans = (ans+dp[i][n]) mod;
  }
  cout << ans << endl;
  return 0;
}

/******************************
Author: jhnah917(Justice_Hui)
g++ -std=c++17 -DLOCAL
******************************/

#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
#define IDX(v, x) (lower_bound(all(v), x) - v.begin())
using namespace std;

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
constexpr ll MOD = 1e9+7;

ll N, A[3030], S[3030][3030];
int D[3030][3030];
vector<int> G[3030][3030];

void Add(int &a, int b){
    a += b; if(a >= MOD) a -= MOD;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N;
    for(int i=1; i<=N; i++) cin >> A[i];
    for(int i=1; i<=N; i++){
        partial_sum(A+1, A+N+1, S[i]+1);
        for(int j=1; j<=N; j++) S[i][j] %= i;
        for(int j=1; j<=N; j++) G[i][S[i][j]].push_back(j);
    }
    for(int i=1; i<=N; i++) D[1][i] = 1;
    for(int i=1; i<=N; i++){
        for(int j=1; j<=N; j++){
            if(!D[i][j]) continue;
            auto &vec = G[i+1][S[i+1][j]];
            for(auto it=upper_bound(all(vec), j); it!=vec.end(); ++it) Add(D[i+1][*it], D[i][j]);
        }
    }
    ll ans = 0;
    for(int i=1; i<=N; i++) ans += D[i][N];
    cout << ans % MOD;
}


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

int main(){
	string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < s.size()-3; i++) {
    if (s.at(i) == 'Z'){
    	if (s.at(i+1) =='O'){
        	if (s.at(i+2) =='N'){
        		if (s.at(i+3) =='e'){
        			count++;
     		    }
	        }
        }
    }
    }
	cout << count <<endl;

}

//                        YATIN KWATRA

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

#define ll                      long long
#define ar                      array
#define sz(v)                   (int)(v.size())
#define inf                     1e18
#define int                     ll
#define FIO                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ld                      long double
#define ull                     unsigned long long
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define pq                      priority_queue
#define uomii                   unordered_map<int,int,best_hash>
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795
#define cz(x)                   63 - __builtin_clzll(x)

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct best_hash {
	static uint64_t splitmix64(uint64_t x) {

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

void INPUT()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

/*
----------------------------------------------------------------
   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
----------------------------------------------------------------
*/

void solve()
{
	string s;
	cin >> s;
	int n = sz(s);
	int ans = 0;
	fo(i, 3, n - 1) {
		if (s.substr(i - 3, 4) == "ZONe") ans++;
	}
	cout << ans;
}

signed main() {

	FIO
	INPUT();

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


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mo 1000000007
#define ll long long
#define maxn 1005
using namespace std;

int n,i,j,k,f[2][2];
ll ans;

ll ksm(ll x,ll y){
	ll s=1;
	for(;y;y/=2,x=x*x%mo) if (y&1)
		s=s*x%mo;
	return s;
}

void reverse(){
	static int g[2][2];
	for(i=0;i<2;i++) for(j=0;j<2;j++)
		g[i^1][j^1]=f[j][i]^1;
	memcpy(f,g,sizeof(f));
}

void doit1(){
	static int f[maxn][2];
	f[1][0]=1;
	for(i=2;i<=n-1;i++){
		f[i][0]=(f[i-1][0]+f[i-1][1])%mo;
		f[i][1]=f[i-1][0];
	}
	printf("%d\n",f[n-1][0]);
}

int main(){
	scanf("%d",&n); char ch=getchar();
	for(i=0;i<2;i++) for(j=0;j<2;j++){
		while (ch!='A'&&ch!='B') ch=getchar();
		f[i][j]=ch-'A',ch=getchar();
	}
	if (f[0][1]==1) reverse();
	if (n==2||f[0][0]==0) printf("1"); else
	if (f[1][0]==0) doit1(); else
		printf("%lld\n",ksm(2,n-3));
}

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repl(i,l,r) for(int i=l;i<r;i++)
#define rrepl(i,l,r) for(int i=r-1;i>=l;i--)
const int inf=1e9+10;
const ll INF=2e18+10;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

const ll MOD=1e9+7;

int main(){
    int l;cin>>l;
    ll b;
    set<int> s;
    for(int i=2;i<12;i++)s.insert(i);
    b=1;
    for(int i=l-11;i<l;i++){
        b*=i;
        for(int j=2;j<12;j++){
            if(s.find(j)==s.end())continue;
            if(b%j==0){
                b/=j;
                s.erase(j);
            }
        }
    }
    cout<<b<<endl;
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<int> A(N,0);
  vector<int> B(N,0);

  for(int i=0;i<N;i++){
  	cin>>A.at(i);
  }
   for(int i=0;i<N;i++){
  	cin>>B.at(i);
  }
  int sum=0;

  for(int k=1;k<1001;k++){
  	for(int i=0;i<N;i++){
      if(k<A.at(i)||B.at(i)<k)
        break;
   	  else if(i==N-1&&k>=A.at(i)&&k<=B.at(i))
        sum++;
  }
  }
 cout<<sum<<endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	ll res = 0;
	map<ll, int> a;
	ll s = 0;
	++ a[0];
	for (int i = 0; i < N; ++ i) {
		if (i % 2) {
			s += A[i];
			res += a[s];
			++ a[s];
		} else {
			s -= A[i];
			res += a[s];
			++ a[s];
		}
	}
	cout << res << endl;
}


#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const long double phi = 0.618033988749894848204586834365;

vector<int> calc(long long x, long long y) {
	vector<int> a;
	while (x > 0 || y > 0) {
		if (a.size() > 130) {
			break;
		}
		if (x == 0) {
			a.push_back(2);
			y -= 1;
			continue;
		}

		if (y == 0) {
			a.push_back(1);
			x -= 1;
			continue;
		}

		if (x > y) {
			a.push_back(3);
			x -= y;
			continue;
		}

		a.push_back(4);
		y -= x;
	}

	reverse(a.begin(), a.end());
	return a;
}

int main() {
	long long x;
	scanf("%lld", &x);
	long double yd = x * phi;
	long long y = (long long)(yd);
	if (yd - (long long)(yd) >= 0.5) {
		y = (long long)(yd) + 1;
	}

	vector<int> a;
	for (int i = -10000; i <= 10000; ++i) {
		if (y + i < 0) {
			continue;
		}

		a = calc(x, y + i);
		if (a.size() <= 130) {
			break;
		}
	}

	printf("%d\n", a.size());
	for (int i = 0; i < a.size(); ++i) {
		printf("%d\n", a[i]);
	}
	return 0;
}

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

using namespace std;
//using namespace atcoder;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

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

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

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

ull rnd(void) {
    static ull y = 2463534242;
    y = y ^ (y << 13);
    y = y ^ (y >> 17);
    return y = y ^ (y << 5);
}

// edit
ll LIM = 130;

int rec(ll x, ll y) {
    if (x == 0 && y == 0) {
        return 0;
    }
    if (x == y) {
        return x + y;
    }
    if (x == 0) {
        return y;
    }
    if (y == 0) {
        return x;
    }
    if (x > y) {
//        return 1 + rec(x - y, y);
        if (x / y > LIM) return INF;
        return 1 + rec(x - y, y);
    }
    if (x < y) {
        if (y / x > LIM) return INF;
        return 1 + rec(x, y - x);
    }

    return INF;
}

void solver(ll x, ll y, vector<int> &O) {
    if (x == y) {
        if (x == 0) return;
        REP(i, x) {
            O.push_back(1);
        }
        REP(i, y) {
            O.push_back(2);
        }
    }
    if (x == 0) {
        REP(i, y) {
            O.push_back(2);
        }
    }
    if (y == 0) {
        REP(i, x) {
            O.push_back(1);
        }
    }
    if (x > y) {
        O.push_back(3);
        solver(x - y, y, O);
    }
    if (x < y) {
        O.push_back(4);
        solver(x, y - x, O);
    }
}

void solve() {
//    ll N = 100;
//    REP(i, N) {
//        cout << i << " " << rec(N, i) << endl;
//    }
    ll N;
    cin >> N;
    if (N == 1) {
        cout << 1 << endl;
        cout << 1 << endl;
        return;
    }
    ll y;
    while (true) {
        y = rnd() % (N - 1) + 1;
        ll val = rec(N, y);
        if (val <= LIM) {
//            cout << val << endl;
            break;
        } else {
//            cerr << y << " " << val << endl;
        }
    }

    vector<int> ans;
    solver(N, y, ans);
    assert(ans.size() <= LIM);
    reverse(ALL(ans));

    cout << ans.size() << endl;
    for (auto e : ans) {
        cout << e << endl;
    }

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();

    return 0;
}


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

using ll = long long;

int main(){
    ll t;cin >> t;
    while(t--){
        ll L, R;cin >> L >> R;
        if(2 * L > R){
            cout<<0<<endl;
        }else{
            cout<<(R - 2 * L + 2) * ((R - 2 * L) + 1) / 2<<endl;
        }
    }
    return 0;
}

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

int  main()
{
	int n; cin >> n;
	vector<P> v(n);
	rep(i, n)
		cin >> v[i].first >> v[i].second;
	int ans = 0;
	for(int i = 0 ; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			double x, y;
			x = v[i].first - v[j].first;
			y = v[i].second - v[j].second;
			if ((y / x) >= -1 && (y / x) <= 1)
				ans++;
		}
	}
	cout << ans << endl;
	return (0);
}


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

using namespace std;
#define rep(i,n) for(long long int i=0;i<(n);i++)
typedef long long ll;
typedef pair<int, int> P;

int gcd(int a, int b) {
    if (a % b == 0) {
        return b;
    }
    else {
        return gcd(b, a % b);
    }
}
ll lcm(int a, int b) {
    ll res = (ll)a * b / gcd(a, b);
    return res;
}
int main() {
    long long int n;
    cin >> n;
    int rank=0;
    long long int ans = 0;
    long long int tmp = 1;
    for (long long int i = 1; i<=n; i *= 10) {
        rank++;
        rep(i, (ll)rank - 2) {
            tmp *= 10;
        }
        ans += (ll)tmp * 9 * ((rank - 2) / 3);
        tmp = 1;
    }
    if (rank >= 4){
        rep(i, (ll)rank - 1)
          tmp *= 10;
        ans += (n - tmp + 1)*((rank-1)/3);
    }
    cout << ans;
    return 0;
}

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

//defines...
#define ll           long long
#define boost        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb           push_back
#define mp           make_pair
#define in           insert
#define pi           2*acos(0.0)
#define srt(s)       sort(s.begin(),s.end())
#define rsrt(s)      sort(s.rbegin(),s.rend())
#define all(x)       x.begin(),x.end()
#define mem(a, b)    memset(a, b, sizeof(a))
#define c_test       printf("Case %lld: ",t)

const ll mod=1e9+7;
const ll MX=2e5+5;

inline void norm(ll &a) {a%=mod; (a<0) && (a+=mod) ;}                            //positive mod value
inline ll modAdd(ll a,ll b) {a%=mod, b%=mod; norm(a),norm(b); return (a+b)%mod;} //modular addition
inline ll modSub(ll a,ll b) {a%=mod, b%=mod; norm(a),norm(b); return (a-b)%mod;} //modular subtraction
inline ll modMul(ll a,ll b) {a%=mod, b%=mod; norm(a),norm(b); return (a*b)%mod;} //modular multiplication

inline ll bigMod(ll b,ll p)  {ll r=1; while(p) {if(p & 1LL) r=modMul(r,b) ;b=modMul(b,b) ; p>>=1LL ; } return r; }
inline ll modInverse(ll a) {return bigMod(a,mod-2); }
inline ll modDiv(ll a ,ll b) { return modMul(a,modInverse(b)) ;}

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int dRow[] = { -1, 0, 1, 0 };
int dCol[] = { 0, 1, 0, -1 };

//code goes from here...

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

    //freopen("output.txt", "w", stdout);
//#endif

    boost
    //---------------------------------
    ll n;
    cin >> n;
    if(n==3)
    {
        cout << "6 10 15\n";
        return 0;
    }
    vector<ll> v;
    set<ll> s;

    for(ll i=6;i<=10000;i+=6) s.in(i);
    for(ll i=10;i<=10000;i+=10) s.in(i);
    for(ll i=15;i<=10000;i+=15) s.in(i);

    for(auto i: s) v.pb(i);

    for(ll i=0;i<n;i++) cout << v[i] <<  ' ';

    cout << endl;

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

    return 0;
}


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

ll cnt(ll X, ll Y, ll R, ll lim) {
    ll a = 0;
    ll b = 10000;
    ll res = 0;

    for (ll i = (Y + R) - (Y + R) % 10000; i >= lim; i -= 10000) {
        while ((b - X) * (b - X) + (i - Y) * (i - Y) <= R * R) {
            b += 10000;
        }
        while ((a - X) * (a - X) + (i - Y) * (i - Y) <= R * R) {
            a -= 10000;
        }

        res += (b - a - 10000) / 10000;
    }
    return res;
}

int main() {
    ld x, y, r;
    cin >> x >> y >> r;

    ll ans = 0;
    ll X = round(x * 10000);
    ll Y = round(y * 10000);
    ll R = round(r * 10000);
    X %= 10000;
    Y %= 10000;

    ans += cnt(X, Y, R, 10000);
    ans += cnt(X, -Y, R, 0);

    cout << ans << endl;

    return 0;
}

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

int main() {
    int l,r;
    cin>>l>>r;
    long long ans = 0;
    vector<long long> dp(r+1,0);
    for(int g = r; g>=2;g--){
        long long cnt = (r/g - (l-1)/g);
        dp[g] = (cnt * (cnt-1))/2;
        //Currently dp[g] contains g,2g,3g,4g,... as gcd
        //we need to remove all other gcd's except g
        for(int j=2*g;j<=r;j+=g){
            dp[g] -= dp[j]; //remove gcd = j from dp[g]
        }
        ans += dp[g];
    }
    //dp[g] contains the number of pairs which have gcd exactly g
    //But we need to remove the pairs which have one of number = g
    //there are r/g-1 such pairs
    //Since r/g-1 is the total number of elements which are paired in g
    //Hence we remove them from final answer

    //Let's say l < 2 : Here l = 1, and we want gcd!=1, Hence we ignore this
    //l >= 2: Assume l = 4, Now we need not remove r/2-1 , r/3-1 from our answer because such pairs are never formed
    //....as we are considering only pairs from l to r.
    for(int i=max(2,l);i<=r;i++) ans -= r/i - 1;
    cout<<2*ans<<endl;
}


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

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

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define deb(x) cout<<#x<<" "<<x<<"\n"
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("Error.txt", "w", stderr);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}
void upd(ll st[],ll v,ll stl,ll str,ll pos,ll val)
{
	if(stl==str)
		st[v]=1;
	else
	{
		ll stm=(stl+str)/2;
		if(pos<=stm)
			upd(st,2*v,stl,stm,pos,val);
		else
			upd(st,2*v+1,stm+1,str,pos,val);
		st[v]=st[2*v]+st[2*v+1];
	}
}
ll ans(ll st[],ll v,ll stl,ll str,ll l,ll r)
{
	if(l>r)
		return 0LL;
	if(stl==l && r==str)
		return st[v];
	else
	{
		ll stm=(stl+str)/2;
		return ans(st,2*v,stl,stm,l,min(r,stm))+ans(st,2*v+1,stm+1,str,max(stm+1,l),r);
	}
}
void terminAtor()
{
	ll n;
	cin>>n;
	ll a[n+1];
	for(ll i=1;i<=n;i++)
		cin>>a[i];
	ll st[4*(n+1)];
	for(ll i=0;i<4*n+1;i++)
		st[i]=0;
	ll tot=0,temp=0;
	vector< ll > pos;
	for(ll i=1;i<=n;i++)
	{
		tot+=(ans(st,1,1,n,a[i]+1,n));
		if(temp!=tot)
		{
			temp=tot;
			pos.pb(i);
		}
		upd(st,1,1,n,a[i],1);
	}
	if(tot!=n-1){
		cout<<-1;
		return;
	}
	ll k=0;
	for(ll i=0;i<pos.size();i++)
	{
		ll tt=pos[i]-1;
		pos[i]--;
		while(pos[i]>k)
		{
			cout<<pos[i]<<"\n";
			pos[i]--;
		}
		k=tt;
	}

}

int main()
{
	checkpoint1();
/********************************************************/
	auto startrrr = high_resolution_clock::now();
	cout << setprecision(20);
/*******************************************************/

	terminAtor();

/*******************************************************/
	auto stoprrr = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stoprrr - startrrr);
	#ifndef ONLINE_JUDGE
		cerr << "Time: " << duration.count()/1000.0<<"\n";
	#endif
/*******************************************************/
	return 0;
}

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

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

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

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

}

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

  int n;
  cin >>n ;
  vector<int> arr(n+1);
  vector<int> ind(n+1);

  for(int i=1;i<=n;i++)
   {
     cin >> arr[i];
     ind[arr[i]]=i;
   }

   vector<bool> vis(n);
   vector<int> ans ;
   bool yes=true;
   for(int i=1;i<=n;i++)
   {
     int u=ind[i];
     if(ind[i]==i) continue;
     while(u>i)
     {

       if(vis[u-1])
       {
         yes=false;
         break;
       }
       // cout << u << endl;
       vis[u-1]=true;
       ans.pb(u-1);
       swap(arr[u],arr[u-1]);
       ind[arr[u]]=u;
       ind[arr[u-1]]=u-1;
       u--;
     }

     if(!yes) break;
     // cout << i << endl;
   }
    // cout << yes << endl;
   for(int i=1;i<n;i++)
    {
      if(!vis[i]) yes=false;
    }
    // cout << endl;

    for(int i=1;i<=n;i++)
      if(arr[i]!=i) yes=false;
    if(!yes) cout << -1 ;
    else
    {
       for(int i=0;i<n-1;i++) cout << ans[i] << " ";
    }
  cout << endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    //int t; cin >> t; while (t--)
    solve();

}


//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define REP(i,n) for(int i=0;i<n;i++)
const int N = 2e5+10;
const ll mod = 1e9+7;

void run_case(){
	string s;
	cin >> s;
	string tt="";
	tt+=s[1];
	tt+=s[2];
	tt+=s[0];
	cout<<tt;

}

int main(){
	fast;
	int q;
	//cin >> q;
	q=1;
	while(q--){
		run_case();
	}

}

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

int main() {
  string s;
  cin >> s;
  cout << s[1] << s[2] << s[0] << endl;
  return 0;
}


#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define ll long long int
#define all(x) begin(x), end(x)
bool isPowerOfTwo (int x) {
    return x && (!(x&(x-1)));
}
int main(){
    //std::ios_base::sync_with_stdio(0);
    //std::cin.tie(0);
    //freopen("king2.in", "r", stdin);
    //freopen("king2.out", "w", stdout);
    std::string s;
    std::cin >> s;
    int od = 0, ev = 0;
    bool f = false;
    for(int i = 0; i < (int)s.size(); i++){
        if((i+1)%2 != 0){
            if(s[i] >= 97 && s[i] <= 122){
                 od++;
                 continue;
            }
            else{
               f = true;
                break;
            }
        }
        if((i+1)%2 == 0){
            if(s[i] >= 65 && s[i] <= 90){
                ev++;
                continue;
            }
            else{
               f = true;
               break;
           }
        }
        else{
            f = true;
            break;
        }
    }
    if(f == false){
        std::cout <<"Yes\n";
    }
    else{
        std::cout << "No\n";
    }
}

#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 FOR(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(i, n) FOR(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;

    bool ok = true;
    REP(i, s.size()){
        if(i % 2 == 0 && !('a' <= s[i] && s[i] <= 'z')){
            ok = false;
        }else if(i % 2 && !('A' <= s[i] && s[i] <= 'Z')){
            ok = false;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int main(){
  char a[3];
  cin>>a[0]>>a[1]>>a[2];
  cout << a[1] << a[2] << a[0] << endl;
  return 0;
}

#include <stdio.h>

int main(){
  bool rev=false;
 	char dq[1101000],c;
  int l=501000,r=501000;//一開一閉
  while((c=getchar())!='\n'){
  	if(c=='R')rev=!rev;
    else{
    	if(rev){
        if(l!=r&&dq[l]==c)l++;
        else dq[--l]=c;}
      else{
        if(l!=r&&dq[r-1]==c)r--;
        else dq[r++]=c;}}}
	if(rev)for(int i=r-1;i>=l;i--)putchar(dq[i]);
  else for(int i=l;i<r;i++)putchar(dq[i]);
	putchar('\n');
return 0;}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vv = vector<vi>;
using P  = pair<ll,int>;//(cost,to)
using vP = vector<P>;
using vvP= vector<vP>;

const int INF = 1001001001;

void dijkstra(vvP &graph, vi &cost, int &s){

    priority_queue<P, vP, greater<P>> q;
    q.push(P(0,s));

    vector<bool> used((int)graph.size(), 0);

    while(!q.empty()){
        ll c  = q.top().first;
        int v  = q.top().second;
        q.pop();

        if(used[v])continue;
        if(c>cost[v])continue;
        used[v] = 1;
        cost[v] = c;

        for(int i=0; i<(int)graph[v].size(); i++){
            if(used[graph[v][i].second])continue;
            q.push(P(c + graph[v][i].first, graph[v][i].second));
        }
    }
    return;
}

int main(){
    int r, c;
    cin >> r >> c;
    vv a(r, vi(c-1));
    vv b(r-1, vi(c));
    rep(i,r)rep(j,c-1)cin >> a[i][j];
    rep(i,r-1)rep(j,c)cin >> b[i][j];

    vvP graph(r*c*2);

    rep(i,r)rep(j,c){
        if(i)graph[i*c+j].push_back(P(2, (i-1)*c+j + r*c));
        if(i!=r-1)graph[i*c+j].push_back(P(b[i][j], (i+1)*c+j));
        if(j)graph[i*c+j].push_back(P(a[i][j-1], i*c+j-1));
        if(j!=c-1)graph[i*c+j].push_back(P(a[i][j], i*c+j+1));

        if(i)graph[i*c+j+r*c].push_back(P(1, (i-1)*c+j + r*c));
        if(i!=r-1)graph[i*c+j+r*c].push_back(P(b[i][j], (i+1)*c+j));
        if(j)graph[i*c+j+r*c].push_back(P(a[i][j-1], i*c+j-1));
        if(j!=c-1)graph[i*c+j+r*c].push_back(P(a[i][j], i*c+j+1));
    }

    vi cost(r*c*2, INF);
    int s = 0;

    dijkstra(graph, cost, s);

    cout << cost[r*c-1] << endl;

    return 0;
}

#include <bits/stdc++.h>

template <typename T>
T next() {
    T temp; std::cin >> temp;
    return temp;
}

template <>
int next() {
    int temp; scanf("%d", &temp);
    return temp;
}
template <>
long long next() {
    long long temp; scanf("%lld", &temp);
    return temp;
}
template <>
double next() {
    double temp; scanf("%lf", &temp);
    return temp;
}
template <>
float next() {
    float temp; scanf("%f", &temp);
    return temp;
}

template <typename T1, typename T2>
std::pair<T1, T2> next() {
    std::pair<T1, T2> temp;
    temp.first = next<T1>();
    temp.second = next<T2>();
    return temp;
}

template <typename T>
std::vector<T> next(int n) {
    std::vector<T> temp(n);
    for(int i = 0; i < n; i++)
        temp[i] = next<T>();
    return temp;
}

template <typename T1, typename T2>
std::vector<std::pair<T1, T2>> next(int n) {
    std::vector<std::pair<T1, T2>> temp(n);
    for(int i = 0; i < n; i++)
        temp[i] = next<T1, T2>();
    return temp;
}

template <typename T>
void print(const T &x, char endc = '\n') {
    std::cout << x << endc;
    return;
}
void print(const int &x, char endc = '\n') {
    printf("%d%c", x, endc);
    return;
}
void print(const long long &x, char endc = '\n') {
    printf("%lld%c", x, endc);
    return;
}
void print(const size_t &x, char endc = '\n') {
    printf("%zu%c", x, endc);
    return;
}
void print(const float &x, char endc = '\n') {
    printf("%f%c", x, endc);
    return;
}
void print(const double &x, char endc = '\n') {
    printf("%lf%c", x, endc);
    return;
}

template<typename T1, typename T2>
void print(const std::pair<T1, T2> &p, char sepc = ' ', char endc = '\n') {
    print(p.first, sepc);
    print(p.second, endc);
    return;
}

template<typename T>
void print(const std::vector<T> &v, char sepc = ' ', char endc = '\n') {
    for(const T &e : v) print(e, sepc);
    printf("%c", endc);
    return;
}

template<typename T>
class SparseGraph {
    struct Node {
        std::vector<std::pair<int, T>> adj;
        T value;
    };

private:
    std::vector<Node> nodes;
    int nodeSize;
    int edgeSize = 0;

public:
    SparseGraph(int n) {
        nodes.resize(n);
        nodeSize = n;
    }

    SparseGraph(const std::vector<T> &values) {
        int n = values.size();
        nodes.resize(n);
        nodeSize = n;
        for(int i = 0; i < n; i++)
            nodes[i].value = values[i];
    }

    void addEdge(int u, int v, const T &edgeVal = 0) {
        nodes[u].adj.push_back({v, edgeVal});
        edgeSize++;
    }

    const int &getNodeSize() const {
        return nodeSize;
    }

    const int &getEdgeSize() const {
        return edgeSize;
    }

    const T &valueOf(int here) const {
        return nodes[here].value;
    }

    const std::vector<std::pair<int, T>> &adjOf(int here) const {
        return nodes[here].adj;
    }
};

using namespace std;

double solve(int connected, int disconnected, vector<double> &memo) {
    if(disconnected == 0)
        return 0.0;

    double &ret = memo[connected];
    if(!ret) {
        ret = solve(connected+1, disconnected-1, memo) + 1.0 + 1.0*connected/disconnected;
    }

    return ret;
}

void eachTC() {
    int N = next<int>();
    vector<double> memo(N, 0.0);
    double res = solve(1, N-1, memo);
    printf("%.9lf", res);
}

int main() {
    constexpr bool multipleTC = false;
    int T = multipleTC ? next<int>() : 1;
    while(T--) eachTC();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;typedef long long ll;
int T=1;void eo();int main(){//cin>>T;
while(T--)eo();}
void eo(){
	string s;cin>>s;
	for(char x:s){
		if(x=='.') break;
		cout<<x;
	}
cout<<'\n';}

///bismillahir rahmanir rahim

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

#define ll long long

int main()
{
    ll p=0, d=0, c=0;
    string s;
    cin>>s;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='.') d++;
    }
    if(d==1){
        for(int i=0; s[i]!='.'; i++){
            if(s[i]>'0'){
                c++;
            }
        }
        if(c==0) cout<<0;
        else{
            for(int i=0; s[i]!='.'; i++){
                if(s[i]!='0'){
                    p=i;
                    break;
                }
            }
            for(int i=p; s[i]!='.'; i++) cout<<s[i];
        }
    }
    else{
        for(int i=0; i<s.size(); i++){
            if(s[i]!='0'){
                p=i;
                break;
            }
        }
        for(int i=p; i<s.size(); i++) cout<<s[i];
    }
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define reps(i,n) for (int i = 1; i <= (n); ++i)
#define rrep(i,n) for (int i = (n) - 1; i >= 0; --i)
#define rreps(i,n) for (int i = (n); i > 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define PB push_back
#define MP make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
using namespace std;
using ll = long long;
using P = pair<int,ll>;

ll x, y;

int main() {
  cin >> x >> y;

  if (x >= y) {
    cout << x - y << endl;
    return 0;
  }

  ll ans = 2e18;
  map<ll, int> d;
  priority_queue<P, vector<P>, greater<P>> que;
  d[y] = 0;
  que.push(MP(d[y], y));
  while (que.size()) {
    P p = que.top(); que.pop();
    ll yy = p.second;
    // printf("yy = %lld\n", yy);
    if (p.first > d[yy]) continue;
    ans = min(ans, d[yy] + abs(yy - x));
    if (yy <= x) continue;
    if (yy % 2 == 0) {
      if (d[yy / 2] != 0 && d[yy / 2] <= d[yy] + 1) continue;
      d[yy / 2] = d[yy] + 1;
      que.push(MP(d[yy / 2], yy / 2));
    } else {
      if (d[yy / 2] == 0 || d[yy / 2] > d[yy] + 2) {
        d[yy / 2] = d[yy] + 2;
        que.push(MP(d[yy / 2], yy / 2));
      }
      if (d[yy / 2 + 1] == 0 || d[yy / 2 + 1] > d[yy] + 2) {
        d[yy / 2 + 1] = d[yy] + 2;
        que.push(MP(d[yy / 2 + 1], yy / 2 + 1));
      }
    }
  }

  cout << ans << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long x,y;
map<long long,long long>dp;
long long rec(long long now){
  if(x>=now)return x-now;
  if(dp[now])return dp[now];
  long long res=now-x;
  if(res>rec(now/2)+now%2+1)res=rec(now/2)+now%2+1;
  if(res>rec((now+1)/2)+now%2+1)res=rec((now+1)/2)+now%2+1;
  return dp[now]=res;
}
int main(){
  cin>>x>>y;
  cout<<rec(y)<<endl;
  return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define rsrt(v) sort(v.begin(), v.end(), greater<int>())
#define rsrtl(v) sort(v.begin(), v.end(), greater<ll>())
#define fi(i, a, b) for (int i = a; i < b; i++)
#define fll(i, a, b) for (ll i = a; i < b; i++)
#define srt(v) sort(v.begin(), v.end())
#define pb push_back
#define g(v, i, j) get<i>(v[j])
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(),(x).end()
#define ll long long
ll md = 1000000007;
#define theartofwar                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define F first
#define S second
#define sz(v) v.size()
using namespace std;
#define dbg(x) cerr << #x << " = " << x << endl;
template <typename T>
T pw(T a, T b){
    T c = 1, m = a;
    while (b){
        if (b & 1) c = (c * m);
        m = (m * m), b /= 2;
    }
    return c;
}
template <typename T>
T ceel(T a, T b){
    if (a % b == 0)
        return a / b;
    else
        return a / b + 1;
}
template <typename T>
T my_log(T n, T b){
    T i = 1, ans = 0;
    while (1){
        if (i > n){
            ans--;
            break;
        }
        if (i == n) break;
        i *= b, ans++;
    }
    return ans;
}
template <typename T>
T gcd(T a, T b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll pwmd(ll a, ll b){
    ll c = 1, m = a;
    while (b){
        if (b & 1) c = (c * m) % md;
        m = (m * m) % md;
        b /= 2;
    }
    return c;
}
ll modinv(ll n){
    return pwmd(n, md - 2);
}
ll inverse(ll i){
    if (i == 1)
        return 1;
    return (md - ((md / i) * inverse(md % i)) % md + md) % md;
}
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b){
    return (a.second < b.second);
}
int main()
{
    theartofwar;
    ll n, a;
    cin >> n;
    vll v;
    fll(i, 0, n) cin >> a, v.pb(a);
    ll dp[n][n + 1];
    fll(i, 0, n) fll(j, 0, n + 1) dp[i][j] = 0;
    ll last[n + 1][n];
    fll(i, 0, n + 1) fll(j, 0, n) last[i][j] = -1;
    dp[0][1] = 1;
    fll(i, 2, n + 1) last[i][v[0] % i] = 0;
    ll s = v[0];
    fll(i, 1, n){
        dp[i][1] = 1;
        s += v[i];
        fll(j, 2, i + 2){
            ll p = s % j;
            if (last[j][p] == -1) continue;
            ll o = last[j][p];
            dp[i][j] = (dp[i][j] + dp[o][j]) % md;
            dp[i][j] = (dp[i][j] + dp[o][j - 1]) % md;
        }
        fll(j, 2, n + 1) last[j][s % j] = i;
    }
    ll ans = 0;
    fll(i, 1, n + 1) ans = (ans + dp[n - 1][i]) % md;
    cout << ans;
}


#include<bits/stdc++.h>
#define HohleFeuerwerke using namespace std
#pragma GCC optimize(3,"Ofast","-funroll-loops","-fdelete-null-pointer-checks")
#pragma GCC target("ssse3","sse3","sse2","sse","avx2","avx")
#define int long long
HohleFeuerwerke;
inline int read(){
	int s=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) s=s*10+c-'0';
	return s*f;
}
inline void write(int x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
signed main()
{
	int x=read();
	if(x>=0) write(x),puts("");
	else puts("0");
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  stack<char> st;
  int ans = N;
  for(int i = 0;i < N;i++){
    char c = S.at(i);
    if(c == 'f' || c == 'o')
      st.push(c);
    else if(c == 'x' && st.size() >= 2){
      char two = st.top();
      st.pop();
      char one = st.top();
      st.pop();
      if(one == 'f' && two == 'o')
        ans -= 3;
      else{
        for(;;){
          if(st.size() > 0) st.pop();
          else break;
        }
      }
    }
    else{
      for(;;){
        if(st.size() > 0) st.pop();
        else break;
      }
    }
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ls (p << 1)
#define rs (ls | 1)
#define tm ((tl + tr) >> 1)
#define lowbit(x) ((x) & -(x))

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

constexpr double eps = 1e-8;
constexpr int NINF = 0xc0c0c0c0;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LNINF = 0xc0c0c0c0c0c0c0c0;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll mod = 1e9 + 7;
constexpr ll N = 5e2 + 5;

int n, c[N][N], a[N], b[N], da[N], db[N];

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

    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 1; i < n; i++) {
        da[i] = c[i][0] - c[i - 1][0];
        db[i] = c[0][i] - c[0][i - 1];
    }
    int id1 = 0, id2 = 0;
    for (int i = 1; i < n; i++) {
        da[i] += da[i - 1];
        db[i] += db[i - 1];
        if (id1 == 0 || da[i] < da[id1]) {
            id1 = i;
        }
        if (id2 == 0 || db[i] < db[id2]) {
            id2 = i;
        }
    }
    // if (c[0][0] > da[id1] + db[id2]) {
    //     cout << "No\n";
    //     return 0;
    // }
    if (da[id1] < 0) {
        a[0] = abs(da[id1]);
        c[0][0] -= a[0];
    }
    if (db[id2] < 0) {
        b[0] = abs(db[id2]);
        c[0][0] -= b[0];
    }
    if (c[0][0] < 0) {
        cout << "No\n";
        return 0;
    } else {
        a[0] += c[0][0];
        c[0][0] = a[0] + b[0];
    }
    for (int i = 1; i < n; i++) {
        a[i] = a[0] + da[i];
        b[i] = b[0] + db[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i] + b[j] != c[i][j]) {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    for (int i = 0; i < n; i++) cout << a[i] << " \n"[i == n - 1];
    for (int i = 0; i < n; i++) cout << b[i] << " \n"[i == n - 1];

    return 0;
}

#include<iostream>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define int long long
using namespace std;
int c[502][502],a[502],b[502];
signed main(){
    ios::sync_with_stdio(false);
    int n; cin>>n;
    rep(i,1,n)rep(j,1,n)cin>>c[i][j];
    bool flag=true;
    rep(i,1,n){rep(j,2,n){
        if(i==1)a[j]=c[i][j]-c[i][j-1];
        else if(a[j]!=c[i][j]-c[i][j-1]){flag=false;break;}
    }if(!flag)break;}
    if(!flag){cout<<"No\n";return 0;}
    rep(j,1,n){rep(i,2,n){
        if(j==1)b[i]=c[i][j]-c[i-1][j];
        else if(b[i]!=c[i][j]-c[i-1][j]){flag=false;break;}
    }if(!flag)break;}
    if(!flag){cout<<"No\n";return 0;}
    int mna=0,mnb=0;
    rep(i,1,n){
        a[i]+=a[i-1],b[i]+=b[i-1];
        mna=min(mna,a[i]),mnb=min(mnb,b[i]);
    }
    //cout<<mna<<" "<<mnb<<endl;
    if(c[1][1]+mna+mnb<0){cout<<"No\n";return 0;}
    int ada=-mna,adb=c[1][1]-ada;
    cout<<"Yes\n";
    rep(i,1,n)cout<<b[i]+adb<<" ";
    cout<<endl;
    rep(i,1,n)cout<<a[i]+ada<<" ";
    cout<<endl;
    return 0;
}


#include <bits/stdc++.h>

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

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

    int flag = 0;
    int ansa = 0, ansb = 0;
    ll a = 3;

    for(int i = 1; ; i++) {
        if(a < 0 || a > n) break;
        ll b = 5;
        for(int j = 1;;j++) {
            if(b < 0 || a + b > n) break;
            else if(a + b == n) {
                flag = 1;
                ansa = i;
                ansb = j;
                break;
            }
            b *= 5;
        }
        a *= 3;
    }

    if(flag == 0) cout << -1 << endl;
    else cout << ansa << " " << ansb << endl;
}

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

#include<bits/stdc++.h>
using namespace std;
long long N,INF = 1e18;
int main() {
	scanf("%lld",&N);
	long long k = 1,d = 1,s = 1;
	int i=1,j=1;
	for(;k<=N;++i) {
		 k*=5;
		d = N-k,s = 3,j=2;
		for(;s<d;++j) {
			s*=3;
		}
		if(d == s) {
			return 0*printf("%d %d\n",j-1,i);
		}
	}
	puts("-1");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define quickread                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define hii cout << "Hii there Sparky! \n"
#define endl '\n'
#define mod 1000000007
//#define mod 998244353
#define maxn 100010 //check the limits, dummy

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    if (c == 0) {
        if (a > b) {
            cout << "Takahashi" << endl;
        } else {
            cout << "Aoki" << endl;
        }
    } else {
        if (b > a) {
            cout << "Aoki" << endl;
        } else {
            cout << "Takahashi" << endl;
        }
    }
}

int32_t main() {
    quickread;
    int test = 1;
    //cin >> test;
    for (int i = 0; i < test; i++) {
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int maxn=1e2+5;
double dp[maxn][maxn][maxn];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    for (int i=99; i>=a; i--) {
        for (int j=99; j>=b; j--) {
            for (int k=99; k>=c; k--) {
                double m=i+j+k;
                dp[i][j][k] = i/m*(dp[i+1][j][k]+1) + j/m*(dp[i][j+1][k]+1) + k/m*(dp[i][j][k+1]+1);
            }
        }
    }
   printf("%.9lf",dp[a][b][c]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 0; i < n; i++)
#define RREP(i,n) for (int i = n; i >= 0; i--)
#define MOD 1000000007
#define MOD2 998244353
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define vecin(x,n); vi x;int hool; for(int o=0;o<n;o++) {cin>>hool; x.pb(hool);}
#define vecout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
#define debarrall(arr) for(int o=0;o<arr.size();o++) deb2(o,arr[o])
#define IO freopen("input.txt", "r", stdin); freopen("output.txt", "w+", stdout)
const double pi = 3.14159265358979323846;

namespace number_theory{
    int powersimple(int a, int b){//a^b
        int res=1;
        while(b>0){
            if(b&1)
            {res=(res*a);
            b--;}
            a=(a*a);
            b>>=1;
        }
        return res;
    }

    int ncr(int n,int k)
    {
        int ans=1;
        if(k>n-k)
        k=n-k;
        for(int i=1;i<=k;i++)
        ans*=(n-i+1),ans/=i;
        return ans;
    }

    int power(int x,int y,int p)
    {
        int res = 1;
        x = x % p;
        while (y > 0) {
            if (y & 1)
                res = (res * x) % p;
            y = y >> 1;
            x = (x * x) % p;
        }
        return res;
    }

    int modInverse(int n, int p)
    {
        return power(n, p - 2, p);
    }

    int ncrModPFermat(int n,int r, int p)
    {

        if (r == 0)
            return 1;

        int fac[n + 1];
        fac[0] = 1;
        for (int i = 1; i <= n; i++)
            fac[i] = (fac[i - 1] * i) % p;

        return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
    }

    int gcd(int a, int b){
        return (b==0)?a:gcd(b,a%b);
    }
}
using namespace number_theory;

///////////////END OF TEMPLATE//////////////////

void solve(){
    int x,y,a,b;cin>>x>>y>>a>>b;
    int exp=0;
    while((double)a*x<=2e18 and a*x<=x+b and a*x<y){
    	x*=a;
    	exp++;
    }
    int add=(y-x-1)/b;
    cout<<exp+add;
}

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

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

    //test{
        solve();
    //}

    return 0;
}

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)
#define mem0(a) memset(a,0,sizeof(a))
#define mem_1(a) memset(a,-1,sizeof(a))
#define mem0x(a) memset(a,0x3f,sizeof(a))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN(a,b) (a)<(b)?(a):(b)
#define INF 0x7f7f7f7f
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
using namespace std;

typedef long long ll;
//typedef __int64_t i64;
typedef long long unsigned llu;
typedef pair<int,int> P;
typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
const int N = 200002;

int main(){

    //int a,b,tmp,sum,v,w;

    ll X,Y,A,B;
    cin>>X>>Y>>A>>B;

    ll  ret=0;
    while(1){
        if(Y/X<A) break;
        if( A*X >= X+B) break;
        if(A*X>=Y) break;

        ret++;
      X*=A;
    }

     ret+= (Y-1-X)/B;

    //watch(ret);
    cout<<ret<<endl;

    return 0;
}


#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
using ll = long long;

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i, n)
    {
        ll tempA;
        ll tempB;
        cin >> tempA >> tempB;
        tempA--;
        tempB--;
        // a<=b となるように並べます→いみない！！！
        if (tempA <= tempB)
        {
            a[i] = tempA;
            b[i] = tempB;
        }
        else
        {
            a[i] = tempB;
            b[i] = tempA;
        }
    }
    ll aMax = 0;
    ll bMax = 0;
    rep(i, n)
    {
        aMax = max(aMax, a[i]);
        bMax = max(bMax, b[i]);
    }
    ll colorKinds = max(aMax, bMax) + 1;

    vector<vector<ll>> targets(colorKinds);
    rep(i, n)
    {
        targets[a[i]].push_back(b[i]);
        targets[b[i]].push_back(a[i]);
    }

    ll result = 0;
    vector<bool> doneColor(colorKinds, false);
    for (ll color = 0; color < colorKinds; color++)
    {
        if (doneColor[color] == true)
        {
        }
        else
        {
            queue<ll> que;
            que.push(color);
            ll islandMembers = 0;
            ll kyohi = 0;
            while (!que.empty())
            {
                ll nowColor = que.front();
                que.pop();
                if (doneColor[nowColor] == false)
                {
                    doneColor[nowColor] = true;
                    islandMembers++;
                    for (ll target : targets[nowColor])
                    {
                        que.push(target);
                    }
                }
                else
                {
                    // その頂点は調査済みだった場合
                    kyohi++;
                }
            }
            if (kyohi == islandMembers - 1)
            {
                // loopなし
                result += islandMembers - 1;
            }
            else
            {
                // loopあり
                result += islandMembers;
            }
        }
    }
    cout << result << endl;
    return 0;
}

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

using namespace std;
//using namespace atcoder;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

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

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

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

// edit

struct UnionFind {
    vector<int> par, sz;
    vector<int> ed;

    UnionFind(int n) : par(n), sz(n, 1), ed(n, 0) {
        for (int i = 0; i < n; ++i) par[i] = i;
    }

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

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sz[x] < sz[y]) swap(x, y);
        par[y] = x;

        sz[x] += sz[y];
        sz[y] = 0;

        ed[x] += ed[y];
        ed[y] = 0;
    }

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

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

    void add_e(int x) {
        ed[root(x)]++;
    }

    int e_size(int x) {
        return ed[root(x)];
    }
};

const int lim = 400005;
vector<vector<int>> G(lim);

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

    UnionFind uf(lim);

    set<int> app;
    REP(_, N) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        app.insert(a);
        app.insert(b);

        if (a == b) {
            uf.add_e(a);
            continue;
        }
        if (uf.issame(a, b)) {
        } else {
            uf.merge(a, b);
        }

        uf.add_e(a);
    }

    set<int> gr;

    int ans = app.size();
    for (auto e : app) {
        int g = uf.root(e);
        if (gr.count(g)) continue;
        gr.insert(g);

        if (uf.e_size(e) < uf.size(e)) {
            ans--;
        }
    }

    cout << ans << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();

    return 0;
}


/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <assert.h>
#include <math.h>
#include <memory.h>
#include <stdio.h>

#include <algorithm>
#include <complex>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define left asdgashgrketwjklrej
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-12
#define M_PI 3.141592653589793
#define bsize 1024

#define ldouble long double
using namespace std;

const int bs = 1000000007;

const long long N = 200031;

long long a[N],b[N],n,cur_max;
long long ans[N];

int main() {
    //freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    cin>>n;
    for (int i=1;i<=n;i++){
    	cin>>a[i];
    }
    for (int i=1;i<=n;i++){
    	cin>>b[i];
    }

    cur_max=0;
    for (int i=1;i<=n;i++){
    	cur_max=max(cur_max,a[i]);
    	ans[i]=b[i]*cur_max;
    	ans[i]=max(ans[i],ans[i-1]);
    }

    for (int i=1;i<=n;i++){
    	cout<<ans[i]<<endl;
    }

    //cin.get(); cin.get();
    return 0;
}

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

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

int main() {
  int n;
  cin >> n;
  vector<i64> a(n), b(n);
  cin >> a >> b;
  vector<i64> c(n);
  vector<i64> a_max(n + 1);
  rep(i, n) a_max[i + 1] = max(a_max[i], a[i]);
  repr(i, n) c[i] = a_max[i + 1] * b[i];
  rep(i, n - 1) c[i + 1] = max(c[i + 1], c[i]);
  cout << (c) << endl;
}


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

int main() {
    int H, W, N, M;
    cin >> H >> W >> N >> M;
    int mat[H][W];
    rep(i, H) rep(j, W) {
        mat[i][j] = 0;
    }
    vector<P> light;
    rep(i, N) {
        int p1, p2;
        cin >> p1 >> p2;
        light.push_back((P){p1-1, p2-1});
    }
    rep(i, M) {
        int p1, p2;
        cin >> p1 >> p2;
        mat[p1-1][p2-1] = -1;
    }
    int count = 0;
    for(auto p : light) {
        if(mat[p.first][p.second] == 0) {
            count++;
            mat[p.first][p.second] = 1;
            int i = 1;
            while(p.first+i < H && mat[p.first+i][p.second] != -1) {
                mat[p.first+i][p.second] = 1;
                count++;
                i++;
            }
            i = 1;
            while(p.first-i >= 0 && mat[p.first-i][p.second] != -1) {
                mat[p.first-i][p.second] = 1;
                count++;
                i++;
            }
        }
    }
    for(auto p : light) {
        if(mat[p.first][p.second] == 2) continue;
        int i = 1;
        while(p.second+i < W && mat[p.first][p.second+i] != -1) {
            if(mat[p.first][p.second+i] == 0) count++;
            mat[p.first][p.second+i] = 2;
            i++;
        }
        i = 1;
        while(p.second-i >= 0 && mat[p.first][p.second-i] != -1) {
            if(mat[p.first][p.second-i] == 0) count++;
            mat[p.first][p.second-i] = 2;
            i++;
        }
    }
    cout << count << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

struct Edge {
  ll to;
  char c;
  Edge(ll to, char c) : to(to), c(c) {}
};

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<Edge>> to(n);
  REP(i, m) {
    ll a, b;
    char c;
    cin >> a >> b >> c;
    a--, b--;
    to[a].push_back(Edge(b, c));
    to[b].push_back(Edge(a, c));
  }
  const ll INF = 1e18;
  vector<vector<ll>> dp(n, vector<ll>(n, INF));
  queue<P> q;
  REP(i, n) {
    dp[i][i] = 0;
    q.push({i, i});
  }
  REP(i, n) {
    for (Edge e : to[i]) {
      ll nv = e.to;
      chmin(dp[i][nv], 1LL);
      q.push({i, nv});
    }
  }

  while (!q.empty()) {
    P p = q.front();
    q.pop();
    ll a = p.first, b = p.second;
    for (Edge e1 : to[a]) {
      for (Edge e2 : to[b]) {
        if (e1.c == e2.c) {
          ll bef = dp[e1.to][e2.to], aft = dp[a][b] + 2;
          if (bef > aft) {
            dp[e1.to][e2.to] = aft;
            q.push({e1.to, e2.to});
          }
        }
      }
    }
  }

  ll ans = dp[0][n - 1];
  if (ans == INF) {
    ans = -1;
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
    using namespace atcoder;
#endif
using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 1; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  vector<P> v(N);
  rep(i, N) {
    int x, y;
    cin >> x >> y;
    v[i] = mp(x, y);
  }
  int cnt = 0;
  rep(i, N) {
    for (int j = i+1; j < N; j++) {
      double t = (double)(v[j]._2-v[i]._2)/(v[j]._1-v[i]._1);
      if (t >= -1 && t <= 1)
        cnt++;
    }
  }
  cout << cnt << endl;
}

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

int main(){
    int n;  cin >> n;
    vector<int> m(200, 0);
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
        m[a[i]%200]++;
    }
    ll ans = 0;
    rep(i, n){
        m[a[i]%200]--;
        ans += m[a[i]%200];
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll=long long;
using ld=long double;
//using mint = modint1000000007;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo 2e18
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
//priority_queue<ll, vector<ll>, greater<ll>> Q;
/*
7 5
10101
00001
10001 合致する

00110
11110
00100
11111
10000
*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  ll N, M;
  cin >> N >> M;
  ll odd=0, even=0;
  rep(i, N){
    string S;
    cin >> S;
    ll cnt = 0;
    rep(j, M){
      if (S[j] == '1') cnt++;
    }
    if (cnt%2) odd++;
    else even++;
  }
  cout << odd * even << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x;
    string s;
    cin>>n>>x;
    cin>>s;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='x')
        {
            if(x!=0)
            {
             x--;
            }
        }
        else
        {
            x++;
        }
    }
    cout<<x;
}


#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

const double Pi=3.141592653589793;

int main(){
    int n;
    cin>>n;
    double x[2],y[2];
    for(int i=0;i<2;i++){
        cin>>x[i]>>y[i];
    }
    double mx=(x[0]+x[1])/2;
    double my=(y[0]+y[1])/2;
    x[0]-=mx,y[0]-=my;
    double ans_x,ans_y;
    ans_x=x[0]*cos(2*Pi/n)-y[0]*sin(2*Pi/n);
    ans_y=x[0]*sin(2*Pi/n)+y[0]*cos(2*Pi/n);
    ans_x+=mx,ans_y+=my;
    cout<<fixed<<setprecision(15)<<ans_x<<" ";
    cout<<fixed<<setprecision(15)<<ans_y;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> pii;
typedef pair<LL,pii> ppi;
typedef pair<pii,pii> ppp;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second

#define y0 asdfasdf
#define y1 asdfasdvcxz
typedef complex<double> pnt;
#define x real()
#define y imag()

template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {cout << "["; F0R(i, v.size()) {if (i) cout << ", "; cout << v[i];} return cout << "]";}

//var
LL T;
pnt p0, pn2, p1;
double x0, y0, yn2, xn2;
double n;
const double PI = atan(1) * 4;

void solve(){
	cin >> n;
	cin >> x0 >> y0 >> xn2 >> yn2;
	p0 = pnt(x0, y0);
	pn2 = pnt(xn2, yn2);

	double angle = (LD)2 * PI / n;
	pn2 = (p0 + pn2) / (pnt)2;
	p0 = (p0 - pn2) * polar(1.0, angle) + pn2;

	cout << fixed << setprecision(11);
	cout << p0.x << ' ' << p0.y << "\n";
}

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

	T = 1;
	//cin >> T;
	FOR(t, T)
		solve();

	cout.flush();
	return 0;
}


#include <stdio.h>

#include <vector>

#define cm (1 << 17)
char cn[cm], *ci = cn + cm, ct;

inline char getcha() {
  if (ci - cn == cm) {
    fread(cn, 1, cm, stdin);
    ci = cn;
  }
  return *ci++;
}

inline int getint() {
  int A = 0;
  while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
  return A;
}

int main() {
  int h = getint(), w = getint(), n = getint(), m = getint();
  bool g1[h][w] = {}, g2[h][w] = {}, res[h][w] = {};
  for (int i = 0; i < n; ++i) {
    g1[getint() - 1][getint() - 1] = 1;
  }
  for (int i = 0; i < m; ++i) {
    g2[getint() - 1][getint() - 1] = 1;
  }
  for (int i = 0; i < h; ++i) {
    bool flag = 0;
    for (int j = 0; j < w; ++j) {
      if (g2[i][j]) {
        flag = 0;
      } else if (g1[i][j]) {
        flag = 1;
        for (int jj = j - 1; ~jj; --jj) {
          if (g1[i][jj] || g2[i][jj]) break;
          res[i][jj] = 1;
        }
      }
      if (flag) res[i][j] = 1;
    }
  }
  for (int j = 0; j < w; ++j) {
    bool flag = 0;
    for (int i = 0; i < h; ++i) {
      if (g2[i][j]) {
        flag = 0;
      } else if (g1[i][j]) {
        flag = 1;
        for (int ii = i - 1; ~ii; --ii) {
          if (g1[ii][j] || g2[ii][j]) break;
          res[ii][j] = 1;
        }
      }
      if (flag) res[i][j] = 1;
    }
  }
  int ans = 0;
  for (auto&& v : res) {
    for (auto&& e : v) {
      if (e) ans++;
    }
  }
  printf("%d", ans);
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define rep1(i,n) for(int i = 1 ; i <= (n) ; i++)
#define rrep(i,n) for(int i = (n) - 1 ; i >= 0 ; i--)
#define rrep1(i,n) for(int i = (n) ; i > 0 ; i--)
#define MOD 1000000007
using ll = int64_t;
using P = pair<int, int>;
using PL = pair<ll,ll>;
using PD = pair<double,double>;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vP = vector<P>;
using p_q = priority_queue<int, vi, greater<int>>;
const int INF = 1001001001;
const ll LINF = (1ll<<62) + ((1ll<<62)-1);
#define v(n) vector<n>
#define vv(n) vector<vector<n>>
#define vvv(n) vector<vector<vector<n>>>
#define p_q(n) priority_queue<(n), v(n), greater<n>>
#define line cout << "================================" << endl;
#define Yn(x) ((x) ? "Yes" : "No")
#define yn(x) ((x) ? "yes" : "no")
#define mmax(a,b) a = max(a,b)
#define mmin(a,b) a = min(a,b)
#define debug(x) cout << #x" : " << (x) << endl;
#define output(x) cout << (x) << endl;
#define outs(x) cout << #x << endl;
#define mod(n) %(n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
template <typename T> void chmin(T& a, T b){if(a>b)a=b;}
template <typename T> void chmax(T& a, T b){if(a<b)a=b;}

class alucrex{
    public:
    void vin(vi& a){rep(i,a.size())cin>>a[i];}
    void vin1(vi& a){rep1(i,a.size())cin>>a[i];}
    void vvin(vvi& a){rep(i,a.size())rep(j,a[i].size())cin>>a[i][j];}
    void vvdes(vvi& a){rep(i,a.size()){rep(j,a[i].size()){
        cout << a[i][j] << " ";}cout<<endl;
    }}
    void vinl(vl& a){rep(i,a.size())cin>>a[i];}
    void vvinl(vvl& a){rep(i,a.size())rep(j,a[i].size())cin>>a[i][j];}
    void vvdesl(vvl& a){rep(i,a.size()){rep(j,a[i].size()){
        cout << a[i][j] << " ";}cout<<endl;
    }}
    void vpin(vP& a){for(auto& x:a)cin>>x.first>>x.second;}
    template<typename T>
    void vvd(vv(T)& a){rep(i,a.size()){rep(j,a[i].size()){
        cout << a[i][j] << " ";}cout<<endl;
    }}
};

int main(){
    alucrex al;
    int a, b; cin >> a >> b;
    double ans = a * b;
	ans /= 100;
    cout << ans << endl;
}


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

const ll SEG_LEN = (1 << 20);

ll seg[SEG_LEN * 2];

void update(ll ind, ll val){
    ind += SEG_LEN;
    seg[ind] ^= val;
    while (1){
        //cout << seg[ind] << " ";
        ind /= 2;
        if (ind == 0) break;
        seg[ind] = seg[ind * 2] ^ seg[ind * 2 + 1];
    }
    // cout << endl;
}

ll XOR(int ql, int qr, int sl = 0, int sr = 1 << 20, int pos = 1){
    //被らない
    if (qr <= sl || sr <= ql) return 0;
    //完全に包まれる
    if (ql <= sl && sr <= qr) return seg[pos];
    //部分的に被る
    int sm = (sl + sr) / 2;
    ll left = XOR(ql, qr, sl, sm, pos * 2);
    ll right = XOR(ql, qr, sm, sr, pos * 2 + 1);
    return left ^ right;
}

int main(){
    int n, q;
    cin >> n >> q;
    rep(i,n) {
        ll ai;
        cin >> ai;
        update(i, ai);
    }

    // for (auto ele : seg){
    //     cout << ele << endl;
    // }

    rep(i,q){
        int ti, xi, yi;
        cin >> ti >> xi >> yi;
        if (ti == 1) update(xi-1, yi);
        if (ti == 2) {
            ll ans = XOR(xi-1, yi);
            cout << ans << endl;
        }
    }

    // for (auto ele : seg){
    //     cout << ele << endl;
    // }
}

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

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

#define debug_input cout<<"input"<<endl;freopen("input.txt","r",stdin);
#define debug_output cout<<"output"<<endl;freopen("output.txt","w",stdout);
#define debug debug_input;debug_output;

typedef double db;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

#define F first
#define S second
#define endl '\n'
#define ALL(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<(int)b;i++)
#define FORN(i,a,b) for(int i=a;i<=(int)b;i++)
#define FORB(i,a,b) for(int i=a;i>=(int)b;i--)
#define REP(i,x) FOR(i,0,x)
#define MEM(arr, x) memset(arr, (x), sizeof(arr))

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<str> vs;
typedef vector<pi> vii;
typedef vector<pl> vll;

const int MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

str x;
int ava(ll base, ll m){
    ll newVal = 0;
    for(int i=0; i< (int)x.size();i++){
        if(newVal > m / base)
            return 0;
        newVal = newVal * base + (x[i] - '0');
    }
    return newVal <= m;
}
void solve(){
    ll m;
    cin>>x>>m;

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

    int maxB = -1;
    for(int i=0; i< (int)x.size();i++)
        maxB = max(maxB, x[i] - '0');

    ll l = maxB;
    ll r = 1LL << 60;
    while(l + 1 < r){
        ll mid = (l + r) / 2;
        if(ava(mid, m))
            l = mid;
        else    r = mid;
    }
    cout<<l - maxB<<endl;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    // cout.tie(nullptr);
    // debug_output;
    // debug;

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


#include<iostream>
using namespace std;
main(){int T;cin>>T;for(int i=0;i<T;i++){int N;cin>>N;char ch;for(int j=0;j<3;j++){for(int k=0;k<2*N;k++)cin>>ch;}cout<<0;for(int k=0;k<N;k++){cout<<1;}for(int k=0;k<N;k++){cout<<0;}cout<<endl;}}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define M1 1000000007
#define M2 998244353
#define INF 1e18
#define ll  long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<int>
#define vlli vector <long long>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
/************************/
const double pi = 3.1415926535;
/************************/
//FAST IO//

/************************/

 int power(long long x, unsigned int y, int p)
{
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

const ll int  nax = 2e5 + 5;
vector<ll int > edges[nax], vis(nax, 0);
ll int p= 0;

void dfs(ll int node) {
    p++;
    vis[node] = 1;
    for(ll int x: edges[node]) {
        if(vis[x] == 0) {
            dfs(x);
        }
    }
}

int main() {

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

    ll int  n;
    cin >> n;
    vector<ll int > arr(n);
    for(ll int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for(ll int  i = 0; i < n; ++i)
    {
        edges[arr[i]].push_back(arr[n - i - 1]);
        edges[arr[n - i - 1]].push_back(arr[i]);
    }
    ll int answer = 0;
    for(ll int i = 0; i < nax; ++i) {
        if(vis[i] == 0) {
            p = 0;
            dfs(i);
            answer = answer + max(0ll, p - 1);
        }
    }
    cout << answer << endl;

   }
   return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

string P="atcoder";

void solve(){
  string S;
  cin>>S;
  int N=S.size();

  ll ans=MOD;
  ll sum=0;
  for(int k=0;k<=P.size();k++){
    if(k==P.size()){
      if(S.size()) chmin(ans,sum);
      break;
    }

    int pos=-1;
    for(int i=0;i<S.size();i++){
      if(S[i]>P[k]){
        pos=i;
        break;
      }
    }

    if(pos!=-1){
      ll res=sum+pos;
      chmin(ans,res);
    }

    int tar=-1;
    for(int i=0;i<S.size();i++){
      if(S[i]==P[k]){
        tar=i;
        break;
      }
    }
    if(tar==-1) break;
    sum+=tar;
    S.erase(S.begin()+tar);
  }

  if(ans==MOD) cout<<-1<<"\n";
  else cout<<ans<<"\n";
}

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

  int T;
  cin>>T;
  rep(i,T) solve();

  return 0;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define PB push_back
#define MP make_pair
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define INF (1 << 28)
#define LLINF (1LL << 60)
//#define MOD 998244353
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main()
{
    ll N;
    vector<ll> three, five;

    ll t = 1;
    while(t*3<=1000000000000000000){
        t *= 3;
        three.push_back(t);
    }
    t = 1;
    while (t * 5 <= 1000000000000000000)
    {
        t *= 5;
        five.push_back(t);
    }

    cin >> N;

    for (int i = 0; i < three.size();i++){
        for (int j = 0; j < five.size();j++){
            if(three[i]+five[j]==N){
                cout << i + 1 << ' ' << j + 1 << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;

    return 0;
}


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

int ans;
int A[25];

void solve(int pos, int currOr, int currXor)
{
    if (pos < 0)
    {
        ans = min(ans, (currOr ^ currXor));
        return;
    }

    solve(pos-1, (currOr | A[pos]), currXor);
    solve(pos-1, A[pos], (currXor ^ currOr));
}

int main() {

    int n;
    cin >> n;

    for (int i=0; i<n; i++)
        cin >> A[i];

    ans = (1 << 30);

    solve(n-1, 0, 0);

    cout << ans << "\n";
    return 0;
}

#include <iostream>
#include <vector>
#include <climits>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    int res = INT_MAX;

    rep(bit, (1<<(n-1))){
        vector<int> buf(n, 0);
        int count = 0;
        buf.at(count) = a.at(0);
        for(int j = 0; j < n-1; j++){
            if(bit & (1<<j)) count++;
            buf.at(count) |= a.at(j+1);
        }
        int xo = 0;
        rep(i, n) xo ^= buf.at(i);
        res = min(res, xo);
    }

    cout << res << endl;

}