#include<bits/stdc++.h>
using namespace std;
#define SPEED ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define READ freopen("out.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
typedef unsigned long long int ull;
ll INF=1<<28;
//typedef long long lld;
//const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
//int X[8]={0,0,1,-1,-1,1,1,-1};
int Y[8]={1,-1,0,0,-1,-1,1,1};
int knight[8][2]={1,2,1,-2,2,1,2,-1,-1,2,-1,-2,-2,1,-2,-1};
const long double EPS=1e-16;
//#define INF 10000

ll lcm(ll a,ll b)
{
    return ((a*b)/__gcd(a,b));
}
struct compare
{
  bool operator()(const pii& l, const pii& r)
  {
      if(l.ff==r.ff)
      {
          return l.sn>r.sn;
      }
      return l.ff<r.ff;
  }
};

const int mx=301050;
//const int mod=998244353;
const int mod=1e9+7;
// Including Policy Based DS
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//
//////cout<<*X.find_by_order(1)<<endl;
////cout<<X.order_of_key(-5)<<endl;

//4352348930241
//const int mod=11092019;

int arr[mx];
int tree[4*mx];
void update(int b,int e,int ind,int st,int en)
{
    if(st>e || en<b)
        return;
    if(st<=b && e<=en)
    {
        cnd=1;
        return;
    }
    update(lndp,st,en);
    update(rndp,st,en);
    cnd=lnd+rnd;
}
int query(int b,int e,int ind,int st,int en)
{
    if(st>e || en<b)
    {
        return 0;
    }
    if(st<=b && e<=en)
        return cnd;
    return query(lndp,st,en)+query(rndp,st,en);
}
int main()
{

    int t=1,tc=1;
//    sf(t);
    while(t--)
    {
        int n;
        sf(n);
        for(int i=0;i<n;i++)
        {
            sf(arr[i]);
        }
        ll ans=0;
        for(int i=n-1;i>=0;i--)
        {
            ans+=query(0,n-1,1,0,arr[i]-1);
            update(0,n-1,1,arr[i],arr[i]);
        }
        printf("%lld\n",ans);
        vector<ll>v;
        for(int i=n-1;i>=1;i--)
        {
            ans-=(n-1-arr[i]);
            ans+=(arr[i]);
            v.pb(ans);
        }
        reverse(v.begin(),v.end());
        for(int i=0;i<v.size();i++)
        {
            printf("%lld\n",v[i]);
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define FOR(i, j, k, in) for (ll i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (ll i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

void add(vector<ll> &fw, ll index) {
    index++;
    while (index <= fw.size()) {
        fw[index - 1]++;
        index += index & -index;
    }
}

ll prefix(const vector<ll> &fw, ll index) {
    ll ret = 0;
    while (index > 0) {
        ret += fw[index - 1];
        index -= index & -index;
    }

    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<ll> perm(n);
    REP(i, n)
    cin >> perm[i];
    vector<ll> forward(n), backward(n);
    // set<int> elems;
    vector<ll> fw(n + 2, 0);
    REP(i, n) {
        // int dist = distance(elems.begin(), elems.upper_bound(perm[i]));
        ll dist = prefix(fw, perm[i] + 1);
        // forward[i] = elems.size() - dist;
        forward[i] = i - dist;
        if (i != 0) forward[i] += forward[i - 1];
        // elems.insert(perm[i]);
        add(fw, perm[i] + 1);
    }
    // cout << "forward:";
    // for (const auto el : forward) cout << ' ' << el;
    // cout << endl;
    fw.clear();
    fw.resize(n + 2, 0);
    // cout << "fw:";
    // for (const auto el : fw) cout << ' ' << el;
    // cout << endl;
    RFOR(i, n - 1, 0, 1) {
        // int dist = distance(elems.begin(), elems.upper_bound(perm[i]));
        ll dist = prefix(fw, perm[i] + 1);
        backward[i] = dist;
        if (i != n - 1) backward[i] += backward[i + 1];
        // elems.insert(perm[i]);
        add(fw, perm[i] + 1);
    }
    // cout << "backward:";
    // for (const auto el : backward) cout << ' ' << el;
    // cout << endl;
    ll total = forward[n - 1];
    cout << total << endl;
    // cout << endl;
    FOR(i, 0, n - 1, 1) {
        ll possible = (i + 1) * (n - 1 - i);
        // cout << "i: " << i << endl;
        // cout << "possible: " << possible << endl;
        ll current = total - forward[i] - backward[i + 1];
        // cout << "current: " << current << endl;
        cout << possible - current + forward[i] + backward[i + 1] << endl;
        // cout << endl;
    }
    return 0;
}