#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)    \
    vl v;               \
    rep(i, n)           \
    {                   \
        ll x;           \
        cin >> x;       \
        v.push_back(x); \
    }
const ll INF = 999999999999999;
const ll MOD = 998244353;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
struct segtree
{
    ll N;
    vl dat;
    void init(ll n)
    {
        N = 1;
        while (N < n)
            N *= 2;
        dat = vl(N * 2 + 1);
        for (ll i = 0; i < 2 * N - 1; i++)
            dat[i] = 0;
    }
    // update k th element
    void add(ll k, ll a)
    {
        k += N - 1; // leaf
        dat[k] += a;
        while (k > 0)
        {
            k = (k - 1) / 2;
            dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
        }
    }
    // sum of [a, b)
    ll query(ll a, ll b) { return query(a, b, 0, 0, N); }
    ll query(ll a, ll b, ll k, ll l, ll r)
    {
        if (r <= a or b <= l)
            return 0;
        if (a <= l and r <= b)
            return dat[k];
        ll m = (l + r) / 2;
        return (query(a, b, k * 2 + 1, l, m) + query(a, b, k * 2 + 2, m, r));
    }
};
int main()
{
    cin >> n;
    vl A(n);
    vl B(n);
    rep(i, n)
    {
        cin >> x;
        A[x] = i;
        B[i] = x;
    }
    reverse(all(A));
    segtree seg;

    seg.init(n);
    rep(i, n)
    {
        ans += seg.query(0, A[i]);
        seg.add(A[i], 1);
    }

    rep(i, n)
    {
        cout << ans << endl;
        ans += (n - 1) - B[i] * 2;
    }
}
#include<bits/stdc++.h>

#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define Grep(u) for(int i=head[u];i;i=e[i].nxt)

#define clear(a) memset(a,0,sizeof(a))
#define setinf(a) memset(a,0x3f,sizeof(a))
#define setninf(a) memset(a,0xcf,sizeof(a))
#define setneg1(a) memset(a,-1,sizeof(a))

#define pb push_back
#define mp std::make_pair
#define fi first
#define se second

#define yes {puts("YES");return;}
#define no {puts("NO"),return;}

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
typedef std::vector<int> vi;
typedef std::vector<ll> vl;

const int N=5e5;
const int M=1e6;
const int P=998244353;
const int inf=0x3f3f3f3f;
const int ninf=0xcfcfcfcf;
const ll llinf=0x3f3f3f3f3f3f3f3f;
const ll llninf=0xcfcfcfcfcfcfcfcf;

struct Edge{int to,nxt;}e[M*2+10];int head[N+10],tote;
inline void addEdge(int u,int v){e[++tote].to=v;e[tote].nxt=head[u];head[u]=tote;}

//struct Edge{int to,nxt,w;}e[M*2+10];int head[N+10],tote;
//inline void addEdge(int u,int v,int w){e[++tote].to=v;e[tote].w=w;e[tote].nxt=head[u];head[u]=tote;}

#define gc() char(getchar())

template<typename T>inline T read(){
	T x=0;bool f=0;char c=gc();
	while(c<'0'||c>'9')f|=c=='-',c=gc();
	while(c>='0'&&c<='9')x=x*10+c-48,c=gc();
	return f?-x:x;
}
inline int ri(){return read<int>();}
inline ll rl(){return read<ll>();}
inline ui ru(){return read<ui>();}
inline ull rul(){return read<ull>();}
inline int rstr(char*& str){
	char c=gc();int res=0;
	while(c!='\n'&&c!='\r'&&c!=' ')str[++res]=c,c=gc();
	return res;
}
inline int rline(char*& str){
	char c=gc();int res=0;
	while(c!='\n'&&c!='\r')str[++res]=c,c=gc();
	return res;
}

#undef gc

template<typename T1,typename T2>inline void chkmax(T1& a,T2 b){if(a<b)a=b;}
template<typename T1,typename T2>inline void chkmin(T1& a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2,typename T3>inline void chkmax(T1& a,T2& b,T3 c){if(c>a){b=a;a=c;}else if(c>b)b=c;}
template<typename T1,typename T2,typename T3>inline void chkmin(T1& a,T2& b,T3 c){if(c<a){b=a;a=c;}else if(c<b)b=c;}
template<typename T1,typename T2,typename T3>inline void add(T1& x,T2 y,T3 p=P){(x+=y)>=p&&(x-=p);}
template<typename T1,typename T2,typename T3>inline void mul(T1& x,T2 y,T3 p=P){x=1LL*x*y%P;}

template<typename T1,typename T2,typename T3>inline T1 qpow(T1 x,T2 y,T3 p=P){
	T1 res=T1(1);
	while(y){if(y&1)mul(res,x,p);y>>=1;mul(x,x,p);}
	return res;
}
template<typename T1,typename T2,typename T3>inline T1 qmul(T1 x,T2 y,T3 p=P){
	T1 res=T1(0);
	while(y){if(y&1)add(res,x,p);y>>=1;add(x,x,p);}
	return res;
}
template<typename T1,typename T2>inline T1 gcd(T1 x,T2 y){return !y?x:gcd(y,T2(x%y));}
template<typename T1,typename T2,typename T3>inline T1 exgcd(T1 a,T2 b,T3& x,T3& y){
	if(b==0)return x=T3(1),y=T3(0),void();
	T1 res=exgcd(b,a%b,x,y);
	T3 tmp=x;x=y;y=tmp-(a/b)*y;
	return res;
}

void solve();
int main(){
	int T;
	T=1;
//	T=ri();
	while(T--)solve();
	return 0;
}

int n,a[N+10];
int c[N+10];
ll ans=0;

#define lowbit(x) (x&(-x))
inline void modify(int i,int x){for(;i<=n;i+=lowbit(i))c[i]+=x;}
inline int query(int i){int res=0;for(;i;i-=lowbit(i))res+=c[i];return res;}
#undef lowbit

void solve(){
	n=ri();
	rep(i,1,n)a[i]=ri(),a[i]++;
	rep(i,1,n){
		ans+=query(n)-query(a[i]);
		modify(a[i],1);
	}
	printf("%lld\n",ans);
	rep(i,1,n-1){
		ans=ans+(n-a[i])-(a[i]-1);
		printf("%lld\n",ans);
	}
}
