#include <iostream>
#include <string>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <set>
#include <map>
#include <cassert>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200010
#define LIMIT2 500010
#define LIMIT3 1000010
#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define ALL(a) (a).begin(),(a).end()
#define ALL2(a, n) (a),(a)+(n)
template<class T,class C> T max(T a,C b){ return std::max(a, (T)b); }
template<class T,class C> T min(T a,C b){ return std::min(a, (T)b); }
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a/gcd(a,b))*b;}
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
struct FenwickTree{
  vector<ll> bit;
  int n;
  //1-indexed BIT
  FenwickTree(int size = 200010){
    init(size);
  }
  void init(int size){
    n = size;
    bit.resize(size);
    for(int i=0;i<size;i++) bit[i]=0;
  }
  ll sum(int i){
    ll s=0;
    while(i>0){
      s += bit[i];
      i -= i&(-i);
    }
    return s;
  }
  void add(int i,ll x){
    while(i<=n){
      bit[i] += x;
      i += i&(-i);
    }
  }
  void set(int i,ll x){
    ll y = rangesum(i,i);
    x -= y;
    add(i,x);
  }
  ll rangesum(int l,int r){
    return sum(r)-sum(l-1);
  }
  int lower_bound(ll w) { // a_1 + a_2 + ... + a_x >= w となるような最小の x を求める(ただし a_i >= 0)
    if (w <= 0) {
      return 0;
    } else {
      int x = 0, r = 1;
      while (r < n) r = r << 1;
      for (int len = r; len > 0; len = len >> 1) { // 長さlenは1段下るごとに半分に
        if (x + len < n && bit[x + len] < w) { // 採用するとき
          w -= bit[x + len];
          x += len;
        }
      }
      return x + 1;
    }
  }

  int getSize(){
    return n;
  }
  ll &operator[](int k){
    static ll res;
    res = rangesum(k,k);
    return res;
  }
};

int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  string s;
  
  cin >> n;
  FenwickTree bit(n+1);
  rep(i,n){
    cin >> a[i];
  }
  per(i,n){
    result += bit.sum(a[i]+1);
    bit.add(a[i]+1,1);
  }
  rep(i,n){
    cout << result << '\n';
    
    bit.add(a[i]+1,-1);
    result -= bit.rangesum(1,a[i]+1);
    result += bit.rangesum(a[i]+1,n);
    bit.add(a[i]+1,1);
  }
  
  return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
using namespace __gnu_pbds;
using namespace std;
using ld = long double;
using ll = long long;
using indexed_set = tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update>;

int n;

int main(){
    //IO("input.txt", "output.txt");
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    deque<int> a; 
    indexed_set pre;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        int val;
        cin >> val;
        a.push_back(val);
        ans += pre.order_of_key(val);
        pre.insert(val);
    }
    int beg = a[0];
    cout << ans << '\n';
    do{
        int val = a.front();
        ans -= val, ans += (n - 1 - val);
        a.pop_front(), a.push_back(val);
        if(a.front() != beg) cout << ans << '\n';
    }while(a.front() != beg);
    return 0;
}