import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { class BIT { int n; int[] a; public BIT(int n_) { n = n_; a = new int[n + 1]; } void add(int k, int add) { ++k; while (k < a.length) { a[k] += add; k += k & -k; } } int sum(int k) { ++k; int ret = 0; while (k > 0) { ret += a[k]; k -= k & -k; } return ret; } int sum(int a, int b) { return sum(b - 1) - sum(a - 1); } } void run() { FastScanner sc = new FastScanner(); int N = (int) sc.nextLong(); long[] A = new long[N]; for (int i = 0; i < N; ++i) { A[i] = sc.nextLong(); } A = shrink(A); long sum = 0; BIT bit = new BIT(A.length); for (int i = 0; i < N; ++i) { sum += bit.sum((int) A[i] + 1, N); bit.add((int) A[i], 1); } PrintWriter pw = new PrintWriter(System.out); pw.println(sum); for (int i = 0; i < N - 1; i++) { sum -= bit.sum(0, (int) A[i]); sum += bit.sum((int) A[i] + 1, N); pw.println(sum); } pw.close(); } long[] shrink(long[] A) { int N = A.length; long[] ret = new long[N]; long[][] B = new long[N][2]; for (int i = 0; i < N; ++i) { B[i][0] = i; B[i][1] = A[i]; } Arrays.sort(B, new Comparator() { @Override public int compare(long[] o1, long[] o2) { return Long.compare(o1[1], o2[1]); } }); int p = 0; for (int i = 0; i < N; ++i) { ret[(int) B[i][0]] = p; if (i + 1 < N && B[i][1] == B[i + 1][1]) { continue; } ++p; } return ret; } public static void main(String[] args) { new Main().run(); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } public boolean hasNext() { skipUnprintable(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } } }