#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll inv[ 100005 ] = { 0 } ;
ll query( ll * tree,ll ss,ll se,ll qs,ll qe ,ll index)
{
//complete overlap
if ( ss>= qs and se<= qe)
{
return tree[ index] ;
}
//No Overlap
if ( qe< ss || qs> se)
return 0 ;
//partial overlap
ll int mid = ( ss + se) / 2 ;
ll int left = query( tree,ss,mid,qs,qe,2 * index) ;
ll int right = query( tree,mid+ 1 ,se,qs,qe,2 * index+ 1 ) ;
return left+ right;
}
//point update
void point_update( ll * tree, ll ss,ll se, ll i,ll inc,ll index)
{
if ( i> se || i< ss)
return ;
if ( ss == se)
{
tree[ index] + = inc;
return ;
}
ll int mid = ( ss + se) / 2 ;
point_update( tree,ss,mid,i,inc,2 * index) ;
point_update( tree,mid+ 1 ,se,i,inc,2 * index+ 1 ) ;
tree[ index] = tree[ 2 * index] + tree[ 2 * index+ 1 ] ;
return ;
}
//
void solve( )
{
int n;
cin >> n;
ll a[ n+ 1 ] = { 0 } ;
for ( int i= 1 ; i<= n; i++ )
cin >> a[ i] ;
ll tree[ 4 * n+ 1 ] = { 0 } ;
for ( int i= 1 ; i<= n; i++ )
{
int x = query( tree,1 ,n,a[ i] + 1 ,n,1 ) ;
inv[ a[ i] ] + = x;
point_update( tree,1 ,n,a[ i] ,1 ,1 ) ;
}
for ( int i= 1 ; i<= n; i++ )
cout << inv[ a[ i] ] << " " ;
return ;
}
int main( )
{
ios_base:: sync_with_stdio ( false ) ;
cin .tie ( NULL ) ;
ll int t= 1 ;
// cin>>t;
while ( t-- )
{
solve( ) ;
}
return 0 ;
}
CiNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGxsIGxvbmcgbG9uZwoKbGwgaW52WzEwMDAwNV09ezB9OwoKbGwgcXVlcnkobGwgKnRyZWUsbGwgc3MsbGwgc2UsbGwgcXMsbGwgcWUgLGxsIGluZGV4KQp7CgkvL2NvbXBsZXRl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