from collections import defaultdict

from bisect import *

def solve():

    mod = 10**9+7

    d = defaultdict(lambda: [])

    N = int(eval(input()))

    for i in range(N):

        a = int(eval(input()))

        d[a].append(i)

    selist = [[-1,-1]]

    ends = [-1]

    for l in list(d.values()):

        for i in range(len(l)-1):

            if l[i+1]-1>l[i]:

                selist.append([l[i],l[i+1]])

                ends.append(l[i+1])

    selist = sorted(selist,key=lambda x:x[1])

    ends.sort()

    dp = [0]*(len(selist))

    for i in range(1,len(selist)):

        dp[i] = dp[i-1]+1

        ind = bisect_right(ends,selist[i][0])

        dp[i] += dp[ind-1]

        dp[i] %= mod

    ans = dp[-1]+1

    ans %= mod

    return ans

print((solve()))

from collections import defaultdict

def solve():

  ans = 0

  N = int(eval(input()))

  C = [int(eval(input())) for _ in range(N)]

  d = defaultdict(lambda: -1)

  dp = [1]*N

  d[C[0]] = 0

  mod = 10**9+7

  for i in range(1,N):

    dp[i] = dp[i-1]

    if d[C[i]]>-1 and d[C[i]]!=i-1:

      dp[i] += dp[d[C[i]]]

      dp[i] %= mod

    d[C[i]] = i

  return dp[-1]

print((solve()))
from collections import defaultdict
from bisect import *


def solve():
    mod = 10**9 + 7
    d = defaultdict(lambda: [])
    N = int(eval(input()))
    for i in range(N):
        a = int(eval(input()))
        d[a].append(i)
    selist = [[-1, -1]]
    ends = [-1]
    for l in list(d.values()):
        for i in range(len(l) - 1):
            if l[i + 1] - 1 > l[i]:
                selist.append([l[i], l[i + 1]])
                ends.append(l[i + 1])
    selist = sorted(selist, key=lambda x: x[1])
    ends.sort()
    dp = [0] * (len(selist))
    for i in range(1, len(selist)):
        dp[i] = dp[i - 1] + 1
        ind = bisect_right(ends, selist[i][0])
        dp[i] += dp[ind - 1]
        dp[i] %= mod
    ans = dp[-1] + 1
    ans %= mod
    return ans


print((solve()))

from collections import defaultdict


def solve():
    ans = 0
    N = int(eval(input()))
    C = [int(eval(input())) for _ in range(N)]
    d = defaultdict(lambda: -1)
    dp = [1] * N
    d[C[0]] = 0
    mod = 10**9 + 7
    for i in range(1, N):
        dp[i] = dp[i - 1]
        if d[C[i]] > -1 and d[C[i]] != i - 1:
            dp[i] += dp[d[C[i]]]
            dp[i] %= mod
        d[C[i]] = i
    return dp[-1]


print((solve()))

-from bisect import * +    ans = 0 +    N = int(eval(input())) +    C = [int(eval(input())) for _ in range(N)] +    d = defaultdict(lambda: -1) +    dp = [1] * N +    d[C[0]] = 0 -    d = defaultdict(lambda: []) -    N = int(eval(input())) -    for i in range(N): -        a = int(eval(input())) -        d[a].append(i) -    selist = [[-1, -1]] -    ends = [-1] -    for l in list(d.values()): -        for i in range(len(l) - 1): -            if l[i + 1] - 1 > l[i]: -                selist.append([l[i], l[i + 1]]) -                ends.append(l[i + 1]) -    selist = sorted(selist, key=lambda x: x[1]) -    ends.sort() -    dp = [0] * (len(selist)) -    for i in range(1, len(selist)): -        dp[i] = dp[i - 1] + 1 -        ind = bisect_right(ends, selist[i][0]) -        dp[i] += dp[ind - 1] -        dp[i] %= mod -    ans = dp[-1] + 1 -    ans %= mod -    return ans +    for i in range(1, N): +        dp[i] = dp[i - 1] +        if d[C[i]] > -1 and d[C[i]] != i - 1: +            dp[i] += dp[d[C[i]]] +            dp[i] %= mod +        d[C[i]] = i +    return dp[-1]