import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int []a = new int[n]; List list = new ArrayList(); for(int i = 0; i < n; i++) { a[i] = sc.nextInt(); list.add(a[i]); } sc.close(); Collections.sort(list); BIT bitC = new BIT(n); int ans = 0; for(int i = 0; i < n; i++) { a[i] = Collections.binarySearch(list, a[i]) + 1; ans += i - bitC.sum(a[i]); bitC.add(a[i], 1); } System.out.println(ans); } static class BIT{ int []bit; int n; public BIT(int n) { this.n = n; bit = new int[n + 1]; } int sum(int i) { int sum = 0; while(i > 0) { sum += bit[i]; i -= i & -i; } return sum; } void add(int i, int x) { while(i <= n) { bit[i] += x; i += i & -i; } } } }