import sys, re

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd

from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from bisect import bisect, bisect_left

from heapq import heappush, heappop

from functools import reduce

def input(): return sys.stdin.readline().strip()

def INT(): return int(eval(input()))

def MAP(): return list(map(int, input().split()))

def LIST(): return list(map(int, input().split()))

def ZIP(n): return list(zip(*(MAP() for _ in range(n))))

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

mod = 10 ** 9 + 7



N = INT()

tmp = -1

c = []

for _ in range(N):

	C = INT()

	if C != tmp:

		c.append(C)

	tmp = C



n = len(c)

dic = defaultdict(int)



dp = [0]*(n+1)

dp[0] = 1



for i in range(n):

	dp[i+1] = (dp[i] + dic[c[i]])%mod

	dic[c[i]] = (dic[c[i]] + dp[i])%mod



print((dp[-1]))

import sys, re

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd

from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from bisect import bisect, bisect_left

from heapq import heappush, heappop

from functools import reduce

def input(): return sys.stdin.readline().strip()

def INT(): return int(eval(input()))

def MAP(): return list(map(int, input().split()))

def LIST(): return list(map(int, input().split()))

def ZIP(n): return list(zip(*(MAP() for _ in range(n))))

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

mod = 10 ** 9 + 7



N = INT()

C = [INT() for _ in range(N)]



dp = [0]*(N+1)

dp[0] = 1

dp2 = [-1]*(max(C)+1) #前に色iが出てきたインデックスの保存



for i in range(1, N+1):

	p = dp2[C[i-1]]  # 色C[i-1]が前に出てきたインデックス

	if 1 < i-p and p != -1:

		dp[i] += dp[p]

	dp2[C[i-1]] = i

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

	dp[i] %= mod



print((dp[N]))

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import (
    accumulate,
    permutations,
    combinations,
    product,
    groupby,
    combinations_with_replacement,
)
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce


def input():
    return sys.stdin.readline().strip()


def INT():
    return int(eval(input()))


def MAP():
    return list(map(int, input().split()))


def LIST():
    return list(map(int, input().split()))


def ZIP(n):
    return list(zip(*(MAP() for _ in range(n))))


sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
tmp = -1
c = []
for _ in range(N):
    C = INT()
    if C != tmp:
        c.append(C)
    tmp = C
n = len(c)
dic = defaultdict(int)
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
    dp[i + 1] = (dp[i] + dic[c[i]]) % mod
    dic[c[i]] = (dic[c[i]] + dp[i]) % mod
print((dp[-1]))

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import (
    accumulate,
    permutations,
    combinations,
    product,
    groupby,
    combinations_with_replacement,
)
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce


def input():
    return sys.stdin.readline().strip()


def INT():
    return int(eval(input()))


def MAP():
    return list(map(int, input().split()))


def LIST():
    return list(map(int, input().split()))


def ZIP(n):
    return list(zip(*(MAP() for _ in range(n))))


sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
C = [INT() for _ in range(N)]
dp = [0] * (N + 1)
dp[0] = 1
dp2 = [-1] * (max(C) + 1)  # 前に色iが出てきたインデックスの保存
for i in range(1, N + 1):
    p = dp2[C[i - 1]]  # 色C[i-1]が前に出てきたインデックス
    if 1 < i - p and p != -1:
        dp[i] += dp[p]
    dp2[C[i - 1]] = i
    dp[i] += dp[i - 1]
    dp[i] %= mod
print((dp[N]))

-tmp = -1 -c = [] -for _ in range(N): -    C = INT() -    if C != tmp: -        c.append(C) -    tmp = C -n = len(c) -dic = defaultdict(int) -dp = [0] * (n + 1) +C = [INT() for _ in range(N)] +dp = [0] * (N + 1) -for i in range(n): -    dp[i + 1] = (dp[i] + dic[c[i]]) % mod -    dic[c[i]] = (dic[c[i]] + dp[i]) % mod -print((dp[-1])) +dp2 = [-1] * (max(C) + 1)  # 前に色iが出てきたインデックスの保存 +for i in range(1, N + 1): +    p = dp2[C[i - 1]]  # 色C[i-1]が前に出てきたインデックス +    if 1 < i - p and p != -1: +        dp[i] += dp[p] +    dp2[C[i - 1]] = i +    dp[i] += dp[i - 1] +    dp[i] %= mod +print((dp[N]))