import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        KIntegers solver = new KIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class KIntegers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            ArrayList<Integer> arr = new ArrayList<>();
            int[] p = new int[N];
            FenwickTree invert = new FenwickTree(N);
            for (int i = 0; i < N; i++) {
                p[i] = in.nextInt();
                arr.add(i);
            }
            Collections.sort(arr, new Comparator<Integer>() {

                public int compare(Integer integer, Integer t1) {
                    return Integer.compare(p[integer], p[t1]);
                }
            });
            long res = 0;
            FenwickTree sum = new FenwickTree(N);
            for (long i = 1; i <= N; i++) {
                int nextInd = arr.get((int) (i - 1));
                res += invert.sum(nextInd, N - 1);
                sum.add(nextInd, nextInd);
                invert.add(nextInd, 1);
                int mid = getMid(invert);
                if ((i) % 2 == 1) {
                    out.println(res - sum.sum(0, mid - 1) + sum.sum(mid + 1, N - 1) - ((i / 2) * (i / 2 + 1)));
                } else {
                    out.println(res + mid * (i / 2) - sum.sum(0, mid - 1) + sum.sum(mid + 1, N - 1) - mid * ((i - 1) / 2) - ((i / 2) * (i / 2 + 1)) / 2 - (((i - 1) / 2) * ((i - 1) / 2 + 1)) / 2);
                }
            }
        }

        public int getMid(FenwickTree tree) {
            int low = 0;
            int high = tree.size - 1;
            while (low < high) {
                int mid = (low + high + 1) / 2;
                if (tree.sum(mid - 1) <= tree.sum(tree.size - 1) / 2) {
                    low = mid;
                } else {
                    high = mid - 1;
                }
            }
            return high;
        }

        public class FenwickTree {
            public long[] BIT;
            public int size = 0;

            public FenwickTree(int N) {
                BIT = new long[N];
                size = N;
            }

            public void add(int id, int add) {
                for (int i = id; i < size; i |= i + 1) {
                    BIT[i] += add;
                }
            }

            public long sum(int l, int r) {
                return sum(r) - sum(l - 1);
            }

            public long sum(int r) {
                if (r < 0 || r >= size) {
                    return 0;
                }
                long res = 0;
                for (int i = r; i >= 0; i = ((i) & (i + 1)) - 1) {
                    res += BIT[i];
                }
                return res;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import javax.print.attribute.standard.PrinterMessageFromOperator;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        new Main().run();}

    static int groups = 0;
    static int[] fa;
    static int[] sz;

    static void init1(int n) {
        groups = n;
        fa = new int[n];
        for (int i = 1; i < n; ++i) {
            fa[i] = i;
        }
        sz = new int[n];
        Arrays.fill(sz, 1);
    }

    static int root(int p) {
        while (p != fa[p]) {
            fa[p] = fa[fa[p]];
            p = fa[p];
        }
        return p;
    }

    static void combine(int p, int q) {
        int i = root(p);
        int j = root(q);
        if (i == j) {
            return;
        }
        if (sz[i] < sz[j]) {
            fa[i] = j;
            sz[j] += sz[i];
        } else {
            fa[j] = i;
            sz[i] += sz[j];
        }
        groups--;
    }

    public static String roundS(double result, int scale){
        String fmt = String.format("%%.%df", scale);
        return String.format(fmt, result);
    }

    int[] unique(int a[]){
        int p = 1;
        for(int i=1;i<a.length;++i){
            if(a[i]!=a[i-1]){
                a[p++] = a[i];
            }
        }
        return Arrays.copyOf(a,p);
    }
    public static int eq_bigger(int[] a, int key) {
        return eq_bigger(a,0,a.length,key);
    }

    public static int eq_bigger(int[] a, int lo, int hi,
                                int key) {
        while (lo < hi) {
            int mid = (lo + hi) >>> 1;
            if (a[mid] < key) {
                lo = mid + 1;
            }else {
                hi = mid;
            }
        }
        return lo;
    }

    public static int bigger(int[] a, int key) {
        return bigger(a,0,a.length,key);
    }

    public static int bigger(int[] a, int lo, int hi,
                             int key) {
        while (lo < hi) {
            int mid = (lo + hi) >>> 1;
            if (a[mid] > key) {
                hi = mid;
            }else {
                lo = mid+1;
            }
        }
        return lo;
    }

    void solve() {

        //N , M , K , a , b , c , d . 其中N , M是矩阵的行列数；K 是上锁的房间数目，(a, b)是起始位置，(c, d)是出口位置

//        int n = ni();
//        int m = ni();
//        int k = ni();
//        int a = ni();
//        int b = ni();
//        int c = ni();
//        int d = ni();
//
//
//        char cc[][] = nm(n,m);
//        char keys[][] = new char[n][m];
//
//        char ky = 'a';
//        for(int i=0;i<k;++i){
//            int x = ni();
//            int y = ni();
//            keys[x][y] = ky;
//            ky++;
//        }
//        int f1[] = {a,b,0};
//
//        int dd[][] = {{0,1},{0,-1},{1,0},{-1,0}};
//
//        Queue<int[]> q =  new LinkedList<>();
//        q.offer(f1);
//        int ts = 1;
//
//        boolean vis[][][] = new boolean[n][m][33];
//
//        while(q.size()>0){
//            int sz = q.size();
//            while(sz-->0) {
//                int cur[] = q.poll();
//                vis[cur[0]][cur[1]][cur[2]] = true;
//
//                int x = cur[0];
//                int y = cur[1];
//
//                for (int u[] : dd) {
//                       int lx = x +  u[0];
//                       int ly = y +  u[1];
//                       if (lx >= 0 && ly >= 0 && lx < n && ly < m && (cc[lx][ly] != '#')&&!vis[lx][ly][cur[2]]){
//                            char ck =cc[lx][ly];
//                            if(ck=='.'){
//                                if(lx==c&&ly==d){
//                                    println(ts); return;
//                                }
//                                if(keys[lx][ly]>='a'&&keys[lx][ly]<='z') {
//                                    int cao = cur[2] | (1 << (keys[lx][ly] - 'a'));
//                                    q.offer(new int[]{lx, ly, cao});
//                                    vis[lx][ly][cao] = true;
//                                }else {
//
//                                    q.offer(new int[]{lx, ly, cur[2]});
//                                }
//
//                            }else if(ck>='A'&&ck<='Z'){
//                                int g = 1<<(ck-'A');
//                                if((g&cur[2])>0){
//                                    if(lx==c&&ly==d){
//                                        println(ts); return;
//                                    }
//                                    if(keys[lx][ly]>='a'&&keys[lx][ly]<='z') {
//
//                                        int cao = cur[2] | (1 << (keys[lx][ly] - 'a'));
//                                        q.offer(new int[]{lx, ly, cao});
//                                        vis[lx][ly][cao] = true;;
//                                    }else {
//
//                                        q.offer(new int[]{lx, ly, cur[2]});
//                                    }
//                                }
//                            }
//                       }
//                }
//
//                }
//            ts++;
//        }
//        println(-1);

//        int n = ni();
//
//        HashSet<String> st = new HashSet<>();
//        HashMap<String,Integer> mp = new HashMap<>();
//
//
//        for(int i=0;i<n;++i){
//            String s  = ns();
//            int id= 1;
//            if(mp.containsKey(s)){
//                int u = mp.get(s);
//                id = u;
//
//            }
//
//            if(st.contains(s)) {
//
//                while (true) {
//                    String ts = s + id;
//                    if (!st.contains(ts)) {
//                        s = ts;
//                        break;
//                    }
//                    id++;
//                }
//                mp.put(s,id+1);
//            }else{
//                mp.put(s,1);
//            }
//            println(s);
//            st.add(s);
//
//        }

//        int t = ni();
//
//        for(int i=0;i<t;++i){
//            int n = ni();
//            long w[] = nal(n);
//
//            Map<Long,Long> mp = new HashMap<>();
//            PriorityQueue<long[]> q =new PriorityQueue<>((xx,xy)->{return Long.compare(xx[0],xy[0]);});
//
//            for(int j=0;j<n;++j){
//                q.offer(new long[]{w[j],0});
//                mp.put(w[j],mp.getOrDefault(w[j],0L)+1L);
//            }
//
//            while(q.size()>=2){
//                long f[] = q.poll();
//                long y1 = f[1];
//                if(y1==0){
//                    y1 = mp.get(f[0]);
//                    if(y1==1){
//                        mp.remove(f[0]);
//                    }else{
//                        mp.put(f[0],y1-1);
//                    }
//                }
//                long g[] = q.poll();
//                long y2 = g[1];
//                if(y2==0){
//                    y2 = mp.get(g[0]);
//                    if(y2==1){
//                        mp.remove(g[0]);
//                    }else{
//                        mp.put(g[0],y2-1);
//                    }
//                }
//                q.offer(new long[]{f[0]+g[0],2L*y1*y2});
//
//            }
//            long r[] = q.poll();
//            println(r[1]);
//
//
//
//
//        }
        //  int o= 9*8*7*6;
        //  println(o);

//       int t = ni();
//       for(int i=0;i<t;++i){
//           long a = nl();
//           int k  = ni();
//           if(k==1){
//               println(a);
//               continue;
//           }
//
//           int f = (int)(a%10L);
//           int s = 1;
//           int j = 0;
//           for(;j<30;j+=2){
//               int u = f-j;
//               if(u<0){
//                   u = 10+u;
//               }
//               s = u*s;
//               s = s%10;
//               if(s==k){
//                   break;
//               }
//           }
//
//           if(s==k) {
//               println(a - j - 2);
//           }else{
//               println(-1);
//           }
//
//
//
//
//       }
        int n = ni();
        t1 = new long[n+1];
        t2 = new long[n+1];
        int p[] = new int[n+1];
        int c[] = new int[n+1];
        for(int i=1;i<=n;++i){
            p[i] = ni();
            c[p[i]] = i;
        }

        long s = 0;
        long nx = 0;
        for(int i=1;i<=n;++i){
            int w = c[i];
            long cnm = 0;
            nx += i-1-get(t1, w);
            cnm  = nx;
            update(t1 , w, 1);
            int ck = (i+1)/2;
            int pos = equal_bigger(t1, ck);
            update(t2 , w, w);
            long s1 = get(t2, pos-1);
            s += w;
            long s2 = s-s1-pos;

            cnm -= s1;
            cnm += s2;

            long left = ck-1;
            long right = i-ck;
            cnm += left*pos-(left)*(left+1)/2L;
            cnm -= right*pos+(right)*(right+1)/2L;

            print(cnm);
            if(i!=n){
                print(" ");
            }
        }

    }

    long t1[];
    long t2[];
    void update(long[] t,int i,long v){
        for(;i<t.length;i+=(i&-i)){
            t[i] += v;
        }
    }
    long get(long[] t,int i){
        long s = 0;
        for(;i>0;i-=(i&-i)){
            s += t[i];
        }
        return s;
    }

    int equal_bigger(long t[],long v){
        int s=0,p=0;
        for(int i=Integer.numberOfTrailingZeros(Integer.highestOneBit(t.length));i>=0;--i) {
            if(p+(1<<i)< t.length && s + t[p+(1<<i)] <v){
                v -= t[p+(1<<i)];
                p |= 1<<i;
            }
        }
        return p+1;
    }

    static class S{
        int l = 0;
        int r = 0 ;
        long le = 0;
        long ri = 0;
        long tot = 0;
        long all = 0;

        public S(int l,int r) {
            this.l = l;
            this.r = r;
        }
    }

    static S a[];
    static int[] o;

    static void init(int[] f){
        o = f;
        int len = o.length;
        a = new S[len*4];
        build(1,0,len-1);
    }

    static void build(int num,int l,int r){
        S cur = new S(l,r);
        if(l==r){
            a[num] = cur;
            return;
        }else{
            int m = (l+r)>>1;
            int le = num<<1;
            int ri = le|1;
            build(le, l,m);
            build(ri, m+1,r);
            a[num] = cur;
            pushup(num, le, ri);
        }
    }

    //    static int query(int num,int l,int r){
//
//        if(a[num].l>=l&&a[num].r<=r){
//            return a[num].tot;
//        }else{
//            int m = (a[num].l+a[num].r)>>1;
//            int le = num<<1;
//            int ri = le|1;
//            pushdown(num, le, ri);
//            int ma = 1;
//            int mi = 100000001;
//            if(l<=m) {
//                int r1 = query(le, l, r);
//                ma = ma*r1;
//
//            }
//            if(r>m){
//                int r2 = query(ri, l, r);
//                ma = ma*r2;
//            }
//            return ma;
//        }
//    }
    static long dd = 10007;
    static void update(int num,int l,long v){
        if(a[num].l==a[num].r){
            a[num].le = v%dd;
            a[num].ri = v%dd;
            a[num].all = v%dd;
            a[num].tot = v%dd;
        }else{
            int m = (a[num].l+a[num].r)>>1;
            int le = num<<1;
            int ri = le|1;
            pushdown(num, le, ri);
            if(l<=m){
                update(le,l,v);
            }
            if(l>m){
                update(ri,l,v);
            }
            pushup(num,le,ri);
        }
    }

    static void pushup(int num,int le,int ri){
        a[num].all = (a[le].all*a[ri].all)%dd;
        a[num].le = (a[le].le + a[le].all*a[ri].le)%dd;
        a[num].ri = (a[ri].ri + a[ri].all*a[le].ri)%dd;
        a[num].tot = (a[le].tot + a[ri].tot + a[le].ri*a[ri].le)%dd;

        //a[num].res[1] = Math.min(a[le].res[1],a[ri].res[1]);
    }
    static void pushdown(int num,int le,int ri){

    }

    int gcd(int a,int b){ return b==0?a: gcd(b,a%b);}
    InputStream is;PrintWriter out;
    void run() throws Exception {is = System.in;out = new PrintWriter(System.out);solve();out.flush();}
    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;
    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {lenbuf = is.read(inbuf);} catch (IOException e) {throw new InputMismatchException();}
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];}
    private boolean isSpaceChar(int c) {return !(c >= 33 && c <= 126);}
    private int skip() {int b;while((b = readByte()) != -1 && isSpaceChar(b));return b;}
    private double nd() {return Double.parseDouble(ns());}
    private char nc() {return (char) skip();}
    private char ncc() {int b;while((b = readByte()) != -1 && !(b >= 32 && b <= 126));return (char)b;}
    private String ns() {int b = skip();StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);b = readByte(); }
        return sb.toString();}
    private char[] ns(int n) {char[] buf = new char[n];int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) { buf[p++] = (char) b;b = readByte(); }
        return n == p ? buf : Arrays.copyOf(buf, p);}
    private String nline() {int b = skip();StringBuilder sb = new StringBuilder();
        while (!isSpaceChar(b) || b == ' ') { sb.appendCodePoint(b);b = readByte(); }
        return sb.toString();}
    private char[][] nm(int n, int m) {char[][] a = new char[n][];for (int i = 0; i < n; i++) a[i] = ns(m);return a;}
    private int[] na(int n) {int[] a = new int[n];for (int i = 0; i < n; i++) a[i] = ni();return a;}
    private long[] nal(int n) { long[] a = new long[n];for (int i = 0; i < n; i++) a[i] = nl();return a;}
    private int ni() { int num = 0, b; boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')){};
        if (b == '-') { minus = true; b = readByte(); }
        while (true) {
            if (b >= '0' && b <= '9') num = (num << 3) + (num << 1) + (b - '0');
            else return minus ? -num : num;
            b = readByte();}}
    private long nl() { long num = 0; int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')){};
        if (b == '-') { minus = true; b = readByte(); }
        while (true) {
            if (b >= '0' && b <= '9')  num = num * 10 + (b - '0');
            else return minus ? -num : num;
            b = readByte();}}
    void print(Object obj){out.print(obj);}
    void println(Object obj){out.println(obj);}
    void println(){out.println();}
}


import javax.print.attribute.standard.PrinterMessageFromOperator;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        new Main().run();}

    static int groups = 0;
    static int[] fa;
    static int[] sz;

    static void init1(int n) {
        groups = n;
        fa = new int[n];
        for (int i = 1; i < n; ++i) {
            fa[i] = i;
        }
        sz = new int[n];
        Arrays.fill(sz, 1);
    }

    static int root(int p) {
        while (p != fa[p]) {
            fa[p] = fa[fa[p]];
            p = fa[p];
        }
        return p;
    }

    static void combine(int p, int q) {
        int i = root(p);
        int j = root(q);
        if (i == j) {
            return;
        }
        if (sz[i] < sz[j]) {
            fa[i] = j;
            sz[j] += sz[i];
        } else {
            fa[j] = i;
            sz[i] += sz[j];
        }
        groups--;
    }

    public static String roundS(double result, int scale){
        String fmt = String.format("%%.%df", scale);
        return String.format(fmt, result);
    }

    int[] unique(int a[]){
        int p = 1;
        for(int i=1;i<a.length;++i){
            if(a[i]!=a[i-1]){
                a[p++] = a[i];
            }
        }
        return Arrays.copyOf(a,p);
    }
    public static int eq_bigger(int[] a, int key) {
        return eq_bigger(a,0,a.length,key);
    }

    public static int eq_bigger(int[] a, int lo, int hi,
                                int key) {
        while (lo < hi) {
            int mid = (lo + hi) >>> 1;
            if (a[mid] < key) {
                lo = mid + 1;
            }else {
                hi = mid;
            }
        }
        return lo;
    }

    public static int bigger(int[] a, int key) {
        return bigger(a,0,a.length,key);
    }

    public static int bigger(int[] a, int lo, int hi,
                             int key) {
        while (lo < hi) {
            int mid = (lo + hi) >>> 1;
            if (a[mid] > key) {
                hi = mid;
            }else {
                lo = mid+1;
            }
        }
        return lo;
    }

    void solve() {

        //N , M , K , a , b , c , d . 其中N , M是矩阵的行列数；K 是上锁的房间数目，(a, b)是起始位置，(c, d)是出口位置

//        int n = ni();
//        int m = ni();
//        int k = ni();
//        int a = ni();
//        int b = ni();
//        int c = ni();
//        int d = ni();
//
//
//        char cc[][] = nm(n,m);
//        char keys[][] = new char[n][m];
//
//        char ky = 'a';
//        for(int i=0;i<k;++i){
//            int x = ni();
//            int y = ni();
//            keys[x][y] = ky;
//            ky++;
//        }
//        int f1[] = {a,b,0};
//
//        int dd[][] = {{0,1},{0,-1},{1,0},{-1,0}};
//
//        Queue<int[]> q =  new LinkedList<>();
//        q.offer(f1);
//        int ts = 1;
//
//        boolean vis[][][] = new boolean[n][m][33];
//
//        while(q.size()>0){
//            int sz = q.size();
//            while(sz-->0) {
//                int cur[] = q.poll();
//                vis[cur[0]][cur[1]][cur[2]] = true;
//
//                int x = cur[0];
//                int y = cur[1];
//
//                for (int u[] : dd) {
//                       int lx = x +  u[0];
//                       int ly = y +  u[1];
//                       if (lx >= 0 && ly >= 0 && lx < n && ly < m && (cc[lx][ly] != '#')&&!vis[lx][ly][cur[2]]){
//                            char ck =cc[lx][ly];
//                            if(ck=='.'){
//                                if(lx==c&&ly==d){
//                                    println(ts); return;
//                                }
//                                if(keys[lx][ly]>='a'&&keys[lx][ly]<='z') {
//                                    int cao = cur[2] | (1 << (keys[lx][ly] - 'a'));
//                                    q.offer(new int[]{lx, ly, cao});
//                                    vis[lx][ly][cao] = true;
//                                }else {
//
//                                    q.offer(new int[]{lx, ly, cur[2]});
//                                }
//
//                            }else if(ck>='A'&&ck<='Z'){
//                                int g = 1<<(ck-'A');
//                                if((g&cur[2])>0){
//                                    if(lx==c&&ly==d){
//                                        println(ts); return;
//                                    }
//                                    if(keys[lx][ly]>='a'&&keys[lx][ly]<='z') {
//
//                                        int cao = cur[2] | (1 << (keys[lx][ly] - 'a'));
//                                        q.offer(new int[]{lx, ly, cao});
//                                        vis[lx][ly][cao] = true;;
//                                    }else {
//
//                                        q.offer(new int[]{lx, ly, cur[2]});
//                                    }
//                                }
//                            }
//                       }
//                }
//
//                }
//            ts++;
//        }
//        println(-1);

//        int n = ni();
//
//        HashSet<String> st = new HashSet<>();
//        HashMap<String,Integer> mp = new HashMap<>();
//
//
//        for(int i=0;i<n;++i){
//            String s  = ns();
//            int id= 1;
//            if(mp.containsKey(s)){
//                int u = mp.get(s);
//                id = u;
//
//            }
//
//            if(st.contains(s)) {
//
//                while (true) {
//                    String ts = s + id;
//                    if (!st.contains(ts)) {
//                        s = ts;
//                        break;
//                    }
//                    id++;
//                }
//                mp.put(s,id+1);
//            }else{
//                mp.put(s,1);
//            }
//            println(s);
//            st.add(s);
//
//        }

//        int t = ni();
//
//        for(int i=0;i<t;++i){
//            int n = ni();
//            long w[] = nal(n);
//
//            Map<Long,Long> mp = new HashMap<>();
//            PriorityQueue<long[]> q =new PriorityQueue<>((xx,xy)->{return Long.compare(xx[0],xy[0]);});
//
//            for(int j=0;j<n;++j){
//                q.offer(new long[]{w[j],0});
//                mp.put(w[j],mp.getOrDefault(w[j],0L)+1L);
//            }
//
//            while(q.size()>=2){
//                long f[] = q.poll();
//                long y1 = f[1];
//                if(y1==0){
//                    y1 = mp.get(f[0]);
//                    if(y1==1){
//                        mp.remove(f[0]);
//                    }else{
//                        mp.put(f[0],y1-1);
//                    }
//                }
//                long g[] = q.poll();
//                long y2 = g[1];
//                if(y2==0){
//                    y2 = mp.get(g[0]);
//                    if(y2==1){
//                        mp.remove(g[0]);
//                    }else{
//                        mp.put(g[0],y2-1);
//                    }
//                }
//                q.offer(new long[]{f[0]+g[0],2L*y1*y2});
//
//            }
//            long r[] = q.poll();
//            println(r[1]);
//
//
//
//
//        }
        //  int o= 9*8*7*6;
        //  println(o);

//       int t = ni();
//       for(int i=0;i<t;++i){
//           long a = nl();
//           int k  = ni();
//           if(k==1){
//               println(a);
//               continue;
//           }
//
//           int f = (int)(a%10L);
//           int s = 1;
//           int j = 0;
//           for(;j<30;j+=2){
//               int u = f-j;
//               if(u<0){
//                   u = 10+u;
//               }
//               s = u*s;
//               s = s%10;
//               if(s==k){
//                   break;
//               }
//           }
//
//           if(s==k) {
//               println(a - j - 2);
//           }else{
//               println(-1);
//           }
//
//
//
//
//       }
        int n = ni();
        t1 = new long[n+1];
        t2 = new long[n+1];
        int p[] = new int[n+1];
        int c[] = new int[n+1];
        for(int i=1;i<=n;++i){
            p[i] = ni();
            c[p[i]] = i;
        }

        long s = 0;
        long nx = 0;
        for(int i=1;i<=n;++i){
            int w = c[i];
            update(t1 , w, 1);
            nx += i-get(t1, w);
            long cnm  = nx;
            int ck = (i+1)/2;
            int pos = equal_bigger(t1, ck);
            update(t2 , w, w);
            long s1 = get(t2, pos-1);
            s += w;
            long s2 = s-s1-pos;

            cnm -= s1;
            cnm += s2;

            long left = ck-1;
            long right = i-ck;
            cnm += left*pos-(left)*(left+1)/2L;
            cnm -= right*pos+(right)*(right+1)/2L;

            print(cnm);
            if(i!=n){
                print(" ");
            }
        }

    }

    long t1[];
    long t2[];
    void update(long[] t,int i,long v){
        for(;i<t.length;i+=(i&-i)){
            t[i] += v;
        }
    }
    long get(long[] t,int i){
        long s = 0;
        for(;i>0;i-=(i&-i)){
            s += t[i];
        }
        return s;
    }

    int equal_bigger(long t[],long v){
        int s=0,p=0;
        for(int i=Integer.numberOfTrailingZeros(Integer.highestOneBit(t.length));i>=0;--i) {
            if(p+(1<<i)< t.length && s + t[p+(1<<i)] < v){
                v -= t[p+(1<<i)];
                p |= 1<<i;
            }
        }
        return p+1;
    }

    static class S{
        int l = 0;
        int r = 0 ;
        long le = 0;
        long ri = 0;
        long tot = 0;
        long all = 0;

        public S(int l,int r) {
            this.l = l;
            this.r = r;
        }
    }

    static S a[];
    static int[] o;

    static void init(int[] f){
        o = f;
        int len = o.length;
        a = new S[len*4];
        build(1,0,len-1);
    }

    static void build(int num,int l,int r){
        S cur = new S(l,r);
        if(l==r){
            a[num] = cur;
            return;
        }else{
            int m = (l+r)>>1;
            int le = num<<1;
            int ri = le|1;
            build(le, l,m);
            build(ri, m+1,r);
            a[num] = cur;
            pushup(num, le, ri);
        }
    }

    //    static int query(int num,int l,int r){
//
//        if(a[num].l>=l&&a[num].r<=r){
//            return a[num].tot;
//        }else{
//            int m = (a[num].l+a[num].r)>>1;
//            int le = num<<1;
//            int ri = le|1;
//            pushdown(num, le, ri);
//            int ma = 1;
//            int mi = 100000001;
//            if(l<=m) {
//                int r1 = query(le, l, r);
//                ma = ma*r1;
//
//            }
//            if(r>m){
//                int r2 = query(ri, l, r);
//                ma = ma*r2;
//            }
//            return ma;
//        }
//    }
    static long dd = 10007;
    static void update(int num,int l,long v){
        if(a[num].l==a[num].r){
            a[num].le = v%dd;
            a[num].ri = v%dd;
            a[num].all = v%dd;
            a[num].tot = v%dd;
        }else{
            int m = (a[num].l+a[num].r)>>1;
            int le = num<<1;
            int ri = le|1;
            pushdown(num, le, ri);
            if(l<=m){
                update(le,l,v);
            }
            if(l>m){
                update(ri,l,v);
            }
            pushup(num,le,ri);
        }
    }

    static void pushup(int num,int le,int ri){
        a[num].all = (a[le].all*a[ri].all)%dd;
        a[num].le = (a[le].le + a[le].all*a[ri].le)%dd;
        a[num].ri = (a[ri].ri + a[ri].all*a[le].ri)%dd;
        a[num].tot = (a[le].tot + a[ri].tot + a[le].ri*a[ri].le)%dd;

        //a[num].res[1] = Math.min(a[le].res[1],a[ri].res[1]);
    }
    static void pushdown(int num,int le,int ri){

    }

    int gcd(int a,int b){ return b==0?a: gcd(b,a%b);}
    InputStream is;PrintWriter out;
    void run() throws Exception {is = System.in;out = new PrintWriter(System.out);solve();out.flush();}
    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;
    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {lenbuf = is.read(inbuf);} catch (IOException e) {throw new InputMismatchException();}
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];}
    private boolean isSpaceChar(int c) {return !(c >= 33 && c <= 126);}
    private int skip() {int b;while((b = readByte()) != -1 && isSpaceChar(b));return b;}
    private double nd() {return Double.parseDouble(ns());}
    private char nc() {return (char) skip();}
    private char ncc() {int b;while((b = readByte()) != -1 && !(b >= 32 && b <= 126));return (char)b;}
    private String ns() {int b = skip();StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);b = readByte(); }
        return sb.toString();}
    private char[] ns(int n) {char[] buf = new char[n];int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) { buf[p++] = (char) b;b = readByte(); }
        return n == p ? buf : Arrays.copyOf(buf, p);}
    private String nline() {int b = skip();StringBuilder sb = new StringBuilder();
        while (!isSpaceChar(b) || b == ' ') { sb.appendCodePoint(b);b = readByte(); }
        return sb.toString();}
    private char[][] nm(int n, int m) {char[][] a = new char[n][];for (int i = 0; i < n; i++) a[i] = ns(m);return a;}
    private int[] na(int n) {int[] a = new int[n];for (int i = 0; i < n; i++) a[i] = ni();return a;}
    private long[] nal(int n) { long[] a = new long[n];for (int i = 0; i < n; i++) a[i] = nl();return a;}
    private int ni() { int num = 0, b; boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')){};
        if (b == '-') { minus = true; b = readByte(); }
        while (true) {
            if (b >= '0' && b <= '9') num = (num << 3) + (num << 1) + (b - '0');
            else return minus ? -num : num;
            b = readByte();}}
    private long nl() { long num = 0; int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')){};
        if (b == '-') { minus = true; b = readByte(); }
        while (true) {
            if (b >= '0' && b <= '9')  num = num * 10 + (b - '0');
            else return minus ? -num : num;
            b = readByte();}}
    void print(Object obj){out.print(obj);}
    void println(Object obj){out.println(obj);}
    void println(){out.println();}
}


//package cf;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class USACO {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter (System.out);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
        long n = Integer.parseInt(reader.readLine());
        StringTokenizer st = new StringTokenizer(reader.readLine()," ");
        int[] locs = new int[(int)n];
        int[] leftFenwick = new int[(int)n+1];
        for (int i=0;i<n;i++) locs[Integer.parseInt(st.nextToken())-1]=i;
        int center=0; // half right of center
        long dist=0;
        long otherDist=0;
        long answer=0;
        SortedSet<Integer> flock = new TreeSet<>();
        for (int i=0;i<n;i++) {
        	flock.add(locs[i]);
        	if (i>0) dist+=Math.abs((long)(locs[i]-center));
        	else center=locs[i];
        	if (i%2==0&&locs[i]<center) {
        		long x=center;
        		center=flock.headSet(center).last();
        		dist-=Math.abs(x-center);
        	}
        	if (i%2==1&&locs[i]>center) center=flock.tailSet(center+1).first();
        	long offset=0;
        	if (i%2==0) offset=(i/2)*(i/2+1);
        	else offset=(i/2)*(i/2+1)/2+(i/2+1)*(i/2+2)/2;
        	int power=2;
        	if (i>0) out.print(" ");
        	int powerTwo=1;
        	answer=answer+i;
        	while (powerTwo<=n) {
        		if (((locs[i]+1)/powerTwo)%2==1&&((locs[i]+1)/powerTwo)*powerTwo<=n) {
        			answer-=leftFenwick[((locs[i]+1)/powerTwo)*powerTwo];
        		}
        		powerTwo*=2;
        	}
        	out.print(dist-offset+answer);
        	leftFenwick[(locs[i]+1)]+=1;
        	while (power<=n) {
        		if ((((locs[i]+1)/power)%2==0)&&((locs[i]+1)/power+1)*power<=n) {
        			leftFenwick[((locs[i]+1)/power+1)*power]+=1;
        		}
        		power*=2;
        	}
        	/*for (int j=0;j<n;j++) {
        		out.print(" "+leftFenwick[j+1]);
        	}
        	out.println();*/
        }
        out.println();
        reader.close();
        out.close();
    }
}


package cf;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class USACO {
    public static void main(String[] args) throws IOException {
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter (System.out);
        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
        long n = Integer.parseInt(reader.readLine());
        StringTokenizer st = new StringTokenizer(reader.readLine()," ");
        int[] locs = new int[(int)n];
        int[] leftFenwick = new int[(int)n+1];
        for (int i=0;i<n;i++) locs[Integer.parseInt(st.nextToken())-1]=i;
        int center=0; // half right of center
        long dist=0;
        long otherDist=0;
        long answer=0;
        SortedSet<Integer> flock = new TreeSet<>();
        for (int i=0;i<n;i++) {
        	flock.add(locs[i]);
        	if (i>0) dist+=Math.abs((long)(locs[i]-center));
        	else center=locs[i];
        	if (i%2==0&&locs[i]<center) {
        		long x=center;
        		center=flock.headSet(center).last();
        		dist-=Math.abs(x-center);
        	}
        	if (i%2==1&&locs[i]>center) center=flock.tailSet(center+1).first();
        	long offset=0;
        	if (i%2==0) offset=(i/2)*(i/2+1);
        	else offset=(i/2)*(i/2+1)/2+(i/2+1)*(i/2+2)/2;
        	int power=2;
        	if (i>0) out.print(" ");
        	int powerTwo=1;
        	answer=answer+i;
        	while (powerTwo<=n) {
        		if (((locs[i]+1)/powerTwo)%2==1&&((locs[i]+1)/powerTwo)*powerTwo<=n) {
        			answer-=leftFenwick[((locs[i]+1)/powerTwo)*powerTwo];
        		}
        		powerTwo*=2;
        	}
        	out.print((dist-offset)+answer);
        	leftFenwick[(locs[i]+1)]+=1;
        	while (power<=n) {
        		if ((((locs[i]+1)/power)%2==0)&&(((locs[i]+1)/power)*power!=locs[i]+1)&&((locs[i]+1)/power+1)*power<=n) {
        			leftFenwick[((locs[i]+1)/power+1)*power]+=1;
        		}
        		power*=2;
        	}/*
        	for (int j=0;j<n;j++) {
        		out.print(" "+leftFenwick[j+1]);
        	}
        	out.println();*/
        }
        out.println();
        reader.close();
        out.close();
    }
}


//package cf;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class USACO {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter (System.out);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
        long n = Integer.parseInt(reader.readLine());
        StringTokenizer st = new StringTokenizer(reader.readLine()," ");
        int[] locs = new int[(int)n];
        int[] leftFenwick = new int[(int)n+1];
        for (int i=0;i<n;i++) locs[Integer.parseInt(st.nextToken())-1]=i;
        int center=0; // half right of center
        long dist=0;
        long otherDist=0;
        long answer=0;
        SortedSet<Integer> flock = new TreeSet<>();
        for (int i=0;i<n;i++) {
        	flock.add(locs[i]);
        	if (i>0) dist+=Math.abs((long)(locs[i]-center));
        	else center=locs[i];
        	if (i%2==0&&locs[i]<center) {
        		long x=center;
        		center=flock.headSet(center).last();
        		dist-=Math.abs(x-center);
        	}
        	if (i%2==1&&locs[i]>center) center=flock.tailSet(center+1).first();
        	long offset=0;
        	if (i%2==0) offset=(i/2)*(i/2+1);
        	else offset=(i/2)*(i/2+1)/2+(i/2+1)*(i/2+2)/2;
        	int power=2;
        	if (i>0) out.print(" ");
        	int powerTwo=1;
        	answer=answer+i;
        	while (powerTwo<=n) {
        		if (((locs[i]+1)/powerTwo)%2==1&&((locs[i]+1)/powerTwo)*powerTwo<=n) {
        			answer-=leftFenwick[((locs[i]+1)/powerTwo)*powerTwo];
        		}
        		powerTwo*=2;
        	}
        	out.print((dist-offset)+answer);
        	leftFenwick[(locs[i]+1)]+=1;
        	while (power<=n) {
        		if ((((locs[i]+1)/power)%2==0)&&(((locs[i]+1)/power)*power!=locs[i]+1)&&((locs[i]+1)/power+1)*power<=n) {
        			leftFenwick[((locs[i]+1)/power+1)*power]+=1;
        		}
        		power*=2;
        	}/*
        	for (int j=0;j<n;j++) {
        		out.print(" "+leftFenwick[j+1]);
        	}
        	out.println();*/
        }
        out.println();
        reader.close();
        out.close();
    }
}


//package cf;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class USACO {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter (System.out);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
        long n = Integer.parseInt(reader.readLine());
        StringTokenizer st = new StringTokenizer(reader.readLine()," ");
        int[] locs = new int[(int)n];
        int[] leftFenwick = new int[(int)n];
        for (int i=0;i<n;i++) locs[Integer.parseInt(st.nextToken())-1]=i;
        int center=0; // half right of center
        long dist=0;
        long otherDist=0;
        long answer=0;
        SortedSet<Integer> flock = new TreeSet<>();
        for (int i=0;i<n;i++) {
        	flock.add(locs[i]);
        	if (i>0) dist+=Math.abs((long)(locs[i]-center));
        	else center=locs[i];
        	if (i%2==0&&locs[i]<center) {
        		long x=center;
        		center=flock.headSet(center).last();
        		dist-=Math.abs(x-center);
        	}
        	if (i%2==1&&locs[i]>center) center=flock.tailSet(center+1).first();
        	long offset=0;
        	if (i%2==0) offset=(i/2)*(i/2+1);
        	else offset=(i/2)*(i/2+1)/2+(i/2+1)*(i/2+2)/2;
        	int power=2;
        	if (i>0) out.print(" ");
        	int powerTwo=1;
        	answer=answer+i;
        	while (powerTwo<=n) {
        		if ((locs[i]/powerTwo)%2==1&&(locs[i]/powerTwo)*powerTwo<n) {
        			answer-=leftFenwick[(locs[i]/powerTwo)*powerTwo];
        		}
        		powerTwo*=2;
        	}
        	out.print(dist+answer-offset);
        	if (locs[i]%2==1) leftFenwick[locs[i]]=1;
        	while (power<=n) {
        		if (((locs[i]/power)%2==0)&&(locs[i]/power+1)*power<n) {
        			leftFenwick[(locs[i]/power+1)*power]+=1;
        		}
        		power*=2;
        	}
        	for (int j=0;j<n;j++) {
        		out.print(" "+leftFenwick[j]);
        	}
        	out.println();
        }
        out.println();
        reader.close();
        out.close();
    }
}


//package cf;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class USACO {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter (System.out);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
        long n = Integer.parseInt(reader.readLine());
        StringTokenizer st = new StringTokenizer(reader.readLine()," ");
        long[] locs = new long[(int)n];
        long[] leftFenwick = new long[(int)n+1];
        for (int i=0;i<n;i++) locs[Integer.parseInt(st.nextToken())-1]=i;
        long center=0; // half right of center
        long dist=0;
        long otherDist=0;
        long answer=0;
        SortedSet<Long> flock = new TreeSet<>();
        for (long i=0;i<n;i++) {
        	flock.add(locs[(int)i]);
        	if (i>0) dist+=Math.abs((long)(locs[i]-center));
        	else center=locs[(int)i];
        	if (i%2==0&&locs[(int)i]<center) {
        		long x=center;
        		center=flock.headSet(center).last();
        		dist-=Math.abs(x-center);
        	}
        	if (i%2==1&&locs[(int)i]>center) center=flock.tailSet(center+1).first();
        	long offset=0;
        	if (i%2==0) offset=(i/2)*(i/2+1);
        	else offset=(i/2)*(i/2+1)/2+(i/2+1)*(i/2+2)/2;
        	long power=2;
        	if (i>0) out.print(" ");
        	long powerTwo=1;
        	answer=answer+i;
        	while (powerTwo<=n) {
        		if (((locs[(int)i]+1)/powerTwo)%2==1&&((locs[(int)i]+1)/powerTwo)*powerTwo<=n) {
        			answer-=leftFenwick[(int)(((locs[(int)i]+1)/powerTwo)*powerTwo)];
        		}
        		powerTwo*=2;
        	}
        	out.println((dist-offset)+" "+answer+" x");
        	leftFenwick[(int)(locs[(int)i]+1)]+=1;
        	while (power<=n) {
        		if ((((locs[(int)i]+1)/power)%2==0)&&(((locs[(int)i]+1)/power)*power!=locs[(int)i]+1)&&((locs[(int)i]+1)/power+1)*power<=n) {
        			leftFenwick[(int)(((locs[(int)i]+1)/power+1)*power)]+=1;
        		}
        		power*=2;
        	}/*
        	for (int j=0;j<n;j++) {
        		out.print(" "+leftFenwick[j+1]);
        	}
        	out.println();*/
        }
        out.println();
        reader.close();
        out.close();
    }
}


//package cf;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class USACO {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter (System.out);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
        long n = Integer.parseInt(reader.readLine());
        StringTokenizer st = new StringTokenizer(reader.readLine()," ");
        long[] locs = new long[(int)n];
        long[] leftFenwick = new long[(int)n+1];
        for (int i=0;i<n;i++) locs[Integer.parseInt(st.nextToken())-1]=i;
        long center=0; // half right of center
        long dist=0;
        long otherDist=0;
        long answer=0;
        SortedSet<Long> flock = new TreeSet<>();
        for (long i=0;i<n;i++) {
        	flock.add(locs[(int)i]);
        	if (i>0) dist+=Math.abs((long)(locs[(int)i]-center));
        	else center=locs[(int)i];
        	if (i%2==0&&locs[(int)i]<center) {
        		long x=center;
        		center=flock.headSet(center).last();
        		dist-=Math.abs(x-center);
        	}
        	if (i%2==1&&locs[(int)i]>center) center=flock.tailSet(center+1).first();
        	long offset=0;
        	if (i%2==0) offset=(i/2)*(i/2+1);
        	else offset=(i/2)*(i/2+1)/2+(i/2+1)*(i/2+2)/2;
        	long power=2;
        	if (i>0) out.print(" ");
        	long powerTwo=1;
        	answer=answer+i;
        	while (powerTwo<=n) {
        		if (((locs[(int)i]+1)/powerTwo)%2==1&&((locs[(int)i]+1)/powerTwo)*powerTwo<=n) {
        			answer-=leftFenwick[(int)(((locs[(int)i]+1)/powerTwo)*powerTwo)];
        		}
        		powerTwo*=2;
        	}
        	out.println((dist-offset)+" "+answer+" x");
        	leftFenwick[(int)(locs[(int)i]+1)]+=1;
        	while (power<=n) {
        		if ((((locs[(int)i]+1)/power)%2==0)&&(((locs[(int)i]+1)/power)*power!=locs[(int)i]+1)&&((locs[(int)i]+1)/power+1)*power<=n) {
        			leftFenwick[(int)(((locs[(int)i]+1)/power+1)*power)]+=1;
        		}
        		power*=2;
        	}/*
        	for (int j=0;j<n;j++) {
        		out.print(" "+leftFenwick[j+1]);
        	}
        	out.println();*/
        }
        out.println();
        reader.close();
        out.close();
    }
}


//package cf;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class USACO {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter (System.out);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
        long n = Integer.parseInt(reader.readLine());
        StringTokenizer st = new StringTokenizer(reader.readLine()," ");
        long[] locs = new long[(int)n];
        long[] leftFenwick = new long[(int)n+1];
        for (int i=0;i<n;i++) locs[Integer.parseInt(st.nextToken())-1]=i;
        long center=0; // half right of center
        long dist=0;
        long otherDist=0;
        long answer=0;
        SortedSet<Long> flock = new TreeSet<>();
        for (long i=0;i<n;i++) {
        	flock.add(locs[(int)i]);
        	if (i>0) dist+=Math.abs((long)(locs[(int)i]-center));
        	else center=locs[(int)i];
        	if (i%2==0&&locs[(int)i]<center) {
        		long x=center;
        		center=flock.headSet(center).last();
        		dist-=Math.abs(x-center);
        	}
        	if (i%2==1&&locs[(int)i]>center) center=flock.tailSet(center+1).first();
        	long offset=0;
        	if (i%2==0) offset=(i/2)*(i/2+1);
        	else offset=(i/2)*(i/2+1)/2+(i/2+1)*(i/2+2)/2;
        	long power=2;
        	if (i>0) out.print(" ");
        	long powerTwo=1;
        	answer=answer+i;
        	while (powerTwo<=n) {
        		if (((locs[(int)i]+1)/powerTwo)%2==1&&((locs[(int)i]+1)/powerTwo)*powerTwo<=n) {
        			answer-=leftFenwick[(int)(((locs[(int)i]+1)/powerTwo)*powerTwo)];
        		}
        		powerTwo*=2;
        	}
        	out.print((dist-offset)+answer);
        	leftFenwick[(int)(locs[(int)i]+1)]+=1;
        	while (power<=n) {
        		if ((((locs[(int)i]+1)/power)%2==0)&&(((locs[(int)i]+1)/power)*power!=locs[(int)i]+1)&&((locs[(int)i]+1)/power+1)*power<=n) {
        			leftFenwick[(int)(((locs[(int)i]+1)/power+1)*power)]+=1;
        		}
        		power*=2;
        	}/*
        	for (int j=0;j<n;j++) {
        		out.print(" "+leftFenwick[j+1]);
        	}
        	out.println();*/
        }
        out.println();
        reader.close();
        out.close();
    }
}


import java.util.Scanner;

public class KIntegers {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] p = new int[n + 1];
        int[] q = new int[n + 1];
        for (int j = 1; j <= n; j++) {
            p[j] = in.nextInt();
            q[p[j]] = j;
        }
        BinaryIndexTree bit1 = new BinaryIndexTree(1, n);
        BinaryIndexTree bit2 = new BinaryIndexTree(1, n);
        StringBuilder builder = new StringBuilder();
        long curr = 0;
        for (int j = 1; j <= n; j++) {
            curr += bit1.query(q[j] + 1, n);
            //System.out.println("j = " + j + ", curr = " + curr);
            bit1.update(q[j], 1L);
            bit2.update(q[j], q[j]);
            int lower = 1;
            int upper = n;
            while (upper > lower) {
                int mid = (lower + upper + 1) / 2;
                if (bit1.query(1, mid - 1) > j / 2) {
                    upper = mid - 1;
                } else {
                    lower = mid;
                }
            }
            long above = bit1.query(upper + 1, n);
            long add1 =  bit2.query(upper + 1, n) - (((long) upper) * above) - ((above * (above + 1)) / 2L);
            long below = bit1.query(1, upper - 1);
            long add2 =  (((long) upper) * below) - ((below * (below + 1)) / 2L) - bit2.query(1, upper - 1);
            //System.out.println("upper = " + upper);
            //System.out.println("above = " + above + ", below = " + below);
            //System.out.println("add1 = " + add1 + ", add2 = " + add2);
            builder.append(curr + add1 + add2).append(' ');
        }
        System.out.println(builder);
    }

    static class BinaryIndexTree {
        final long[] val;
        final int treeFrom;

        BinaryIndexTree(int treeFrom, int treeTo) {
            val = new long[treeTo - treeFrom + 2];
            this.treeFrom = treeFrom;
        }

        void update(int index, long delta) {
            for (int i = index + 1 - treeFrom; i < val.length; i += i & -i) {
                val[i] += delta;
            }
        }

        long query(int to) {
            long res = 0;
            for (int i = to + 1 - treeFrom; i > 0; i -= i & -i) {
                res += val[i];
            }
            return res;
        }

        long query(int from, int to) {
            if (to < from) {
                return 0;
            }
            return query(to) - query(from - 1);
        }
    }
}


import java.util.*;
import java.io.*;
public class KInt {

	static BufferedReader br;
	static StringTokenizer tokenizer;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		int n = nextInt();
		int[] arr = new int[n];
		int[] idx = new int[n + 1];
		BIT b = new BIT(n);
		BIT dist = new BIT(n);
		for(int i = 0; i < n; i++) {
			arr[i] = nextInt();
			idx[arr[i]] = i;
		}
		TreeSet<Integer> mid = new TreeSet<Integer>();
		long inversions = 0;
		int pivot = idx[1];
		PrintWriter out = new PrintWriter(System.out);
		for(int i = 1; i <= n; i++) {
			b.add(idx[i], 1);
			dist.add(idx[i], idx[i]);
			mid.add(idx[i]);
			inversions += b.get(idx[i], n) - 1;
			long lower = b.get(pivot);
			if(lower * 2 - 2 >= i) pivot = mid.lower(pivot);
			else if(lower * 2 < i) pivot = mid.higher(pivot);
			lower = b.get(pivot);
			long higher = b.get(pivot, n);
			long jump = lower * pivot - dist.get(pivot) + dist.get(pivot, n) - higher * pivot;
			jump -= lower * (lower - 1) / 2 + higher * (higher - 1) / 2;
			out.print(inversions + jump + " ");
		}
		out.close();
	}

	public static String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null)
				throw new IOException();
			tokenizer = new StringTokenizer(line);
		}
		return tokenizer.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public static long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
}
class BIT {
	long[] BIT;
	int n;

	public BIT(int n) {
		super();
		this.n = n + 1;
		BIT = new long[n + 1];
	}
	public BIT(long[] BIT) {
		this.BIT = BIT;
		n = BIT.length;
	}
	void add(int idx, int val) {
		idx++;
		for(; idx < n; idx += (idx & (-idx)))
			BIT[idx] += val;
	}
	//[0,l]
	long get(int idx) {
		idx++;
		long ret = 0;
		for(; idx > 0; idx -= (idx & (-idx)))
			ret += BIT[idx];
		return ret;
	}
	// [l,r)
	long get(int l, int r) {
		return (get(r - 1) - get(l - 1));
	}
}


import java.util.*;
import java.io.*;
public class KInt {

	static BufferedReader br;
	static StringTokenizer tokenizer;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		int n = nextInt();
		int[] arr = new int[n];
		int[] idx = new int[n + 1];
		BIT b = new BIT(n);
		BIT dist = new BIT(n);
		for(int i = 0; i < n; i++) {
			arr[i] = nextInt();
			idx[arr[i]] = i;
		}
		TreeSet<Integer> mid = new TreeSet<Integer>();
		long inversions = 0;
		int pivot = idx[1];
		PrintWriter out = new PrintWriter(System.out);
		for(int i = 1; i <= n; i++) {
			b.add(idx[i], 1);
			dist.add(idx[i], idx[i]);
			mid.add(idx[i]);
			inversions += b.get(idx[i], n) - 1;
			long lower = b.get(pivot);
			if(lower * 2 - 2 >= i) pivot = mid.lower(pivot);
			else if(lower * 2 < i) pivot = mid.higher(pivot);
			lower = b.get(pivot);
			long higher = b.get(pivot, n);
			long jump = lower * pivot - dist.get(pivot) + dist.get(pivot, n) - higher * pivot;
//			System.out.println(lower + " " + higher + " " + jump);
			jump -= lower * (lower - 1) / 2 + higher * (higher - 1) / 2;
//			System.out.println(i + " " + inversions + " " + jump + " " + pivot);
//			System.out.println();
			out.print(inversions + jump + " ");
		}
		out.close();
	}

	public static String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null)
				throw new IOException();
			tokenizer = new StringTokenizer(line);
		}
		return tokenizer.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public static long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
}
class BIT {
	int[] BIT;
	int n;

	public BIT(int n) {
		super();
		this.n = n + 1;
		BIT = new int[n + 1];
	}
	public BIT(int[] BIT) {
		this.BIT = BIT;
		n = BIT.length;
	}
	void add(int idx, int val) {
		idx++;
		for(; idx < n; idx += (idx & (-idx)))
			BIT[idx] += val;
	}
	//[0,l]
	int get(int idx) {
		idx++;
		int ret = 0;
		for(; idx > 0; idx -= (idx & (-idx)))
			ret += BIT[idx];
		return ret;
	}
	// [l,r)
	int get(int l, int r) {
		return (get(r - 1) - get(l - 1));
	}
}


import java.util.*;
import java.io.*;
public class KInt {

	static BufferedReader br;
	static StringTokenizer tokenizer;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		int n = nextInt();
		int[] arr = new int[n];
		int[] idx = new int[n + 1];
		BIT b = new BIT(n);
		BIT dist = new BIT(n);
		for(int i = 0; i < n; i++) {
			arr[i] = nextInt();
			idx[arr[i]] = i;
		}
		TreeSet<Integer> mid = new TreeSet<Integer>();
		long inversions = 0;
		int pivot = idx[1];
		PrintWriter out = new PrintWriter(System.out);
		for(int i = 1; i <= n; i++) {
			b.add(idx[i], 1);
			dist.add(idx[i], idx[i]);
			mid.add(idx[i]);
			inversions += b.get(idx[i], n) - 1;
			long lower = b.get(pivot);
			if(lower * 2 - 2 >= i) pivot = mid.lower(pivot);
			else if(lower * 2 < i) pivot = mid.higher(pivot);
			lower = b.get(pivot);
			long higher = b.get(pivot, n);
			long jump = lower * pivot - dist.get(pivot) + dist.get(pivot, n) - higher * pivot;
			jump -= lower * (lower - 1) / 2 + higher * (higher - 1) / 2;
			if(jump < 0)
				out.print(jump + " ");
			out.print(inversions + jump + " ");
		}
		out.close();
	}

	public static String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null)
				throw new IOException();
			tokenizer = new StringTokenizer(line);
		}
		return tokenizer.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public static long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
}
class BIT {
	int[] BIT;
	int n;

	public BIT(int n) {
		super();
		this.n = n + 1;
		BIT = new int[n + 1];
	}
	public BIT(int[] BIT) {
		this.BIT = BIT;
		n = BIT.length;
	}
	void add(int idx, int val) {
		idx++;
		for(; idx < n; idx += (idx & (-idx)))
			BIT[idx] += val;
	}
	//[0,l]
	int get(int idx) {
		idx++;
		int ret = 0;
		for(; idx > 0; idx -= (idx & (-idx)))
			ret += BIT[idx];
		return ret;
	}
	// [l,r)
	int get(int l, int r) {
		return (get(r - 1) - get(l - 1));
	}
}


import java.util.*;
import java.io.*;
public class KInt {

	static BufferedReader br;
	static StringTokenizer tokenizer;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		int n = nextInt();
		int[] arr = new int[n];
		int[] idx = new int[n + 1];
		BIT b = new BIT(n);
		BIT dist = new BIT(n);
		for(int i = 0; i < n; i++) {
			arr[i] = nextInt();
			idx[arr[i]] = i;
		}
		TreeSet<Integer> mid = new TreeSet<Integer>();
		int inversions = 0;
		int pivot = idx[1];
		PrintWriter out = new PrintWriter(System.out);
		for(int i = 1; i <= n; i++) {
			b.add(idx[i], 1);
			dist.add(idx[i], idx[i]);
			mid.add(idx[i]);
			inversions += b.get(idx[i], n) - 1;
			int lower = b.get(pivot);
			if(lower * 2 - 2 >= i) pivot = mid.lower(pivot);
			else if(lower * 2 < i) pivot = mid.higher(pivot);
			lower = b.get(pivot);
			int higher = b.get(pivot, n);
			int jump = lower * pivot - dist.get(pivot) + dist.get(pivot, n) - higher * pivot;
//			System.out.println(lower + " " + higher + " " + jump);
			jump -= lower * (lower - 1) / 2 + higher * (higher - 1) / 2;
//			System.out.println(i + " " + inversions + " " + jump + " " + pivot);
//			System.out.println();
			out.print(inversions + jump + " ");
		}
		out.close();
	}

	public static String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null)
				throw new IOException();
			tokenizer = new StringTokenizer(line);
		}
		return tokenizer.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public static long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
}
class BIT {
	int[] BIT;
	int n;

	public BIT(int n) {
		super();
		this.n = n + 1;
		BIT = new int[n + 1];
	}
	public BIT(int[] BIT) {
		this.BIT = BIT;
		n = BIT.length;
	}
	void add(int idx, int val) {
		idx++;
		for(; idx < n; idx += (idx & (-idx)))
			BIT[idx] += val;
	}
	//[0,l]
	int get(int idx) {
		idx++;
		int ret = 0;
		for(; idx > 0; idx -= (idx & (-idx)))
			ret += BIT[idx];
		return ret;
	}
	// [l,r)
	int get(int l, int r) {
		return (get(r - 1) - get(l - 1));
	}
}


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1269E
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         int[] map = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
         {
            arr[i] = Integer.parseInt(st.nextToken());
            map[arr[i]] = i;
         }
         //brain tumor
         StringBuilder sb = new StringBuilder();
         FenwickTree bit = new FenwickTree(N+1);
         FenwickTree pos = new FenwickTree(N+1);
         //ArrayList<Integer> pos = new ArrayList<Integer>();
         long res = 0L;
         for(int i=1; i <= N; i++)
         {
            int dex = map[i]+1;
            res += bit.find(dex, N);
            bit.add(dex, 1);
            pos.add(dex, dex);
            //has pos.size()/2 elements to the left
            int low = 1;
            int high = N;
            while(low != high)
            {
               int mid = (low+high+1)/2;
               if(bit.find(mid) > i/2)
                  high = mid-1;
               else
                  low = mid;
            }
            //fft (fuck fenwick trees)
            long left_count = bit.find(low-1);
            long temp = -1*pos.find(low-1);
            temp -= left_count*(left_count+1)/2;
            temp += left_count*(long)low;
            long right_count = bit.find(low+1, N);
            long temp2 = pos.find(low+1, N);
            temp2 -= right_count*(right_count+1)/2;
            temp2 -= right_count*(long)low;
            sb.append(res+temp+temp2+" ");
         }
         System.out.println(sb);
      }
   }
   class FenwickTree
   {
      //1 indexed
      public long[] tree;
      public int size;

      public FenwickTree(int size)
      {
         this.size = size;
         tree = new long[size+5];
      }
      public void add(int i, int v)
      {
         while(i <= size)
         {
            tree[i] += v;
            i += i&-i;
         }
      }
      public long find(int i)
      {
         long res = 0L;
         while(i >= 1)
         {
            res += tree[i];
            i -= i&-i;
         }
         return res;
      }
      public long find(int l, int r)
      {
         return find(r)-find(l-1);
      }
   }


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1269E
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         int[] map = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
         {
            arr[i] = Integer.parseInt(st.nextToken());
            map[arr[i]] = i;
         }
         //brain tumor
         StringBuilder sb = new StringBuilder();
         FenwickTree bit = new FenwickTree(N+1);
         FenwickTree pos = new FenwickTree(N+1);
         //ArrayList<Integer> pos = new ArrayList<Integer>();
         long res = 0L;
         for(int i=1; i <= N; i++)
         {
            int dex = map[i]+1;
            res += bit.find(dex, N);
            bit.add(dex, 1);
            pos.add(dex, dex);
            //has pos.size()/2 elements to the left
            int low = 1;
            int high = N;
            while(low != high)
            {
               int mid = (low+high+1)/2;
               if(bit.find(mid-1) > i/2)
                  high = mid-1;
               else
                  low = mid;
            }
            //fft (fuck fenwick trees)
            long left_count = bit.find(low-1);
            long temp = -1*pos.find(low-1);
            temp -= left_count*(left_count+1)/2;
            temp += left_count*(long)low;
            long right_count = bit.find(low+1, N);
            long temp2 = pos.find(low+1, N);
            temp2 -= right_count*(right_count+1)/2;
            temp2 -= right_count*(long)low;
            sb.append(res+temp+temp2+" ");
         }
         System.out.println(sb);
      }
   }
   class FenwickTree
   {
      //1 indexed
      public long[] tree;
      public int size;

      public FenwickTree(int size)
      {
         this.size = size;
         tree = new long[size+5];
      }
      public void add(int i, int v)
      {
         while(i <= size)
         {
            tree[i] += v;
            i += i&-i;
         }
      }
      public long find(int i)
      {
         long res = 0L;
         while(i >= 1)
         {
            res += tree[i];
            i -= i&-i;
         }
         return res;
      }
      public long find(int l, int r)
      {
         return find(r)-find(l-1);
      }
   }


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1269E
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         int[] map = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
         {
            arr[i] = Integer.parseInt(st.nextToken());
            map[arr[i]] = i;
         }
         //I lack Omkar
         StringBuilder sb = new StringBuilder();
         FenwickTree bit = new FenwickTree(N+1);
         ArrayList<Integer> pos = new ArrayList<Integer>();
         long res = 0L;
         for(int i=1; i <= N; i++)
         {
            int dex = map[i]+1;
            res += bit.find(dex, N);
            bit.add(dex, 1);
            pos.add(dex);
            //median optimal?
            Collections.sort(pos);
            int mid = pos.size()/2;
            long temp = 0L;
            for(int a=0; a < pos.size(); a++)
               temp += Math.abs(pos.get(mid)-pos.get(a))-Math.abs(mid-a);
            sb.append(res+temp).append(" ");
         }
         System.out.println(sb);
      }
   }
   class FenwickTree
   {
      //1 indexed
      public int[] tree;
      public int size;

      public FenwickTree(int size)
      {
         this.size = size;
         tree = new int[size+5];
      }
      public void add(int i, int v)
      {
         while(i <= size)
         {
            tree[i] += v;
            i += i&-i;
         }
      }
      public int find(int i)
      {
         int res = 0;
         while(i >= 1)
         {
            res += tree[i];
            i -= i&-i;
         }
         return res;
      }
      public int find(int l, int r)
      {
         return find(r)-find(l-1);
      }
   }


#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
using namespace std;
#define FOR(z,l,n) for(int z=l;z<n;z++)
#define pii pair<int,int>
#define mp make_pair
#define ll long long int
#define pll pair<long long,long long>
const bool debug = true;
int p[200001];
int pos[200001];
class seg_tree{
    int* st;
    int n;
    public:
     seg_tree(int a){
        st = new int[2*a];
        for(int i=0;i<2*a;i++)st[i]=0;
        n = a;
    }
    void set(int x){
        x+=n;
        st[x]=1;
        x/=2;
        while(x){
            st[x] = st[2*x]+st[2*x+1];
            x/=2;
        }
    }
    int query (int l,int r){
        l+=n;r+=n;
        int ans = 0;
        while(l<r){
            if(l&1){
                ans += st[l++];
            }
            if(r&1){
                ans += st[--r];
            }
            l>>=1;r>>=1;
        }
        return ans;
    }
};
class median{
    priority_queue<int,vector<int>,greater<int>> higher;
    priority_queue<int> lower;
    long long int suml,sumr;
public:
    median(){
        suml=0;sumr=0;
    }
    void insert(int n){
        if((lower.empty()&&higher.empty()) || n<lower.top()){
            lower.push(n);
            suml+=n;
            if(lower.size()>higher.size()+1){
                higher.push(lower.top());
                sumr+=lower.top();
                suml-=lower.top();
                lower.pop();
            }
        }
        else{
            higher.push(n);
            sumr+=n;
            if(higher.size()>lower.size()){
                lower.push(higher.top());
                suml+=higher.top();
                sumr-=higher.top();
                higher.pop();
            }
        }
    }
    int get_median(){
        return lower.top();
    }
    int get_swaps(){
        long long int n = lower.size();
        long long int l = lower.top()*n-suml - ((n)*(n-1))/2;
        n= higher.size();
        long long r = sumr - lower.top()*n - ((n)*(n+1))/2;
        return l+r;
    }
};
int main(){
    int n;
    cin>>n;
    FOR(z,1,n+1){cin>>p[z];pos[p[z]]=z;}
    seg_tree cind(n+1);
    median med;
    int inv = 0;
    FOR(z,1,n+1){
        inv += cind.query(pos[z],n+1);
        //cout<<inv<<endl;
        cind.set(pos[z]);
        med.insert(pos[z]);
        cout<<inv+med.get_swaps()<<" ";
    }
    cout<<endl;
}


#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
using namespace std;
#define FOR(z,l,n) for(int z=l;z<n;z++)
#define pii pair<int,int>
#define mp make_pair
#define ll long long int
#define pll pair<long long,long long>
const bool debug = true;
int p[200001];
int pos[200001];
class seg_tree{
    int* st;
    int n;
    public:
     seg_tree(int a){
        st = new int[2*a];
        for(int i=0;i<2*a;i++)st[i]=0;
        n = a;
    }
    void set(int x){
        x+=n;
        st[x]=1;
        x/=2;
        while(x){
            st[x] = st[2*x]+st[2*x+1];
            x/=2;
        }
    }
    int query (int l,int r){
        l+=n;r+=n;
        int ans = 0;
        while(l<r){
            if(l&1){
                ans += st[l++];
            }
            if(r&1){
                ans += st[--r];
            }
            l>>=1;r>>=1;
        }
        return ans;
    }
};
class median{
    priority_queue<int,vector<int>,greater<int>> higher;
    priority_queue<int> lower;
    int suml,sumr;
public:
    median(){
        suml=0;sumr=0;
    }
    void insert(int n){
        if((lower.empty()&&higher.empty()) || n<lower.top()){
            lower.push(n);
            suml+=n;
            if(lower.size()>higher.size()+1){
                higher.push(lower.top());
                sumr+=lower.top();
                suml-=lower.top();
                lower.pop();
            }
        }
        else{
            higher.push(n);
            sumr+=n;
            if(higher.size()>lower.size()){
                lower.push(higher.top());
                suml+=higher.top();
                sumr-=higher.top();
                higher.pop();
            }
        }
    }
    int get_median(){
        return lower.top();
    }
    int get_swaps(){
        int n = lower.size();
        int l = lower.top()*n-suml - ((n)*(n-1))/2;
        n= higher.size();
        int r = sumr - lower.top()*n - ((n)*(n+1))/2;
        return l+r;
    }
};
int main(){
    int n;
    cin>>n;
    FOR(z,1,n+1){cin>>p[z];pos[p[z]]=z;}
    seg_tree cind(n+1);
    median med;
    int inv = 0;
    FOR(z,1,n+1){
        inv += cind.query(pos[z],n+1);
        //cout<<inv<<endl;
        cind.set(pos[z]);
        med.insert(pos[z]);
        cout<<inv+med.get_swaps()<<" ";
    }
    cout<<endl;
}


#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
using namespace std;
#define FOR(z,l,n) for(int z=l;z<n;z++)
#define pii pair<int,int>
#define mp make_pair
#define ll long long int
#define pll pair<long long,long long>
const bool debug = true;
int p[200001];
int pos[200001];
class seg_tree{
    int* st;
    int n;
    public:
     seg_tree(int a){
        st = new int[2*a];
        for(int i=0;i<2*a;i++)st[i]=0;
        n = a;
    }
    void set(int x){
        x+=n;
        st[x]=1;
        x/=2;
        while(x){
            st[x] = st[2*x]+st[2*x+1];
            x/=2;
        }
    }
    int query (int l,int r){
        l+=n;r+=n;
        int ans = 0;
        while(l<r){
            if(l&1){
                ans += st[l++];
            }
            if(r&1){
                ans += st[--r];
            }
            l>>=1;r>>=1;
        }
        return ans;
    }
};
class median{
    priority_queue<int,vector<int>,greater<int>> higher;
    priority_queue<int> lower;
    long long int suml,sumr;
public:
    median(){
        suml=0;sumr=0;
    }
    void insert(int n){
        if((lower.empty()&&higher.empty()) || n<lower.top()){
            lower.push(n);
            suml+=n;
            if(lower.size()>higher.size()+1){
                higher.push(lower.top());
                sumr+=lower.top();
                suml-=lower.top();
                lower.pop();
            }
        }
        else{
            higher.push(n);
            sumr+=n;
            if(higher.size()>lower.size()){
                lower.push(higher.top());
                suml+=higher.top();
                sumr-=higher.top();
                higher.pop();
            }
        }
    }
    int get_median(){
        return lower.top();
    }
    long long  get_swaps(){
        long long int n = lower.size();
        long long int l = lower.top()*n-suml - ((n)*(n-1))/2;
        n= higher.size();
        long long r = sumr - lower.top()*n - ((n)*(n+1))/2;
        return l+r;
    }
};
int main(){
    int n;
    cin>>n;
    FOR(z,1,n+1){cin>>p[z];pos[p[z]]=z;}
    seg_tree cind(n+1);
    median med;
    long long inv = 0;
    FOR(z,1,n+1){
        inv += cind.query(pos[z],n+1);
        //cout<<inv<<endl;
        cind.set(pos[z]);
        med.insert(pos[z]);
        cout<<inv+med.get_swaps()<<" ";
    }
    cout<<endl;
}


#include <iostream>
#include <algorithm>
#include <set>

long long int fenwick[200010];
int n;

long long int abss(long long int x)
{
    if (x < 0)
        return -x;
    else
        return x;
}

void add(int index)
{
    ++index;
    while (index <= n)
    {
        ++fenwick[index];
        index += index & -index;
    }
}

long long int sum(int index)
{
    ++index;
    long long int ans = 0;
    while (index > 0)
    {
        ans += fenwick[index];
        index -= index & -index;
    }

    return ans;
}

void cntInversions(int a[], long long int inversionCnt[], int where[])
{
    for (int i = 0; i < n; ++i)
    {
        if (i > 0)
        {
            inversionCnt[i] += inversionCnt[i - 1];
            inversionCnt[i] += i - sum(where[i]);
            add(where[i]);
        }
        else
            add(where[i]);
    }
}

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cin >> n;

    int where[200010], a[200010];
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a[i];
        --a[i];
        where[a[i]] = i;
    }

    long long int inversionCnt[200010] = { 0 };
    cntInversions(a, inversionCnt, where);

    std::set<long long int> seti;
    long long int cur = where[0];
    seti.insert(where[0]);
    long long int smaller = 0, bigger = 0;

    long long int ans = 0;

    std::cout << "0 ";
    for (int i = 1; i < n; ++i)
    {
        seti.insert(where[i]);
        ans += abss(where[i] - cur);
        ans -= inversionCnt[i - 1];
        ans += inversionCnt[i];
     //   std::cout << ans << "|";
        if (where[i] < cur)
        {
            ++smaller;
            if (smaller - bigger > 1)
            {
                auto it = seti.find(cur);
                --it;
                ans += (cur - *it) * (bigger + 1);
                ans -= (cur - *it) * smaller;
                --smaller;
                ++bigger;
                cur = *it;
            }
        }
        else if (where[i] > cur)
        {
            ++bigger;
            if (bigger - smaller > 1)
            {
                auto it = seti.find(cur);
                ++it;
                ans += (*it - cur) * (smaller + 1);
                ans -= (*it - cur) * bigger;
                --bigger;
                ++smaller;
                cur = *it;
            }
        }

        ans -= ((smaller) * (smaller + 1)) / 2;
        ans -= ((bigger) * (bigger + 1)) / 2;
        std::cout << ans << " ";
        ans += ((smaller) * (smaller + 1)) / 2;
        ans += ((bigger) * (bigger + 1)) / 2;
    }
}


#include <iostream>
#include <algorithm>
#include <set>

long long int fenwick[200010];
int n;

long long int abss(long long int x)
{
    if (x < 0)
        return -x;
    else
        return x;
}

void add(int index)
{
    ++index;
    while (index <= n)
    {
        ++fenwick[index];
        index += index & -index;
    }
}

long long int sum(int index)
{
    ++index;
    long long int ans = 0;
    while (index > 0)
    {
        ans += fenwick[index];
        index -= index & -index;
    }

    return ans;
}

void cntInversions(int a[], long long int inversionCnt[], int where[])
{
    for (int i = 0; i < n; ++i)
    {
        if (i > 0)
        {
            inversionCnt[i] += inversionCnt[i - 1];
            inversionCnt[i] += i - sum(where[i]);
            add(where[i]);
        }
        else
            add(where[i]);
    }
}

int main()
{
    std::cin >> n;

    int where[200010], a[200010];
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a[i];
        --a[i];
        where[a[i]] = i;
    }

    long long int inversionCnt[200010] = { 0 };
    cntInversions(a, inversionCnt, where);

    std::set<long long int> seti;
    long long int cur = where[0];
    seti.insert(where[0]);
    long long int smaller = 0, bigger = 0;

    long long int ans = 0;

    std::cout << "0 ";
    for (int i = 1; i < n; ++i)
    {
        seti.insert(where[i]);
        ans += abss(where[i] - cur);
        ans -= inversionCnt[i - 1];
        ans += inversionCnt[i];
     //   std::cout << ans << "|";
        if (where[i] < cur)
        {
            ++smaller;
            if (smaller - bigger > 1)
            {
                auto it = seti.find(cur);
                --it;
                ans += (cur - *it) * (bigger + 1);
                ans -= (cur - *it) * smaller;
                --smaller;
                ++bigger;
                cur = *it;
            }
        }
        else if (where[i] > cur)
        {
            ++bigger;
            if (bigger - smaller > 1)
            {
                auto it = seti.find(cur);
                ++it;
                ans += (*it - cur) * (smaller + 1);
                ans -= (*it - cur) * bigger;
                --bigger;
                ++smaller;
                cur = *it;
            }
        }

        ans -= ((smaller) * (smaller + 1)) / 2;
        ans -= ((bigger) * (bigger + 1)) / 2;
        std::cout << ans << " ";
        ans += ((smaller) * (smaller + 1)) / 2;
        ans += ((bigger) * (bigger + 1)) / 2;
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

long long int calc(std::vector< std::pair<int, int> >& vec)
{
    long long int ans = 0;
    for (int i = vec.size() - 1; i >= 0; --i)
    {
        std::pair<int, int> block = vec[i];
        if (block.first % 2 == 0 || block.second % 2 == 0)
            ans += (block.first * 1LL * block.second) / 2;
        else
        {
            if (i > 0)
            {
                std::pair<int, int> blockBefore = vec[i - 1];
                if ((blockBefore.first & 1) && (blockBefore.second & 1))
                {
                    ans += (block.first * 1LL * block.second) / 2 + (blockBefore.first * 1LL * blockBefore.second) / 2 + 1;
                    --i;
                }
            }
            else
                ans += (block.first * 1LL * block.second) / 2;
        }
    }

    return ans;
}

int main()
{
    int n;
    std::cin >> n;

    std::vector< std::pair<int, int> > vec;
    vec.push_back(std::make_pair(-1, -1));
    int a[300010];
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a[i];
        if (a[i] == vec.back().first)
            ++vec.back().second;
        else
            vec.push_back(std::make_pair(a[i], 1));
    }
    vec.erase(vec.begin());

    std::vector< std::pair<int, int> > vec2;
    vec2.push_back(std::make_pair(-1, -1));
    int i = 0;
    for (int j = a[0]; j >= 1; --j)
    {
        while (a[i] >= j) ++i;
        if (vec2.back().first == i)
            ++vec2.back().second;
        else
            vec2.push_back(std::make_pair(i, 1));
    }
    vec2.erase(vec.begin());

    long long int ans = std::max(calc(vec2), calc(vec));
    std::cout << ans;
}


#include <iostream>
#include <algorithm>
#include <set>

long long int fenwick[200010];
int n;

long long int abss(long long int x)
{
    if (x < 0)
        return -x;
    else
        return x;
}

void add(int index)
{
    ++index;
    while (index <= n)
    {
        ++fenwick[index];
        index += index & -index;
    }
}

long long int sum(int index)
{
    ++index;
    long long int ans = 0;
    while (index > 0)
    {
        ans += fenwick[index];
        index -= index & -index;
    }

    return ans;
}

void cntInversions(int a[], long long int inversionCnt[], int where[])
{
    for (int i = 0; i < n; ++i)
    {
        if (i > 0)
        {
            inversionCnt[i] += inversionCnt[i - 1];
            inversionCnt[i] += i - sum(where[i]);
            add(where[i]);
        }
        else
            add(where[i]);
    }
}

int main()
{
    std::cin >> n;

    int where[200010], a[200010];
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a[i];
        --a[i];
        where[a[i]] = i;
    }

    long long int inversionCnt[200010] = { 0 };
    cntInversions(a, inversionCnt, where);

    std::set<long long int> seti;
    long long int cur = where[0];
    seti.insert(where[0]);
    long long int smaller = 0, bigger = 0;

    long long int ans = 0;

    std::cout << "0 ";
    for (int i = 1; i < n; ++i)
    {
        ans += abss(where[i] - cur);
        ans -= inversionCnt[i - 1];
        ans += inversionCnt[i];
     //   std::cout << ans << "|";
        if (where[i] < cur)
        {
            ++smaller;
            if (smaller - bigger > 1)
            {
                auto it = seti.find(cur);
                --it;
                ans += (cur - *it) * (bigger + 1);
                ans -= (cur - *it) * smaller;
                --smaller;
                ++bigger;
                cur = *it;
            }
        }
        else if (where[i] > cur)
        {
            ++bigger;
            if (bigger - smaller > 1)
            {
                auto it = seti.find(cur);
                ++it;
                ans += (*it - cur) * (smaller + 1);
                ans -= (*it - cur) * bigger;
                --bigger;
                ++smaller;
                cur = *it;
            }
        }

        ans -= ((smaller) * (smaller + 1)) / 2;
        ans -= ((bigger) * (bigger + 1)) / 2;
        std::cout << ans << " ";
        ans += ((smaller) * (smaller + 1)) / 2;
        ans += ((bigger) * (bigger + 1)) / 2;
        seti.insert(where[i]);
    }
}


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

const int N = 200005;

int n, u, a[N];
long long ans = 0;

struct bit {
    long long bit[N];

    void update(int u, long long v) {
        for (; u <= n; u += u & -u) {
            bit[u] += v;
        }
    }

    long long query(int u) {
        long long ret = 0;
        for (; u > 0; u -= u & -u) {
            ret += bit[u];
        }
        return ret;
    }

    int binary_search(long long v) {
        int pos = 0;
        for (int i = __lg(N); i >= 0; i--) {
            if (pos + (1 << i) <= n && bit[pos + (1 << i)] < v) {
                pos += (1 << i);
                v -= bit[pos];
            }
        }
        return pos + 1;
    }
} pos, sum;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> u;
        a[u] = i;
    }
    for (int i = 1; i <= n; i++) {
        ans += i - 1 - pos.query(a[i]);
        pos.update(a[i], 1); sum.update(a[i], a[i]);
        int mid = pos.binary_search((i + 1) / 2), cnt = i / 2;
        long long cur = ans;
        cur += 1LL * (2 * mid - cnt + 1 - i % 2 * 2) * cnt / 2 - sum.query(mid - i % 2);
        cur += sum.query(n) - sum.query(mid) - 1LL * (2 * mid + cnt + 1) * cnt / 2;
        cout << cur << " ";
    }
}


#include <bits/stdc++.h>

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

const int N = 212345;

int loc[N], c[N];
int n;

inline int lowbit(int x) { return x & (-x); }

int sum(int pos) {
    int ans = 0;
    while (pos) {
        ans += c[pos];
        pos -= lowbit(pos);
    }
    return ans;
}

void add(int pos) {
    while (pos <= n) {
        ++c[pos];
        pos += lowbit(pos);
    }
}

LL lsum[N * 4], rsum[N * 4];
int ladd[N * 4], radd[N * 4];

LL query(int o, int l, int r, int ql, int qr, int *add, LL *sum) {
    if (ql <= l && r <= qr) return sum[o];
    int mid = l + (r - l) / 2;
    LL ans = 0;
    if (ql <= mid) ans += query(o * 2, l, mid, ql, qr, add, sum);
    if (qr > mid) ans += query(o * 2 + 1, mid + 1, r, ql, qr, add, sum);
    ans += LL(add[o]) * (min(r, qr) - max(l, ql) + 1);
    return ans;
}

void update(int o, int l, int r, int ql, int qr, int *add, LL *sum) {
    if (ql <= l && r <= qr) {
        ++add[o];
        sum[o] += r - l + 1;
    } else {
        int mid = l + (r - l) / 2;
        if (ql <= mid) update(o * 2, l, mid, ql, qr, add, sum);
        if (qr > mid) update(o * 2 + 1, mid + 1, r, ql, qr, add, sum);
        sum[o] = sum[o * 2] + sum[o * 2 + 1];
        sum[o] += LL(add[o]) * (r - l + 1);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        loc[x] = i;
    }

    LL inv = 0;

    for (int i = 1; i <= n; ++i) {
        int x = loc[i];
        inv += (i - 1) - sum(x);
        add(x);
        if (x > 1) update(1, 1, n, 1, x - 1, radd, rsum);
        if (x < n) update(1, 1, n, x + 1, n, ladd, lsum);

        int l = 1, r = n + 1;
        while (l < r) {
            int mid = l + (r - l) / 2;
            if (sum(mid) <= i / 2) l = mid + 1;
            else r = mid;
        }

        LL ans = 0, num = 0;
        if (l > 1) {
            ans += query(1, 1, n, 1, l - 1, ladd, lsum);
            num = sum(l - 1);
            ans -= num * (num - 1) / 2;
        }

        ans += query(1, 1, n, l, n, radd, rsum);
        num = i - num;
        ans -= num * (num - 1) / 2;
        cout << ans + inv << ' ';
    }
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define PI pair<int,int>
#define PL pair<LL,LL>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

const int MX = 2e5 + 5;
const int INF = 1e9 + 9;
int n;
LL Bit[MX];
LL Idx[MX];
LL Inv[MX];
LL Pos[MX];

vector<int> A;

void Add_Bit(int x,int val){
  for( ; x <= n + 1 ; x += x&-x)
    Bit[x] += val;
}

void Add_Idx(int x,int val){
  for( ; x <= n + 1 ; x += x&-x)
    Idx[x] += val;
}

LL Get_Bit(int x){
  LL res = 0;
  for( ; x > 0 ; x -= x&-x)
    res += Bit[x];
  return res;
}

LL Get_Idx(int x){
  LL res = 0;
  for( ; x > 0 ; x -= x&-x)
    res += Idx[x];
  return res;
}

void prep(){
  for(int i = 0 ; i <= n ; ++i){
    Bit[i] = 0;
    Idx[i] = 0;
    Pos[i] = 0;
  }
}

int main(){
  scanf("%d",&n);
  prep();
  for(int i = 0 ; i < n ; ++i){
    int x; scanf("%d",&x);
    A.push_back(x);
    Pos[x] = i + 1;
  }
  for(int i = n - 1 ; i >= 0 ; --i){
    Inv[A[i]] = Get_Bit(A[i]);
    Add_Bit(A[i],1);
  }
  for(int i = 1 ; i <= n ; ++i) {
    Bit[i] = 0;
  }
  LL ans = 0;
  LL L = INF;
  LL R = -1;
  LL sum = 0;
  for(int i = 1 ; i <= n ; ++i){
    sum += Inv[i];
    L = min(L,Pos[i]);
    R = max(R,Pos[i]);
    Add_Bit(Pos[i],1);
    Add_Idx(Pos[i],Pos[i]);
    int m = (L + R) >> 1;
    int Ri = Get_Bit(n) - Get_Bit(m);
    int Le = Get_Bit(m - 1);
    ans = 0;
    ans += Get_Idx(n) - Get_Idx(m) - Ri * (m + 1);
    ans += Le * (m - 1) - Get_Idx(m - 1);
    if(Get_Bit(m) - Get_Bit(m - 1) == 0)
      ans += min(Le,Ri);
    Ri--;Le--;
    ans -= Ri * (Ri + 1) / 2;
    ans -= Le * (Le + 1) / 2;
    cout << ans + sum << " ";
  }
  puts("");
}


#include <bits/stdc++.h>
#define LL long long
#define PI pair<int,int>
#define PL pair<LL,LL>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

const int MX = 2e5 + 5;

int n;
int Bit[MX];
int Idx[MX];
int Inv[MX];
int Pos[MX];

vector<int> A;

void Add_Bit(int x,int val){
  for( ; x <= n + 1 ; x += x&-x)
    Bit[x] += val;
}

void Add_Idx(int x,int val){
  for( ; x <= n + 1 ; x += x&-x)
    Idx[x] += val;
}

LL Get_Bit(int x){
  LL res = 0;
  for( ; x > 0 ; x -= x&-x)
    res += Bit[x];
  return res;
}

LL Get_Idx(int x){
  LL res = 0;
  for( ; x > 0 ; x -= x&-x)
    res += Idx[x];
  return res;
}

void prep(){
  for(int i = 0 ; i <= n ; ++i){
    Bit[i] = 0;
    Idx[i] = 0;
    Pos[i] = 0;
  }
}

int main(){
  scanf("%d",&n);
  prep();
  for(int i = 0 ; i < n ; ++i){
    int x; scanf("%d",&x);
    A.push_back(x);
    Pos[x] = i + 1;
  }
  for(int i = n - 1 ; i >= 0 ; --i){
    Inv[A[i]] = Get_Bit(A[i]);
    Add_Bit(A[i],1);
  }
  for(int i = 1 ; i <= n ; ++i) {
    Bit[i] = 0;
  }
  Add_Bit(Pos[1],1);
  Add_Idx(Pos[1],Pos[1]);
  LL ans = Inv[1];
  int L = Pos[1];
  int R = Pos[1];
  cout << Inv[1] << " ";
  for(int i = 2 ; i <= n ; ++i){
    ans += Inv[i];
    L = min(L,Pos[i]);
    R = max(R,Pos[i]);
    Add_Bit(Pos[i],1);
    Add_Idx(Pos[i],Pos[i]);
    int m = (L + R) >> 1;

    int Ri = Get_Bit(n) - Get_Bit(m);
    int Le = Get_Bit(m - 1);
    ans += Get_Idx(n) - Get_Idx(m) - (Ri-1) * m;
    ans += Le * m - Get_Idx(m);
    ans -= Ri * (Ri + 1) / 2;
    ans -= Le * (Le + 1) / 2;
    cout << ans << " ";
  }
  puts("");
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define LL long long
#define PI pair<int,int>
#define PL pair<LL,LL>
#define st first
#define nd second
#define all(x) x.begin(),x.end()

using namespace __gnu_pbds;
using namespace std;

typedef tree<LL,null_type,less<LL>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int MX = 2e5 + 5;
const int INF = 1e9 + 9;
int n;
LL Bit[MX];
LL Idx[MX];
LL Inv[MX];
LL Pos[MX];

vector<LL> A;

void Add_Bit(int x,int val){
  for( ; x <= n + 1 ; x += x&-x)
    Bit[x] += val;
}

void Add_Idx(int x,int val){
  for( ; x <= n + 1 ; x += x&-x)
    Idx[x] += val;
}

LL Get_Bit(int x){
  LL res = 0;
  for( ; x > 0 ; x -= x&-x)
    res += Bit[x];
  return res;
}

LL Get_Idx(int x){
  LL res = 0;
  for( ; x > 0 ; x -= x&-x)
    res += Idx[x];
  return res;
}

void prep(){
  for(int i = 0 ; i <= n + 1; ++i){
    Bit[i] = 0;
    Idx[i] = 0;
    Pos[i] = 0;
  }
}

int main(){
  scanf("%d",&n);
  prep();
  for(int i = 0 ; i < n ; ++i){
    int x; scanf("%d",&x);
    A.push_back(x);
    Pos[x] = i + 1;
  }
  for(int i = n - 1 ; i >= 0 ; --i){
    Inv[A[i]] = Get_Bit(A[i]);
    Add_Bit(A[i],1);
  }
  for(int i = 0 ; i <= n ; ++i) {
    Bit[i] = 0;
  }
  LL ans = 0;
  LL sum = 0;
  ordered_set S;
  for(int i = 1 ; i <= n ; ++i){
    sum += Inv[i];
    S.insert(Pos[i]);
    Add_Bit(Pos[i],1);
    Add_Idx(Pos[i],Pos[i]);
    LL m = *S.find_by_order(i / 2);
    LL Ri = Get_Bit(n) - Get_Bit(m);
    LL Le = Get_Bit(m - 1);
    ans = 0;
    ans += Get_Idx(n) - Get_Idx(m) - Ri * (m + 1);
    ans += Le * (m - 1) - Get_Idx(m - 1);
    if(Get_Bit(m) - Get_Bit(m - 1) == 0)
      ans += min(Le,Ri);
    Ri--;Le--;
    ans -= Ri * (Ri + 1) / 2;
    ans -= Le * (Le + 1) / 2;
    cout << ans + sum << " ";
  }
  puts("");
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define LL long long
#define PI pair<int,int>
#define PL pair<LL,LL>
#define st first
#define nd second
#define all(x) x.begin(),x.end()

using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int MX = 2e5 + 5;
const int INF = 1e9 + 9;
int n;
LL Bit[MX];
LL Idx[MX];
LL Inv[MX];
LL Pos[MX];

vector<int> A;

void Add_Bit(int x,int val){
  for( ; x <= n + 1 ; x += x&-x)
    Bit[x] += val;
}

void Add_Idx(int x,int val){
  for( ; x <= n + 1 ; x += x&-x)
    Idx[x] += val;
}

LL Get_Bit(int x){
  LL res = 0;
  for( ; x > 0 ; x -= x&-x)
    res += Bit[x];
  return res;
}

LL Get_Idx(int x){
  LL res = 0;
  for( ; x > 0 ; x -= x&-x)
    res += Idx[x];
  return res;
}

void prep(){
  for(int i = 0 ; i <= n + 1; ++i){
    Bit[i] = 0;
    Idx[i] = 0;
    Pos[i] = 0;
  }
}

int main(){
  scanf("%d",&n);
  prep();
  for(int i = 0 ; i < n ; ++i){
    int x; scanf("%d",&x);
    A.push_back(x);
    Pos[x] = i + 1;
  }
  for(int i = n - 1 ; i >= 0 ; --i){
    Inv[A[i]] = Get_Bit(A[i]);
    Add_Bit(A[i],1);
  }
  for(int i = 0 ; i <= n ; ++i) {
    Bit[i] = 0;
  }
  LL ans = 0;
  LL sum = 0;
  ordered_set S;
  for(int i = 1 ; i <= n ; ++i){
    sum += Inv[i];
    S.insert(Pos[i]);
    Add_Bit(Pos[i],1);
    Add_Idx(Pos[i],Pos[i]);
    int m = *S.find_by_order(i / 2);
    int Ri = Get_Bit(n) - Get_Bit(m);
    int Le = Get_Bit(m - 1);
    ans = 0;
    ans += Get_Idx(n) - Get_Idx(m) - Ri * (m + 1);
    ans += Le * (m - 1) - Get_Idx(m - 1);
    if(Get_Bit(m) - Get_Bit(m - 1) == 0)
      ans += min(Le,Ri);
    Ri--;Le--;
    ans -= Ri * (Ri + 1) / 2;
    ans -= Le * (Le + 1) / 2;
    cout << ans + sum << " ";
  }
  puts("");
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+7;
int n;
long long a[maxn],c[maxn];
long long b1[maxn],b2[maxn];
void add(long long *b,int i,long long x){
    for(;i<=n;i+=i&(-i))
        b[i]+=x;
}
long long query(long long *b,long long i){
    int ans=0;
    for(;i;i-=i&-i){
        ans+=b[i];
    }
    return ans;
}
long long bs(long long *b,long long x){
    long long i=0;
    for(int j=20;j>=0;j--){
        if((i|1<<j)<=n){
            if(b[i|1<<j]<=x){
                x-=b[i|=1<<j];
            }
        }
    }
    return i;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        c[a[i]]=i;
    }
    long long cnt = 0;
    for(int i=1;i<=n;i++){
        int p = c[i];
        add(b1,p,1);
        cnt+=i-query(b1,p);
        add(b2,p,p);
        long long pos=bs(b1,i/2)+1;
        //cout<<pos<<" "<<cnt<<endl;
        long long sum = 0;
        long long aa=i/2;
        long long bb=i-i/2-1;
		sum+=-(long long)aa*(aa+1)/2-query(b2,pos-1)+(long long)aa*pos;
		sum+=-(long long)bb*pos-(long long)bb*(bb+1)/2+(query(b2,n)-query(b2,pos));
        cout<<sum+cnt<<" ";
    }
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define MN 200005
#define ll long long
#define mod 998244353
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
typedef pair<int,int> pii;
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
int n;
int a[MN],c[MN];
ll b1[MN],b2[MN];
inline void add(ll*b,int i,ll x){for(;i<=n;i+=i&-i)b[i]+=x;}
inline ll qur(ll*b,int i){ll a=0;for(;i;i-=i&-i)a+=b[i];return a;}
inline int bs(ll*b,ll x){
	int i=0;
	dF(j,19,0)if((i|1<<j)<=n){if(b[i|1<<j]<=x)x-=b[i|=1<<j];}
	return i;
}
int main(){
	scanf("%d",&n);
	F(i,1,n)scanf("%d",a+i),c[a[i]]=i;
	ll cnt=0;
	F(i,1,n){
		int p=c[i];
		add(b1,p,1);
		cnt+=i-qur(b1,p);
		add(b2,p,p);
		int pos=bs(b1,i/2)+1;
//		printf("%lld,%d\n",cnt,pos);
		ll sum=0;
		ll aa=i/2,bb=i-i/2-1;
		sum+=(ll)aa*pos-(ll)aa*(aa+1)/2-qur(b2,pos-1);
		sum+=(qur(b2,n)-qur(b2,pos))-(ll)bb*pos-(ll)bb*(bb+1)/2;
		printf("%lld\n",sum+cnt);
	}
	return 0;
}