mod = 10**9+7 class Bit: def __init__(self, n): self.size = n self.tree = [(0, 1) for _ in range(n+1)] def sum(self, i): s = (0, 1) while i > 0: if s[0] == self.tree[i][0]: s = (s[0], (self.tree[i][1] + s[1])%mod) elif s[0] < self.tree[i][0]: s = self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: if x[0] == self.tree[i][0]: self.tree[i] = (x[0], (self.tree[i][1] + x[1])%mod) elif x[0] > self.tree[i][0]: self.tree[i] = (x[0], x[1]) i += i & -i N, = map(int, input().split()) As = map(int, input().split()) bit = Bit(N) for a in As: a0, co = bit.sum(a-1) bit.add(a, (a0+1, co)) print(bit.sum(N)[1]%mod)