import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; 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() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); 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(0, (int) A[i]); 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)); } }