from collections import defaultdict

import sys



sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

p2D = lambda x: print(*x, sep="\n")



def main():

    md = 10 ** 9 + 7

    n = int(input())

    cc = [int(input()) for _ in range(n)]

    dp = [0] * (n + 1)

    dp[0] = 1

    ll = defaultdict(int)

    pc = -1

    for r, c in enumerate(cc):

        dp[r + 1] = dp[r]

        if c == pc: continue

        dp[r + 1] = (dp[r + 1] + ll[c]) % md

        ll[c] = (ll[c] + dp[r]) % md

        pc = c

    print(dp[n])



main()

import sys



sys.setrecursionlimit(10 ** 5)

int1 = lambda x: int(x) - 1

p2D = lambda x: print(*x, sep="\n")

def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return sys.stdin.readline()[:-1]



def main():

    n=II()

    aa=[]

    cnt=[0]*200005

    for _ in range(n):

        c=II()

        if not aa or aa[-1]!=c:aa.append(c)

    #print(aa)

    md=10**9+7

    ans=1

    for a in aa:

        cnt[a]=(cnt[a]+ans)%md

        ans=cnt[a]

    print(ans)



main()

from collections import defaultdict
import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")


def main():
    md = 10**9 + 7
    n = int(input())
    cc = [int(input()) for _ in range(n)]
    dp = [0] * (n + 1)
    dp[0] = 1
    ll = defaultdict(int)
    pc = -1
    for r, c in enumerate(cc):
        dp[r + 1] = dp[r]
        if c == pc:
            continue
        dp[r + 1] = (dp[r + 1] + ll[c]) % md
        ll[c] = (ll[c] + dp[r]) % md
        pc = c
    print(dp[n])


main()

import sys

sys.setrecursionlimit(10**5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number):
    return [LI() for _ in range(rows_number)]


def SI():
    return sys.stdin.readline()[:-1]


def main():
    n = II()
    aa = []
    cnt = [0] * 200005
    for _ in range(n):
        c = II()
        if not aa or aa[-1] != c:
            aa.append(c)
    # print(aa)
    md = 10**9 + 7
    ans = 1
    for a in aa:
        cnt[a] = (cnt[a] + ans) % md
        ans = cnt[a]
    print(ans)


main()

-from collections import defaultdict -sys.setrecursionlimit(10**6) +sys.setrecursionlimit(10**5) +def II(): +    return int(sys.stdin.readline()) + + +def MI(): +    return map(int, sys.stdin.readline().split()) + + +def LI(): +    return list(map(int, sys.stdin.readline().split())) + + +def LLI(rows_number): +    return [LI() for _ in range(rows_number)] + + +def SI(): +    return sys.stdin.readline()[:-1] + + +    n = II() +    aa = [] +    cnt = [0] * 200005 +    for _ in range(n): +        c = II() +        if not aa or aa[-1] != c: +            aa.append(c) +    # print(aa) -    n = int(input()) -    cc = [int(input()) for _ in range(n)] -    dp = [0] * (n + 1) -    dp[0] = 1 -    ll = defaultdict(int) -    pc = -1 -    for r, c in enumerate(cc): -        dp[r + 1] = dp[r] -        if c == pc: -            continue -        dp[r + 1] = (dp[r + 1] + ll[c]) % md -        ll[c] = (ll[c] + dp[r]) % md -        pc = c -    print(dp[n]) +    ans = 1 +    for a in aa: +        cnt[a] = (cnt[a] + ans) % md +        ans = cnt[a] +    print(ans)