import java.util.*; import java.io.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); ArrayList> list = new ArrayList<>(); list.add(new TreeMap<>()); list.get(0).put(Integer.MIN_VALUE, 1); String[] line = br.readLine().split(" ", n); for (int i = 0; i < n; i++) { int x = Integer.parseInt(line[i]); int left = 0; int right = list.size(); while (right - left > 1) { int m = (left + right) / 2; if (list.get(m).firstKey() >= x) { right = m; } else { left = m; } } if (left == list.size() - 1) { list.add(new TreeMap<>()); } int count = 0; for (Map.Entry entry : list.get(left).entrySet()) { if (entry.getKey() >= x) { break; } count += entry.getValue(); count %= MOD; } if (list.get(left + 1).containsKey(x)) { list.get(left + 1).put(x, (list.get(left + 1).get(x) + count) % MOD); } else { list.get(left + 1).put(x, count); } } int sum = 0; for (int x : list.get(list.size() - 1).values()) { sum += x; sum %= MOD; } System.out.println(sum); } }