import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
static long result=0;
public static void merge_sort(int q[],int l,int r) {
if(l>=r) {
return;
}
int mid=l+r>>1;
int k=0;int[] temp=new int[r-l+1];
int i=l;int j=mid+1;
merge_sort(q,l,mid);
merge_sort(q,mid+1,r);
while(i<=mid&&j<=r) {
if(q[i]<=q[j]) {
temp[k++]=q[i++];
}
else {
temp[k++]=q[j++];
result+=mid-i+1;
}
}
while(i<=mid) {
temp[k++]=q[i++];
}
while(j<=r) {
temp[k++]=q[j++];
}
for(int w=l,e=0;w<=r;w++,e++) {
q[w]=temp[e];
}
}
public static void main(String[] args) {
Scanner scan=new Scanner(new InputStreamReader(System.in));
int n=scan.nextInt();
int[] arr=new int [n];
for(int i=0;i<n;i++) {
arr[i]=scan.nextInt();
}
merge_sort(arr,0,n-1);
System.out.print(result);
scan.close();
}
}