#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#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 <sstream>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define V vector
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F first
#define S second
#define sqr(x) (x)*(x)
#define mp make_pair
#define mtp make_tuple
#define tpii tuple<int,int,int>
#define rep(n) for(int i=0;i<n;i++)
#define inf INT_MAX
#define debug(x) cerr<<x<<'\n';
#define sz(x) (int)((x).size())
#define int long long
#define ull unsigned long long
#define quick ios_base::sync_with_stdio(0),cin.tie(0);long double nownow=clock();
#define total_time cerr<<(clock()-nownow)/CLOCKS_PER_SEC*1000<<" (ms)\n";
using namespace std;
int gcd(int a,int b){return (a%b?gcd(b,a%b):b);}
template<typename T>void in(vector<T> &a){for(auto &i:a)cin>>i;}
template<typename T>void out(vector<T> &a){for(auto &i:a)cout<<i<<' ';cout<<'\n';}
template<typename T>void out(multiset<T> &a){for(auto i:a)cout<<i<<' ';cout<<'\n';}
template<typename T>void out(set<T> &a){for(auto i:a)cout<<i<<' ';cout<<'\n';}
#define yn(x) cout<<((x)?"Yes\n":"No\n");
#define YN(x) cout<<((x)?"YES\n":"NO\n");
#define mod (int)(1e9+7)

int n;
int bit[300001];
void update(int x){
    while(x<=n){
        bit[x]++;
        x+=x&(-x);
    }
}
int query(int x){
    int sum=0;
    while(x){
        sum+=bit[x];
        x-=x&(-x);
    }
    return sum;
}

signed main(){
    quick
    cin>>n;
    vi a(n);
    int last=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        last+=query(n)-query(a[i]+1);
        update(a[i]+1);
    }
    for(int i=0;i<n;i++){
        cout<<last<<'\n';
        last+=n-a[i]*2-1;
    }
    total_time
    return 0;
}

#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
#define deb(x) cout << #x": " << (x) << endl;

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}
lli lcm(lli a, lli b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
int popcount(lli x) { return __builtin_popcountll(x); }

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int rnd(int n){return uniform_int_distribution<int>(0, n-1)(rng);}

lli poww(lli a, lli b){
	lli res =1;
	while(b){ if(b&1) res = res * a; a = a*a; b/=2; }
	return res;
}

vvc<int> graph(int n, int m, bool dir=1){
	vv(int,v,n+1,0);
	fore(i,0,m){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		if(dir)v[b].pb(a);
	}
	return v;
}
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
// ---- コーディングはここから！ ('-')7
using T = array<lli,2>;
T ini = {0,0}, bad = {0,0};
using L = lli;
L nulo = 0;

struct LazyST{
  #define mid (l + r)/2
  #define left(u) (u + 1)
  #define right(u) (u + ((mid - l + 1) << 1))
  vector<T>st;
  vector<L>lazy;

  T op(T a, T b){return T{a[0]+b[0],a[1]+b[1]}; } // operacion de merge
  T cmp(T a, T b){return T{a[0]+b[0],a[1]+b[1]}; } //operacion en query


  LazyST(int n):st(2*n,ini), lazy(2*n,nulo){}

  void push(int u, int l, int r){
    if(l<r and lazy[u]!=nulo){
      st[left(u)][1] += (mid-l+1)*lazy[u];
      st[right(u)][1] += (r-mid)*lazy[u];
      lazy[left(u)] += lazy[u];
      lazy[right(u)]+= lazy[u];
      lazy[u]= nulo;
    }
  }

  void update(int u, int l, int r, int ll, int rr, lli x){
    push(u, l, r);
    if(r < ll or l > rr or l>r) return;
    if(ll <= l and r <= rr){
			if(ll==rr)st[u][0]=1;
      st[u][1]+=(r-l+1)*x;
			lazy[u]=x;
      return;
    }
    update(left(u), l, mid, ll, rr, x);
    update(right(u), mid + 1, r, ll, rr, x);
    st[u] = op(st[left(u)],st[right(u)]);
  }

  T query(int u, int l, int r, int ll, int rr){
    push(u, l, r);
    if(r < ll or l > rr or l>r) return bad;
    if(ll <= l and r <= rr)return st[u];
    return cmp(query(left(u),l,mid,ll,rr),query(right(u),mid+1,r,ll,rr));
  }
};



void solve(){
	int n; cin>>n;
	LazyST st(n);
	vi v(n); fore(i,0,n)cin>>v[i];
	for(int i = n-1;i>=0;i--){
		int a = v[i];
		auto q1 = st.query(0,0,n-1,0,a);
		st.update(0,0,n-1,a,a,q1[0]);  // menores a la derecha de mi.
	}
	cout<<st.query(0,0,n-1,0,n-1)[1]<<ENDL;
	fore(i,0,n-1){
		int a = v[i];
		auto q2 = st.query(0,0,n-1,a,a);
		st.update(0,0,n-1,a,a,-q2[1]);
		if(a!=n-1)st.update(0,0,n-1,a+1,n-1,1);
		cout<<st.query(0,0,n-1,0,n-1)[1]<<ENDL;
	}
}

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