import sys

from bisect import bisect_left as bl

from bisect import bisect_right as br

input = sys.stdin.readline

N = int(eval(input()))

table = [[] for _ in range(2 * pow(10, 5) + 1)]

a = []

t = 0

mod = 10 ** 9 + 7

for i in range(N):

  x = int(eval(input()))

  if t != x:

    table[x].append(i)

    t = x

  a.append(x)

#print(table[4], table[3])

dp = [0] * N

dp[0] = 1

for i in range(N):

  j = br(table[a[i]], i)

  k = bl(table[a[i]], i)

  if j < len(table[a[i]]) and (table[a[i]][k] == i):

    dp[table[a[i]][j]] += dp[i]

    dp[table[a[i]][j]] %= mod

  if i + 1 < N: 

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

    dp[i + 1] %= mod

  #print(dp)

print((dp[-1]))
import sys

from bisect import bisect_right as br

from bisect import bisect_left as bl

input = sys.stdin.readline

N = int(eval(input()))

mod = 10 ** 9 + 7

a = []

for _ in range(N): a.append(int(eval(input())))

t = 0

table = [[] for _ in range(max(a) + 1)]

for i in range(N):

  if a[i] != t:

    t = a[i]

    table[a[i]].append(i)

dp = [0] * N

dp[0] = 1

#print(table)

#print(a)

for i in range(N):

  r = br(table[a[i]], i)

  l = bl(table[a[i]], i)

  if r < len(table[a[i]]) and (table[a[i]][l] == i):

    dp[table[a[i]][r]] += dp[i]

    dp[table[a[i]][r]] %= mod

    """

    for k in range(j, len(table[a[i]])):

      print(i, table[a[i]][k])

      dp[table[a[i]][k]] += dp[i]

      dp[table[a[i]][k]] %= mod

    """

  if i + 1 < N:

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

    dp[i + 1] %= mod

print((dp[-1]))
import sys
from bisect import bisect_left as bl
from bisect import bisect_right as br

input = sys.stdin.readline
N = int(eval(input()))
table = [[] for _ in range(2 * pow(10, 5) + 1)]
a = []
t = 0
mod = 10**9 + 7
for i in range(N):
    x = int(eval(input()))
    if t != x:
        table[x].append(i)
        t = x
    a.append(x)
# print(table[4], table[3])
dp = [0] * N
dp[0] = 1
for i in range(N):
    j = br(table[a[i]], i)
    k = bl(table[a[i]], i)
    if j < len(table[a[i]]) and (table[a[i]][k] == i):
        dp[table[a[i]][j]] += dp[i]
        dp[table[a[i]][j]] %= mod
    if i + 1 < N:
        dp[i + 1] += dp[i]
        dp[i + 1] %= mod
    # print(dp)
print((dp[-1]))

import sys
from bisect import bisect_right as br
from bisect import bisect_left as bl

input = sys.stdin.readline
N = int(eval(input()))
mod = 10**9 + 7
a = []
for _ in range(N):
    a.append(int(eval(input())))
t = 0
table = [[] for _ in range(max(a) + 1)]
for i in range(N):
    if a[i] != t:
        t = a[i]
        table[a[i]].append(i)
dp = [0] * N
dp[0] = 1
# print(table)
# print(a)
for i in range(N):
    r = br(table[a[i]], i)
    l = bl(table[a[i]], i)
    if r < len(table[a[i]]) and (table[a[i]][l] == i):
        dp[table[a[i]][r]] += dp[i]
        dp[table[a[i]][r]] %= mod
        """
    for k in range(j, len(table[a[i]])):
      print(i, table[a[i]][k])
      dp[table[a[i]][k]] += dp[i]
      dp[table[a[i]][k]] %= mod
    """
    if i + 1 < N:
        dp[i + 1] += dp[i]
        dp[i + 1] %= mod
print((dp[-1]))

+from bisect import bisect_right as br -from bisect import bisect_right as br -table = [[] for _ in range(2 * pow(10, 5) + 1)] +mod = 10**9 + 7 +for _ in range(N): +    a.append(int(eval(input()))) -mod = 10**9 + 7 +table = [[] for _ in range(max(a) + 1)] -    x = int(eval(input())) -    if t != x: -        table[x].append(i) -        t = x -    a.append(x) -# print(table[4], table[3]) +    if a[i] != t: +        t = a[i] +        table[a[i]].append(i) +# print(table) +# print(a) -    j = br(table[a[i]], i) -    k = bl(table[a[i]], i) -    if j < len(table[a[i]]) and (table[a[i]][k] == i): -        dp[table[a[i]][j]] += dp[i] -        dp[table[a[i]][j]] %= mod +    r = br(table[a[i]], i) +    l = bl(table[a[i]], i) +    if r < len(table[a[i]]) and (table[a[i]][l] == i): +        dp[table[a[i]][r]] += dp[i] +        dp[table[a[i]][r]] %= mod +        """ +    for k in range(j, len(table[a[i]])): +      print(i, table[a[i]][k]) +      dp[table[a[i]][k]] += dp[i] +      dp[table[a[i]][k]] %= mod +    """ -    # print(dp)