import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayList> lists = new ArrayList<>(); lists.add(new TreeMap<>()); for (int i = 0; i < n; i++) { int x = sc.nextInt(); for (int j = lists.size() - 1; j >= 0; j--) { TreeMap target = lists.get(j); Map map = target.headMap(x); if (map.size() == 0) { if (j == 0) { if (target.containsKey(x)) { target.put(x, target.get(x) + 1); } else { target.put(x, 1); } } } else { int count = 0; for (int y : map.values()) { count += y; } if (j == lists.size() - 1) { TreeMap tmp = new TreeMap<>(); tmp.put(x, count); lists.add(tmp); } else { TreeMap tmp = lists.get(j + 1); if (tmp.containsKey(x)) { tmp.put(x, tmp.get(x) + count); } else { tmp.put(x, count); } } break; } } } long total = 0; for (int x : lists.get(lists.size() - 1).values()) { total += x; } System.out.println(total); } }