#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> a){
  tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> s;
  ll tentou=0;
  REP(N){
    tentou+=s.size()-s.order_of_key(a[i]);
    s.insert(a[i]);
  }
  REP(N){
    cout<<tentou<<endl;
    tentou+=(N-a[i]-1)-a[i];
  }
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1-0+1);
    for(int i = 0 ; i < N-1-0+1 ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}

#include <bits/stdc++.h>
#define random mt19937 r(chrono::steady_clock::now().time_since_epoch().count())
#define S second
#define F first
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define pb push_back
#define all(x) x.begin(),x.end()
#define int long long 
#define txin ifstream cin("input.txt")
#define txout ofstream cout("output.txt")
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii ;

const int M = 300*1000 + 16 ;

int k[M] , a[M] ;
ll fen[M] ;
ll inv ;

ll get(int p){
    ll ans=0;
    for( ; p > 0 ; p-=p&-p){
        ans += fen[p];
    }
    return ans ;
}

void add(int p , int val){
    for( ; p < M ; p+=p&-p){
        fen[p] += val ;
    }
}

ll inversion(int n){
    ll cnt =0 ;
    for(int i=n ; i>=1 ; i--){
        add(a[i] , 1) ;
        cnt += get(a[i]-1) ;
    }
    return cnt ;
}

int32_t main(){
    FAST;
    int n ;
    cin >> n ;
    for(int i =1 ; i <= n ; i++){
        cin >> a[i] ;
        a[i] += 2;
    }
    deque<int> d ;
    for(int i =1 ; i <= n ; i++){
        d.pb(a[i]-2) ;
    }
    int inv = inversion(n) ;
    cout << inv << '\n' ;
    for(int i =1 ; i<n ; i++){
        int l = d.front() ;
        d.pop_front() ;
        d.pb(l) ;
        inv = inv - l + (n-1-l) ;
        cout << inv << '\n' ;
    }
    return 0;
}

