#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_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long int
#define endl "\n"
#define MOD 1000000007
#define mod 1000000007
#define M 1000000007
#define pb push_back
#define take(a,b,c) for(int b=0;b<c;b++) cin>>a[b]
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mx 1000005
#define fiint(a,b) memset(a,b,sizeof(a))
#define bitcount __builtin_popcount
#define fori(i,a,b) for(int i=a;i<b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cout<<x<<endl;
#define cases(t) int t; cin>>t; while(t--)
#define inf1 INT_MAX
#define all(a) a.begin(),a.end()
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<int,int>
#define pint pair<int,int>
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mp make_pair
 
#define sz(x) (int)x.size()
#define PI    3.14159265359
 
 
 
int factorial[10000001]={0};
 
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


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

void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
    factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
 
int nCr(int n, int r)
{
    if(r < 0 || r > n){
        return 0;
    }
    int temp = factorial[n];
    temp *= (powerFunction(factorial[r], MOD-2)%MOD);
    temp %= MOD;
    temp *= (powerFunction(factorial[n-r], MOD-2)%MOD);
    temp %= MOD;
    return temp;
}

vec tree(5*300005);

int up(int node,int l ,int r , int idx , int v)
{

    if(l == r)
    {
        tree[node] = v;
        return tree[node];
    }
    
    int mid  = (l + r )/2;
    if(idx <= mid  )
    up(node*2 ,l , mid , idx , v  );
    else
    up(node*2 + 1 , mid + 1 , r , idx , v );
    tree[node] = tree[node*2] + tree[2*node + 1];
    return tree[node];
}

int sum(int node,int st , int en , int l ,int r )
{
    if(en < l || r < st)
        return 0;
    if(st >= l && en <= r)
        return tree[node];
    int mid = (st + en)/2;
    return sum(node*2,st , mid , l , r ) + sum(node*2 + 1, mid + 1 , en , l , r) ;
}

signed main()
{
    int n;cin>>n;
    //vec ans;
    vec v(n+1);
    int ans = 0 ;
    for(int i = 0 ; i < n;i++)
    {
        cin>>v[i];
        ans += sum(1,0,n-1,v[i],n);
        up(1, 0, n-1, v[i], 1);
    }
    for(int i = 0 ; i < n ;i++)
    {
        cout<<ans<<endl;
        ans += n -1 - v[i]*2;
    }
    
    
    
}
    



#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

// 1-indexed
const int N = 1000010;
vector<ll> bit(N);
// a[p] += x
void add(int p, int x) {
  for (int i = p; i <= N; i += i & -i) {
    bit[i] += x;
  }
}
// a[1] + a[2] + ... + a[p]
ll sum(int p) {
  ll res = 0;
  for (int i = p; i > 0; i -= i & -i) {
    res += bit[i];
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i]++;
  }
  ll cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += i - sum(a[i]);
    add(a[i], 1);
  }
  cout << cnt << endl;
  for (int i = 1; i <= n - 1; ++i) {
    cnt += n - 2 * a[i - 1] + 1;
    cout << cnt << endl;
  }
  return 0;
}