import java.util.Scanner;

class Main {
	// ???????????????????????§???????????????????????°????????????????????°
	private static long count = 0;
	//????????????????´?????????§???+1????????????????????°
	private static int max = -1;
	private static int temp1 = Integer.MAX_VALUE;
	private static int temp2 = Integer.MAX_VALUE;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		//??\????????????????????????????´????????????????????´?????????°???????????????????????????????????§???+ 1????±???????
		int n = scanner.nextInt();
		int[] numList = new int[n];
		int[] numList2 = new int[n];
		for (int i = 0; i < n; i++) {
			numList[i] = scanner.nextInt();
			numList2[i] = numList[i];
			if (max < numList[i]) {
				max = numList[i] + 1;
			}
		}
		scanner.close();
		
		// ?????????????????????????????? ?????°???????±???????(numList)????????????????°????????´???????(0)?????????????????§???????´???????(n)?????????
		mergeSort(numList, 0, n);
		//Tool.bubleSort(numList2, n);
/*	System.out.print(numList[0]);
		for (int i = 1; i < n; i++) {
			System.out.print(" " + numList[i]);
		}
		System.out.println();*/
		System.out.println(count);
	}

	// ???????????????(mid)???????????????L??¨R????????????????´?????????? L??¨R????????????????´???°???????????¨?????????
	// L??¨R??????????´?????????????????°????????????????numList???????´???????????????£??????????´?+1?????§????????§??????????????????????????????????´?????????§???
	// +1(max)????????????????????????????´?????????????
	static void merge(int[] numList, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		int[] L = new int[n1 + 1];
		int[] R = new int[n2 + 1];

		for (int i = 0; i < n1; i++) {
			L[i] = numList[left + i];
		}

		for (int i = 0; i < n2; i++) {
			R[i] = numList[mid + i];
		}

		L[n1] = Integer.MAX_VALUE;
		R[n2] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		// L??¨R??????????????????????°????????????????numList???????´??????????
		// ?°?????????????????????????????????????????¬??????????????????????????????????????´????????????????????????°?????????+1?????????
		for (int k = left; k < right; k++) {
			if (L[i] < R[j]) {
				numList[k] = L[i];
				i = i + 1;
				count = count + j;
			} else {	
				numList[k] = R[j];
				j = j + 1;
			}
		}
	}

	// ????¨????merge???????????????????±??????????????°?????´???????(left)??¨?????§????´???????(right)?????????-1??????????????§??°????????????
	static void mergeSort(int[] numList, int left, int right) {
		if ((left + 1) < right) {
			int mid = (left + right) / 2;

			mergeSort(numList, left, mid);
			// System.out.println("???");
			mergeSort(numList, mid, right);
			// System.out.println("???");
			merge(numList, left, mid, right);
		}
	}
}

class Tool {
	static void bubleSort(int[] numList, int count) { // ?????°???????±?????????????????´????????????????(numList)??¨?????????????????°???????´???????????????°(count)?????????
		StringBuffer sb = new StringBuffer();
		int flag = 0; // ???????????°???????´????????????°
		for (int i = 0; i < count; i++) {// ??????????????°(count)????????????????????????
			for (int j = count - 1; j > i; j--) {
				if (numList[j - 1] > numList[j]) { //????????????index???????´???????????????????????????¨???????????????????????????????´????????????????????????????????????§????????´????????\??????????????????
					int temp = numList[j];     
					numList[j] = numList[j - 1];
					numList[j - 1] = temp;
					flag++;
					j = count;
				}
			}
		}
		System.out.println("??????????????????:" + flag); //??????
	}
}

Measured memory_bytes: 102252