CodeEff/ECCO huggingface dataset:
# Original solution
N=int(eval(input()))
C=[int(eval(input())) for _ in range(N)]
mod = int(1e9+7)

memo={}
new_C=[]

pre = 1.5
i=0
for c in C:
    if c!= pre:
        new_C.append(c)
        memo.setdefault(c,[]).append(i)
        i+=1
    pre=c

answer = [0]*len(new_C)
answer[0] = 1

for i in range(1, len(new_C)):
    try:
        prev_index = i-1 - new_C[i-1::-1].index(new_C[i])
        answer[i] = (answer[i-1] + answer[prev_index]) %mod
    except:
        answer[i] = answer[i-1]

print((answer[-1]))

# Optimized solution
N = int(eval(input()))
C = [int(eval(input())) for _ in range(N)]
mod = int(1e9+7)

from itertools import groupby
x = [0] + [k for k, g in groupby(C)]

dp = [0]*(len(x)) # i個目までで何通りあるか
dp[0] = 1
memo = {}

for i in range(1, len(x)):
    c = x[i]
    memo[c] = (memo.get(c,0) + dp[i-1])%mod
    dp[i] = memo[c]

print((dp[-1]))
# Original solution
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())

def main():
    N = II()
    C = []
    for _ in range(N):
        c = II()
        if len(C) == 0 or c != C[-1]:
            C.append(c)
    global ans
    ans = 0
    dp = [1] + [0] * N
    from collections import defaultdict
    idxs = defaultdict(list)
    for i, c in enumerate(C):
        ret = dp[i]
        if c in list(idxs.keys()):
            for j in idxs[c]:
                ret += dp[j]
        dp[i + 1] = ret % MOD
        idxs[c].append(i)

    ans = dp[len(C)]

    return ans % MOD

print((main()))

# Optimized solution
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())

def main():
    N = II()
    C = []
    for _ in range(N):
        c = II()
        if len(C) == 0 or c != C[-1]:
            C.append(c)
    global ans
    ans = 0
    dp = [1] + [0] * N
    from collections import defaultdict
    cnt_clr = defaultdict(int)
    for i, c in enumerate(C):
        ret = dp[i]
        ret += cnt_clr[c]
        cnt_clr[c] = ret
        dp[i + 1] = ret % MOD

    ans = dp[len(C)]

    return ans % MOD

print((main()))
# Original solution
import sys

N = int(eval(input()))
C = []
pre = 0
for _ in range(N):
    c = int(sys.stdin.readline())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c

ans = 1
dic = {}
for c in C:
    if c in list(dic.keys()):
        a = dic[c]
        dic[c] += ans
        ans += a
    else:
        dic[c] = ans

print((ans % (10 ** 9 + 7)))


# Optimized solution
import sys

N = int(eval(input()))
C = [0]
for line in sys.stdin:
    c = int(line)
    if C[-1] == c:
        continue
    else:
        C.append(c)

ans = 1
dic = {}
for c in C:
    if c in list(dic.keys()):
        a = dic[c]
        dic[c] += ans
        ans += a
    else:
        dic[c] = ans

print((ans % (10 ** 9 + 7)))
# Original solution
import sys
from collections import defaultdict

N = int(eval(input()))
C = [0]
for _ in range(N):
    c = int(sys.stdin.readline())
    if C[-1] == c:
        continue
    else:
        C.append(c)

ans = 1
dic = defaultdict(lambda: 0)
mod = 10 ** 9 + 7
for c in C:
    a = dic[c]
    dic[c] += ans
    ans = (ans + a) % mod

print((ans % mod))


# Optimized solution
import sys
from collections import defaultdict

N = int(eval(input()))
C = [0]
for _ in range(N):
    c = int(sys.stdin.readline())
    if C[-1] != c:
        C.append(c)

ans = 1
dic = defaultdict(lambda: 0)
mod = 10 ** 9 + 7
for c in C:
    a = dic[c]
    dic[c] += ans
    ans = (ans + a) % mod

print((ans % mod))
# Original solution
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def main():
    N = int(eval(input()))
    C = [int(eval(input())) for _ in range(N)] + [None]
    C = [C[i] for i in range(N) if C[i] != C[i + 1]]

    colors = defaultdict(list)
    for i, c in enumerate(C):
        colors[c].append(i)

    N = len(C)
    # dp[i] := i個までの色の塗り方の総和
    dp = [0] * (N + 1)
    dp[0] = 1
    for i in range(N):
        # i個目を塗らない
        dp[i + 1] += dp[i]
        dp[i + 1] %= MOD
        for j in colors[C[i]]:
            if j <= i:
                continue

            # ぬる
            dp[j + 1] += dp[i]
            dp[j + 1] %= MOD

    print((dp[-1]))


if __name__ == "__main__":
    main()


# Optimized solution
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def main():
    N = int(eval(input()))
    C = [int(eval(input())) for _ in range(N)] + [-1]
    C = [C[i] for i in range(N) if C[i] != C[i + 1]]

    N = len(C)
    # dp[i] := i個までの色の塗り方の総和
    dp = [0] * N
    dp[0] = 1
    used = [-1] * (max(C) + 1)
    used[C[0]] = 0

    for i in range(1, N):
        if used[C[i]] == -1:
            dp[i] = dp[i - 1]
        else:
            dp[i] = dp[i - 1] + dp[used[C[i]]]

        dp[i] %= MOD
        used[C[i]] = i

    print((dp[-1]))


if __name__ == "__main__":
    main()
# Original solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  n = int(input())
  prev = -1
  nums = []
  table = {}

  for _ in range(n):
    v = int(input())

    if v != prev:
      nums.append(v)
      prev = v

  for i, n in enumerate(nums):
    if n not in table:
      table[n] = []

    table[n].append(i)

  values = [0] * len(nums)
  value = 1

  for i in range(len(nums)):
    values[i] += value

    for j in table[nums[i]]:
      if j <= i:
        continue

      values[j] += value

    value = values[i]

  print(value % int(1e+9 + 7), flush=True)


if __name__ == '__main__':
  main()



# Optimized solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  value = 1
  skips = {}
  prev = -1

  for _ in range(int(input())):
    n = int(input())

    if n == prev:
      continue

    prev = n

    if n in skips:
      value += skips[n]

    skips[n] = value

  print(value % int(1e+9 + 7), flush=True)


if __name__ == '__main__':
  main()
# Original solution
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()


# Optimized solution
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()
# Original solution
#import time
#t = []

N = int(eval(input()))

#st = time.time()

sums = [1]  # pair number sum until index
#cpos = [-1] * (2 * 10 ** 5 + 1)    # positions of each color
cpos = {}
lastc = -1  # last color of input
C = []      # color stone list

#print("prepare time [ms] = {}".format(1000 * (time.time() - st)))

for i in range(N):
    c = int(eval(input()))

#    sti = time.time()
#    st = time.time()

    if(lastc != c):
        lastc = c
        C.append(c)
        cnt = len(C)
#        print("lastc = {}, cnt = {}, C = {}".format(lastc, cnt, C))

#        print("prepare time in loop [ms] = {}".format(1000 * (time.time() - st)))
#        st = time.time()

        if(c in cpos):
            s = sums[-1]
            for pos in cpos[c]:
                s += sums[pos - 1]
            sums.append(s)
            cpos[c].append(cnt)
        else:
            sums.append(sums[-1])
            cpos[c] = [cnt]

#        print("calc time [ms] = {}".format(1000 * (time.time() - st)))
#        print("cpos = " + str(cpos))

#    print("iteration time [ms] = {}".format(1000 * (time.time() - sti)))

#print("C = " + str(C))
#print("cpos = " + str(cpos))
#print("sums = " + str(sums))

print((sums[-1] % (10 ** 9 + 7)))


# Optimized solution
sums = [1]  # pair number sum until index
csums = {}  # pair number sum of each color

N = int(eval(input()))
C = []      # color stone list
lastc = -1  # last color of input
for i in range(N):
    c = int(eval(input()))
    if(lastc == c):
        continue
    lastc = c
    C.append(c)

#print("C = " + str(C))

for i, c in enumerate(C, 1):
    if(c in csums):
        sums.append(sums[-1] + csums[c])
        csums[c] += sums[i - 1]
    else:
        sums.append(sums[-1])
        csums[c] = sums[i - 1]

#    print("i = {}, c = {}".format(i, c))
#    print("csums = " + str(csums))
#    print("sums = " + str(sums))

print((sums[-1] % (10 ** 9 + 7)))
# Original solution
from collections import defaultdict
MOD = 10**9+7
n = int(eval(input()))
dp = [1]
d = defaultdict(list)
cur = int(eval(input()))
d[cur].append(0)
for i in range(1,n):
  pre,cur = cur,int(eval(input()))
  c = dp[-1]
  if pre != cur and d[cur]:
    c += dp[d[cur][-1]]
  dp.append(c)
  d[cur].append(i)
print((dp[-1]%MOD))

# Optimized solution
from collections import defaultdict
MOD = 10**9+7
n = int(eval(input()))
dp = [1]
d = defaultdict(list)
cur = int(eval(input()))
d[cur].append(0)
for i in range(1,n):
  pre,cur = cur,int(eval(input()))
  c = dp[-1]
  if pre != cur and d[cur]:
    c += dp[d[cur][-1]]
  dp.append(c%MOD)
  d[cur].append(i)
print((dp[-1]))
# Original solution
from collections import defaultdict
N = int(eval(input()))
p = 10 ** 9 + 7
C = [0] * (N + 1)
D = defaultdict(list)
DP = [[0, 0] for i in range(N + 1)]
DP[0] = [1, 0]
LC = 0
LP = -1
for i in range(1, N + 1):
  C[i] = int(eval(input()))
  DP[i][0] = sum(DP[i - 1]) % p
  if C[i] != C[i - 1]:
    for d in D[C[i]]:
      DP[i][1] += DP[d][0]
    D[C[i]] += [i]
print((sum(DP[N]) % p))

# Optimized solution
from collections import defaultdict
N = int(eval(input()))
p = 10 ** 9 + 7
C = [0] * (N + 1)
D = defaultdict(lambda: -1)
DP = [[0, 0] for i in range(N + 1)]
DP[0] = [1, 0]
for i in range(1, N + 1):
  C[i] = int(eval(input()))
  DP[i][0] = sum(DP[i - 1]) % p
  if C[i] != C[i - 1]:
    DP[i][1] = sum(DP[D[C[i]]]) if D[C[i]] != -1 else 0
    D[C[i]] = i
print((sum(DP[N]) % p))
# Original solution
import copy
from collections import deque

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

C2 = []
re = ""
L = {}
for i in C:
  if i != re:
    if i in L:
      L[i].append(len(C2))
    else:
      L[i] = deque([])
    C2.append(i)
  re = i

LL = [-1] * len(C2)
for i in range(len(C2)):
  if L[C2[i]] != []:
    LL[i] = copy.deepcopy(L[C2[i]])
    if len(L[C2[i]]) > 0:
      L[C2[i]].popleft()

DP = [-1] * (len(C2) + 1)

DP[-1] = 1
for i in range(len(C2) - 1, -1, -1):
  DP[i] = DP[i + 1]
  if LL[i] != -1:
    for j in LL[i]:
      DP[i] += DP[j + 1]

print((DP[0]))

# Optimized solution
N = int(eval(input()))
C = [eval(input()) for i in range(N)]

MOD = 1e9 + 7

C2 = []
re = ""
L = {}
LL = [-1] * N
for i in C:
  if i != re:
    if i in L:
      LL[L[i]] = len(C2)
      L[i] = len(C2)
    else:
      L[i] = len(C2)
    C2.append(i)
  re = i


DP = [-1] * (len(C2) + 1)

DP[-1] = 1
for i in range(len(C2) - 1, -1, -1):
  DP[i] = DP[i + 1]
  if LL[i] != -1:
    DP[i] += DP[LL[i]] % MOD
print((int(DP[0] % MOD)))
# Original solution
N = int(eval(input()))
c = []
for _ in range(N):
    c.append(int(eval(input())))

dp = [0] * N
dp[0] = 1

for i in range(1, N):
    if c[i] == c[i - 1]:
        dp[i] = dp[i - 1]
        continue
    for j in range(i):
        if j == 0 and c[j] == c[i]:
            dp[i] += 1
        if c[i] == c[j + 1] and c[j] != c[j + 1]:
            dp[i] += dp[j]
print((dp[N - 1]))

# Optimized solution
import sys
input = sys.stdin.readline

N = int(eval(input()))
c = []
for _ in range(N):
    c.append(int(eval(input())))

dp = [0] * N
dp[0] = 1
dpc = [0] * (max(c) + 1)
dpc[c[0]] = 1

for i in range(1, N):
    dp[i] = dp[i - 1]
    if c[i] != c[i - 1]:
        dp[i] += dpc[c[i]]
        dpc[c[i]] += dp[i - 1]

print((dp[N - 1] % (10**9+7)))
# Original solution
N=int(eval(input())) 
clist=[-1]
mod=10**9+7

for i in range(N):
  t=int(eval(input()))
  if t==clist[-1]:
    continue
  clist.append(t)

del clist[0]
N = len(clist)

# print(clist)
colorlast=[-1]*(3*10**5)
poslp=[-1]*(N+1)

for e,c in enumerate(clist,1):
  if  colorlast[c]  !=  -1:
    poslp[e]=colorlast[c]
    colorlast[c]=e
  else:
    colorlast[c]=e


dp=[0]*(N+100)
dp[0]=1

for e,c in enumerate(clist,1):
  if poslp[e]==-1:
    dp[e]=(dp[e-1])%mod
  else:
    dp[e]=(dp[e-1]+dp[poslp[e]])%mod

# print(dp[:len(clist)+1])
print((dp[len(clist)]%mod))
    



# Optimized solution
def solve():
    # 方針
    # 範囲で並べ方の個数を足し合わせるDP
    
    N = int(eval(input()))
    X = [int(eval(input())) for _ in range(N)]
    MOD = int(1e9)+7
    
    colors = set()
    NoDouble = [-1]
    for x in X:
        colors.add(x)
        if x == NoDouble[-1]:
            continue
        NoDouble.append(x)
    del NoDouble[0]
    N = len(NoDouble)
    C = len(colors)

    ForIdxLastNum = [-1] * N # N番目の要素まで見たとき、その色は直前にどこに出現したか
    # 上記を作成するために、inplace な色の出現の位置を記憶
    Onetime_colors = [-1] * (2*10**5+1)

    for e,c in enumerate(NoDouble):
        if Onetime_colors[c] == -1:
            # その色は初出
            Onetime_colors[c] = e
        else:
            ForIdxLastNum[e] = Onetime_colors[c]
            Onetime_colors[c] = e
    
    
    DP = [0] * (N+1) # dp[i], i個目まで見たときの並べ方の個数
    DP[0] = 1

    for e,c in enumerate(NoDouble):
        if ForIdxLastNum[e] == -1:
            # その色は初出
            DP[e+1] = DP[e]
        else:
            lastIdx = ForIdxLastNum[e]
            DP[e+1] = (DP[lastIdx+1] + DP[e]) % MOD
    
    print((DP[N] % MOD))

            
    
    


if __name__ == "__main__":
    solve()
# Original solution
import sys
sys.setrecursionlimit(100000000)
N = int(eval(input()))
C = [int(eval(input()))]
cindex = {C[0]:[0]}
mod = 7 + 10 ** 9
counter = 0
for _ in range(N-1):
    c = int(eval(input()))
    if c != C[-1]:
        C.append(c)
        counter += 1
        if c in cindex:
            cindex[c].append(counter)
        else:
            cindex[c] = [counter]

def variation(i, memo = {}):
    if i == len(C)-1: return 1
    try:
        return memo[i]
    except KeyError:
        total = 0
        L = cindex[C[i]]
        for l in L:
            if l > i:
                total += variation(l, memo) #lまで塗る
                total %= mod
                break
        total += variation(i + 1, memo)
        total %= mod
        memo[i] = total
        return total
 
memo = {}
print((variation(0, memo)))

# Optimized solution
N = int(eval(input()))
C = [int(eval(input()))]
cindex = {C[0]: 0}
mod = 7 + 10 ** 9
counter = 0
for _ in range(N-1):
    c = int(eval(input()))
    if c != C[-1]:
        C.append(c)
        counter += 1
        if c not in cindex:
            cindex[c] = counter

DP = [[0, 1] for i in range(len(C))]
for i in range(1, len(C)):
    if cindex[C[i]] == i:
        DP[i][1] = DP[i-1][1]
    else:
        DP[i][0] = DP[cindex[C[i]]][1] 
        DP[i][1] = DP[i][0] + DP[i-1][1]
        DP[i][1] %= mod
        cindex[C[i]] = i
print((DP[-1][1]))
# Original solution
import sys
input = sys.stdin.readline

def main():
    N = int(eval(input()))
    c = [-1]
    INF = 10**9+7
    for _ in range(N):
        a = int(eval(input()))
        if c[-1] == a:
            continue
        c.append(a)
    
    c.pop(0)
    d,M = len(c),max(c)    
    _c = list(set(c))
    
    dp = [1 for _ in range(d+1)]
    c_dp = [[0 for _ in range(d+1)] for _ in range(M+1)]
    for i in range(d):
        for j in _c:
            if c[i] != j:
                c_dp[j][i+1] = c_dp[j][i]
            else:
                dp[i+1] = (c_dp[j][i] + dp[i])%INF
                c_dp[j][i+1] = dp[i+1]
                
    print((dp[-1]))
    
if __name__ == "__main__":
    main()


# Optimized solution
import sys
input = sys.stdin.readline

def main():
    N = int(eval(input()))
    c = [-1]
    INF = 10**9+7
    for _ in range(N):
        a = int(eval(input()))
        if c[-1] == a-1:
            continue
        c.append(a-1)
    
    c.pop(0)
    d,M = len(c),max(c)
    dp = [1 for _ in range(d+1)]
    c_dp = [0 for _ in range(M+1)]
    for i in range(d):
        now = c[i]
        dp[i+1] = (dp[i] + c_dp[now])%INF
        c_dp[now] = dp[i+1]
                
    print((dp[-1]))
    
if __name__ == "__main__":
    main()
# Original solution
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 = []
    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 = [[-1,-1]]+sorted(selist,key=lambda x:x[1])
    # s_ind = {}
    # for i,(s,e) in enumerate(selist):
        # e_ind[e] = i
    # ends = list(e_ind.keys())
    ends.sort()
    dp = [0]*(len(selist))
    for i in range(1,len(selist)):
        dp[i] = (dp[i-1]+1)%mod
        ind = bisect_right(ends,selist[i][0])
        dp[i] += dp[ind-1]
    ans = dp[-1]+1
    ans %= mod
    return ans
print((solve()))

# Optimized solution
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 = []
    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 = [[-1,-1]]+sorted(selist,key=lambda x:x[1])
    # s_ind = {}
    # for i,(s,e) in enumerate(selist):
        # e_ind[e] = i
    # ends = list(e_ind.keys())
    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()))
# Original solution
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()))


# Optimized solution
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()))
# Original solution
N = int(eval(input()))
C = [int(eval(input())) for i in range(N)]
MOD = 10**9+7

A = []
for c in C:
    if A and A[-1]==c: continue
    A.append(c)

last = [-1] * 200001
B = [-1] * len(A)
for i,a in enumerate(A):
    B[i] = last[a]
    last[a] = i

dp = [0] * (len(A))
dp[0] = 1
for i in range(1,len(A)):
    bk = 0 if B[i] < 0 else dp[B[i]]
    dp[i] = (dp[i-1] + bk) % MOD
print((dp[-1]))

# Optimized solution
N = int(eval(input()))
C = [int(eval(input())) for i in range(N)]
MOD = 10**9+7

dp = [0] * N
dp[0] = 1
bak = {C[0]:0}

for i,c in enumerate(C):
    if i==0: continue
    dp[i] = dp[i-1]
    if c in bak and bak[c] < i-1:
        dp[i] += dp[bak[c]]
        dp[i] %= MOD
    bak[c] = i
print((dp[-1]))
# Original solution
import sys
N = int(eval(input()))
C = [0]
#c = [int(sys.stdin.readline()) for i in range(N)]
n = N
for i in range(1, n + 1):
    c = int(sys.stdin.readline())
    if c == C[-1]:
        N -= 1
    else:
        C.append(c)
#C = C+c
dp = [0] * (N + 2)
dp_2 = [0] * (N + 2)
color = [[]for i in range((2*(10**5)+2))]
dp[0] = 1
dp[1] = 1
dp_2[0] = 1
dp_2[1] = 1
color[C[1]].append(1)
cumsum = [0] * (2 * (10 ** 5) + 2)
cumsum[C[1]] = 1
for i in range(2, N+1):
    dp[i] = dp[i - 1] + cumsum[C[i]]
    cumsum[C[i]] += dp[i-1]
    # ↓これだと遅い(当日はこれ以上の高速化が思いつけなくてTLE)
    dp_2[i] = dp_2[i - 1] + sum([dp_2[col - 1] for col in color[C[i]]])
    color[C[i]].append(i)
    dp[i] %= (10 ** 9 + 7)
# print(C)
# print(dp)
# print(dp_2)
print((dp[N]))


# Optimized solution
import sys
N = int(eval(input()))
C = [0]
n = N
for i in range(1, n + 1):
    c = int(sys.stdin.readline())
    if c == C[-1]:
        N -= 1
    else:
        C.append(c)
dp = [0] * (N + 2)
dp[0] = 1
dp[1] = 1
cumsum = [0] * (2 * (10 ** 5) + 2)
cumsum[C[1]] = 1
for i in range(2, N+1):
    dp[i] = dp[i - 1] + cumsum[C[i]]
    cumsum[C[i]] += dp[i-1]
    dp[i] %= (10 ** 9 + 7)
print((dp[N]))
# Original solution
n = int(eval(input()))
c = [int(eval(input())) for i in range(n)]
dp = [1 for i in range(2*(10**5)+1)]
dp2 = [-1 for i in range(2*(10**5)+1)]
dp3 = [0 for i in range(2*(10**5)+1)]

ans = 1

def count(s):
  memo = {}
  res = 1
  for i in range(len(s)):
    if s[i] not in memo:
      memo[s[i]] = 1
    else:
      memo[s[i]] += 1
  for i in memo:
    res = res*2**(memo[i]-1)
  return res


dp2[c[0]] = 0
dp3[c[0]] += 1
#print("dp",dp)
#print("dp2",dp2)
     
for i in range(1,n):
  
  if c[i] != c[i-1]:
    if dp2[c[i]] == -1:
      dp2[c[i]] = i
      dp3[c[i]] += 1
    else:
      dp[c[i]] = count(c[dp2[c[i]]:i])*dp[c[i]]*(dp3[c[i]])
      ans += dp[c[i]]
      ans = ans % 1000000007 
      dp3[c[i]] += 1
      
      dp2[c[i]] = i
#  print(i,"dp",dp)
#  print(i,"dp2",dp2)
#  print(i,ans)
print(ans)

# Optimized solution
n = int(eval(input()))
cc = [int(eval(input())) for i in range(n)]
c = [cc[0]]
for i in range(1,n):
  if cc[i] != cc[i-1]:
    c.append(cc[i])

n = len(c)
dp = [0 for i in range(n)]
pos_dp = [-1 for i in range(2*10**5+1)]

dp[0] = 1
pos_dp[c[0]] = 0
     
for i in range(1,n):
  if pos_dp[c[i]]!=-1:
    dp[i] = (dp[i-1] + dp[pos_dp[c[i]]])%1000000007
  else:
    dp[i] = dp[i-1] 
  pos_dp[c[i]] = i

print((dp[n-1]))