//Badwaper gg
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define re register int
#define fr first
#define sd second
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define lowbit(x) x&(-x)
#define Z(x) (x>=mod?x-mod:x)
#define pa pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
ll n;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	ll l=0,r=2e9,ans=0;
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		if(mid*(mid+1)/2<=n+1)ans=mid,l=mid+1;
		else r=mid-1;
	}
	//cout<<"WTF:"<<ans<<" "<<ans*(ans+1)/2; 
	printf("%lld\n",n-ans+1);
	return 0;
}

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

//solution:
#define int int64_t
#define span(a) begin(a), end(a)

struct segtree {
  int n;
  static inline int size = 1;
  vector<int> t, lazy;
  segtree() = default;
  segtree(int n): n(n) {
    while(size < n) size <<= 1;
    t.assign(size << 1, 0);
    lazy.assign(size << 1, 0);
  }
  void push(int x, int l, int r) {
    //a[l, r] += x ---> delta = (r - l) * lazy;
    int m = l + r >> 1;
    t[2 * x + 1] += lazy[x] * (m - l);
    t[2 * x + 2] += lazy[x] * (r - m);
    lazy[2 * x + 1] += lazy[x];
    lazy[2 * x + 2] += lazy[x];
    lazy[x] = 0;
  }
  int query(int lo, int hi, int x = 0, int l = 0, int r = size) {
    if(lo >= r || l >= hi) return 0;
    if(lo <= l and r <= hi) return t[x];
    push(x, l, r);
    int m = l + r >> 1;
    return query(lo, hi, 2 * x + 1, l, m) + query(lo, hi, 2 * x + 2, m, r);
  }
  void update(int lo, int hi, int v, int x = 0, int l = 0, int r = size) {
    if(lo >= r || l >= hi) return;
    if(lo <= l and r <= hi) {
      t[x] += v * (r - l), lazy[x] += v; //remember how t[x] is updated here!
      return;
    }
    push(x, l, r);
    int m = l + r >> 1;
    update(lo, hi, v, 2 * x + 1, l, m);
    update(lo, hi, v, 2 * x + 2, m, r);
    t[x] = t[2 * x + 1] + t[2 * x + 2];
  }
};

void hike() {
  int n; cin >> n;
  vector<int> a(n);
  segtree s(n), t(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = n - 1; ~i; --i) {
    s.update(a[i], a[i] + 1, t.query(0, a[i]));
    t.update(a[i], a[i] + 1, 1);
  }
  for(int i = 0; i < n; ++i) {
    cout << s.query(0, n) << "\n";
    s.update(a[i] + 1, n, 1);
    s.update(0, a[i], -1);
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
  int t = 1; //cin >> t;
  while(t--) hike();
  return 0;
} //farewell, until we meet again..