import java.util.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] arr = new int[n]; long ans = 0; TreeMap map = new TreeMap<>(); for (int i = 0; i < n; i++) { arr[i] = Integer.parseInt(br.readLine()); map.put(arr[i], 0); } int idx = 1; for (int x : map.keySet()) { map.put(x, idx); idx++; } BinaryIndexedTree bit = new BinaryIndexedTree(idx); long total = 0; for (int i = 0; i < n; i++) { total += bit.getSum(idx - 1) - bit.getSum(map.get(arr[i])); bit.add(map.get(arr[i]), 1); } StringBuilder sb = new StringBuilder(); int[] counts = new int[idx]; for (int i = 0; i < idx; i++) { counts[i] = bit.getSum(i); } sb.append(total).append("\n"); for (int i = 0; i < n - 1; i++) { total -= counts[map.get(arr[i]) - 1]; total += counts[idx - 1] - counts[map.get(arr[i])]; sb.append(total).append("\n"); } System.out.print(sb); } } class BinaryIndexedTree { int size; int[] tree; public BinaryIndexedTree(int size) { this.size = size; tree = new int[size]; } public void add(int idx, int value) { int mask = 1; while (idx < size) { if ((idx & mask) != 0) { tree[idx] += value; idx += mask; } mask <<= 1; } } public int getSum(int from, int to) { return getSum(to) - getSum(from - 1); } public int getSum(int x) { int mask = 1; int ans = 0; while (x > 0) { if ((x & mask) != 0) { ans += tree[x]; x -= mask; } mask <<= 1; } return ans; } }