#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
//#define vec vector<ll>
//#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
const ll inf=INF*INF;
const ll mod=INF;
const ll MAX=200010;
const double PI=acos(-1.0);


//dijkstra(O(ElogV))
//0-indexed
void dijkstra(ll n,ll s,vector<vector<pll> >&G,vector<ll> &d){
    priority_queue<pll,vector<pll>,greater<pll> >pq;
    rep(i,n){
        d[i]=inf;
    }
    d[s]=0;
    pq.push(mp(0,s));
    while(!pq.empty()){
        pll k=pq.top();pq.pop();
        ll v=k.second;
        if(d[v]<k.first)continue;
        for(auto e:G[v]){
            if(e.fi<0)continue;
            if(d[e.first]>d[v]+e.second){
                d[e.first]=d[v]+e.second;
                pq.push(mp(d[e.first],e.first));
            }
        }
    }
}

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};



signed main(){
    int n=30;
    int N=n*n;
    int T=1000;
    vector<vector<pll> >G(N);
    
    rep(i,n){
        rep(j,n){
            ll v=i*n+j;
            rep(k,4){
                ll nx=i+dx[k],ny=j+dy[k];
                ll nv=nx*n+ny;
                ll x=1;
                if(nx<0||nx>=n||ny<0||ny>=n){
                    G[v].pb(mp(-1,x));
                }else{
                    G[v].pb(mp(nv,x));
                }
            }
        }
    }
    vector<ll>dist(N);
    while(T--){
        ll a,b,c,d;cin>>a>>b>>c>>d;
        string res="";
        ll s=a*n+b,t=c*n+d;
        ll nxt=t;
        dijkstra(N,s,G,dist);
        ll x=dist[t];
        vector<ll>used(N);
        while(nxt!=s){
            used[nxt]=1;
            ll idx=-1;
            rep(i,N){
                if(used[i])continue;
                ll c=inf;
                for(auto e:G[i]){
                    if(e.fi==nxt)c=e.se;
                }
                if(dist[i]+c==dist[nxt])idx=i;
            }
            if(nxt-idx==1){
                res+='R';
            }
            if(nxt-idx==-1){
                res+='L';
            }
            if(nxt-idx==n){
                res+='D';
            }
            if(nxt-idx==-n){
                res+='U';
            }
            nxt=idx;
        }
        reverse(all(res));
        cout<<res<<endl;
        ll score;cin>>score;
        ll mean=score/(ll)res.size();
        rep(i,res.size()){
            if(res[i]=='R'){
                G[s][0].se=mean;
                G[s+1][2].se=mean;
                s++;
            }
            if(res[i]=='L'){
                G[s][2].se=mean;
                G[s-1][0].se=mean;
                s--;
            }
            if(res[i]=='U'){
                G[s][3].se=mean;
                G[s-n][1].se=mean;
                s-=n;
            }
            if(res[i]=='D'){
                G[s][1].se=mean;
                G[s+n][3].se=mean;
                s+=n;
            }
        }
    }
}
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using ld=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
using vp=vector<P>;
using vvp=vector<vp>;
const int inf=1e9+7;
const ll INF=9e18/2;
const long double PI = acosl(-1.0); 
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

template<typename T>
struct BIT{
    int N;
    vector<T> dat;
    BIT(int siz):N(siz+1),dat(siz+1,0){}

    void add(int i,T x){
        for(int idx=i;idx<N;idx+=(idx & -idx)){
            dat[idx]+=x;
        }
    }

    T sum(int i){
        T res=0;
        for(int idx=i;idx>0;idx-=(idx & -idx)){
            res+=dat[idx];
        }
        return res;
    }
};

int main(){//cout<<fixed<<setprecision(20);
  long long n;
  cin>>n;
  BIT<long long> bit(n);
  vll a(n);
  rep(i,0,n)cin>>a[i];
  ll ans=0;
  rep(i,0,n){
    a[i]++;
    ans+=bit.sum(n)-bit.sum(a[i]);
    bit.add(a[i],1);
  }
  cout<<ans<<endl;
  rep(i,0,n-1){
    ans+=n+1-2*a[i];
    cout<<ans<<endl;
  }
}