#include <bits/stdc++.h>
#define fir first
#define sec second
#define PB push_back
#define MP make_pair
#define all(a) (a).begin(), (a).end()
#define sz(a) (a).size()

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i < (int)(n); ++i)
#define foreach(itr, c) for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); ++itr)

template <class T> void chkmax(T& x, T y) { x = (x > y ? x : y); }
template <class T> void chkmin(T& x, T y) { x = (x < y ? x : y); }

typedef long long LL;
typedef pair <int, int> pii;
typedef vector <int> vi;

const int N = 3e5 + 5;

int n, a[N * 2];

struct Fenwick {
    LL d[N];

    void init(){
        rep1(i, n + 1) d[i] = 0;
    }

    void modify(int x, int val){
        while (x <= n){
            d[x] += val;
            x += x & -x;
        }
    }

    LL query(int x){
        int ret = 0;
        while (x){
            ret += d[x];
            x -= x & -x;
        }
        return ret;
    }
} fenw;

int main(){
    scanf("%d", &n);
    rep(i, n) scanf("%d", &a[i]), a[i]++;
    LL cur = 0;
    rep(i, n){
        cur += i - fenw.query(a[i] - 1);
        fenw.modify(a[i], 1);
    }
    printf("%lld\n", cur);
    rep(i, n - 1){
        a[i + n] = a[i];
        fenw.modify(a[i], -1);
        cur -= a[i] - 1;
        cur += n - a[i];
        printf("%lld\n", cur);
    }
    return 0;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define line cout<<"--------------------------"<<endl
#define dd(x) cout<<#x<<" = "<<x<<' '
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
using namespace __gnu_pbds;
template <typename T> using os=tree < T, null_type ,less<T>, rb_tree_tag,tree_order_statistics_node_update >;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mx=300009;
ll big[mx],small[mx]; 
int main()
{
    ll n; 
    cin>>n; 
    vector<ll>v(n);
    for(ll i=0;i<n;i++) cin>>v[i]; 
    os<ll>s; 
    ll ans=0; 
    for(ll i=n-1;i>=0;i--)
    {
        ll a=v[i]; 
        ll sm=s.order_of_key(a);
        ans+=sm; 
        s.insert(a);
    }
    for(ll i=0;i<n;i++)
    {
        cout<<ans<<endl; 
        ans+=n-v[i]-1-v[i];
    }
}
		