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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main()
{
    int i,j,n,k;
    cin>>n;
    vector<int>a(n),pos(n+1);
    for(i=0;i<n;i++){
        cin>>a[i];
        pos[a[i]]=i;
    }
    ordered_set s;
    int l=0,r=0,ele=pos[1],ans=0;
    for(i=1;i<=n;i++){
        if(i==1){
            s.insert(pos[i]);
            cout<<ans<<" ";
        }
        else{
            s.insert(pos[i]);
            int rank=s.order_of_key(pos[i]);
            if(ele>pos[i]) l++;
            else r++;
            if(l==r || l==r+1 || l+1==r){
                if(*(s.find_by_order(0))>pos[i]){
                    ans+=(ele-pos[i]-l)+i-1;
                }else if(*(s.find_by_order(i-1))<pos[i]){
                    ans+=(pos[i]-pos[ele]-r);
                }else if(ele>pos[i]){
                    ans+=(ele-pos[i]-(l-rank))-rank + i-rank-1;
                }else{
                    rank=i-rank-1;
                    ans+=(pos[i]-ele-(r-rank));
                }
            }else{
                if(l==r+2){
                    ele=*(s.find_by_order(s.order_of_key(ele)-1));
                    l--;r++;
                    if(ele==a[i])ans=ans-l;
                    else{
                        if(*(s.find_by_order(0))>pos[i]){
                            ans+=(ele-pos[i]-l)+i-1;
                        }else if(*(s.find_by_order(i-1))<pos[i]){
                            ans+=(pos[i]-pos[ele]-r);
                        }else if(ele>pos[i]){
                            ans+=(ele-pos[i]-(l-rank))-rank + i-rank-1;
                        }else{
                            rank=i-rank-1;
                            ans+=(pos[i]-ele-(r-rank));
                        }
                    }
                }else{
                    ele=*(s.find_by_order(s.order_of_key(ele)+1));
                    l++;r--;
                    if(ele==a[i])ans=ans-l;
                    else{
                        if(*(s.find_by_order(0))>pos[i]){
                            ans+=(ele-pos[i]-l)+i-1;
                        }else if(*(s.find_by_order(i-1))<pos[i]){
                            ans+=(pos[i]-pos[ele]-r);
                        }else if(ele>pos[i]){
                            ans+=(ele-pos[i]-(l-rank))-rank + i-rank-1;
                        }else{
                            rank=i-rank-1;
                            ans+=(pos[i]-ele-(r-rank));
                        }
                    }
                }
            }
            cout<<ans<<" ";
        }
    }
    cout<<endl;
    return 0;
}
    