import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayList list = new ArrayList<>(); list.add(0); list.add(Integer.MAX_VALUE); long total = 0; for (int i = 0; i < n; i++) { int x = sc.nextInt(); int left = 0; int right = list.size(); while (right - left > 1) { int m = (left + right) / 2; if (list.get(m) < x) { left = m; } else { right = m; } } list.add(right, x); total += list.size() - right - 2; } System.out.println(total); } }