#include<bits/stdc++.h>
using namespace std;

long long int BIT[300001],N;
 
long long int sum(int i){
  long long int s = 0;
  while(i > 0){
    s += BIT[i];
    i -= i & -i;
  }
  return s;
}
 
void add(int i,long long int x){
  while(i <= N){
    BIT[i] += x;
    i += i & -i;
  }
}

int main(){
  cin >> N;
  long long int ans = 0;
  vector<long long int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
    ans += i-sum(A[i]+1);
    add(A[i]+1,1);
  }
  cout << ans << endl;
  for(int i=0;i<N-1;i++){
    ans -= A[i];
    ans += N-1-A[i];
    cout << ans << endl;
  }
}

//In the Name of Allah Most Gracious, Most Merciful//
/*If you want something you've never had, you have  to do something you never did.*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;





#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MaxN 201007
#define INF 1e9
#define INFL 1e18
#define PI acos(-1)
#define mp make_pair
//
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move


int gcd(int a, int b)
{
 return b ? gcd(b, a%b) : a;
}

ll bigmod(ll b,ll p,ll m)
{
    ll res=1LL%m;
    ll x=b%m;
    while(p)
    {
        if( p & 1LL )res=(res*x) % m;
        x=(x*x)%m;
        p >>=1LL;
    }
    return res;
}


struct data
{
    long long l,r,val;

};


ll myfunc(ll x)
{
    ll cnt=0;
    while(x!=0)
    {
        cnt++;
        x=x/10;
    }
    return cnt-1;
}

int main()
{

   //  #ifndef ONLINE_JUDGE
   //    freopen("input.txt","r",stdin);
   //    freopen("output.txt","w",stdout);
  //   #endif

    ll n;
    cin>>n;

    map<ll,ll>cmma;
    for(int i=0;i<=15;i++)
    {
        cmma[i]=i/3;
    }
    ll x=1000;
    ll y=9999;
    ll cnt=0;
    for(int i=0;i<=15;i++)
    {
        if(n<x)
        {
            break;
        }
        ll val=(y-x+1);
        //cout<<x<<" "<<myfunc(x)<<endl;
        if(n>=y)
        {
            cnt+=(val)*cmma[myfunc(x)];
        }
        else
        {
            cnt+=(n-x+1)*cmma[myfunc(x)];
            break;
        }
        x=x*10;
        y=y*10+9;
    }
    cout<<cnt<<endl;


//#ifdef LOCAL_DEFINE
  //  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
// #endif
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1
}
