import java.util.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayList> list = new ArrayList<>(); list.add(new TreeMap<>()); list.get(0).put(Integer.MIN_VALUE, 1); 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).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); } }