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> dp = new ArrayList<>(); dp.add(new TreeMap<>()); dp.get(0).put(Integer.MIN_VALUE, 1); for (int i = 0; i < n; i++) { int x = sc.nextInt(); int left = 0; int right = dp.size(); while (right - left > 1) { int m = (left + right) / 2; boolean flag = true; if (dp.get(m).firstKey() < x) { left = m; } else { right = m; } } int count = 0; for (Map.Entry entry : dp.get(left).entrySet()) { if (entry.getKey() < x) { count += entry.getValue(); count %= MOD; } else { break; } } if (dp.size() <= left + 1) { dp.add(new TreeMap<>()); } if (dp.get(left + 1).containsKey(x)) { dp.get(left + 1).put(x, (dp.get(left + 1).get(x) + count) % MOD); } else { dp.get(left + 1).put(x, count); } } int total = 0; for (int x : dp.get(dp.size() - 1).values()) { total += x; total %= MOD; } System.out.println(total); } }