CodeEff/ECCO huggingface dataset:
# Original solution
H, W, N = list(map(int, input().split()))
D = dict()

for i in range(N):
    a, b = list(map(int, input().split()))
    for a_add in [-1, 0, 1]:
        for b_add in [-1, 0, 1]:
            c = a + a_add
            d = b + b_add
            if c-1 in range(1, H-1) and d-1 in range(1, W-1):
                if str([c, d]) in list(D.keys()):
                    D[str([c, d])] += 1
                else:
                    D[str([c, d])] = 1

res_list = [0]*10
for s in list(D.keys()):
    res_list[D[s]] += 1

res_list[0] = (H-2) * (W-2) - sum(res_list)

for i in range(10):
    print(res_list[i])

# Optimized solution
H, W, N = list(map(int, input().split()))
D = dict()

for i in range(N):
    a, b = list(map(int, input().split()))
    for a_add in [-1, 0, 1]:
        for b_add in [-1, 0, 1]:
            c = a + a_add
            d = b + b_add
            if c-1 in range(1, H-1) and d-1 in range(1, W-1):
                if str([c, d]) in D:
                    D[str([c, d])] += 1
                else:
                    D[str([c, d])] = 1

res_list = [0]*10
for s in list(D.keys()):
    res_list[D[s]] += 1

res_list[0] = (H-2) * (W-2) - sum(res_list)

for i in range(10):
    print(res_list[i])
# Original solution
from itertools import product
from bisect import bisect_left as bl
H, W, N = list(map(int, input().split()))
A = [tuple(map(int, input().split())) for _ in range(N)]
A.sort()
ans = [0] * 10
for x, y in A:
    for ltx, lty in product(range(max(1, x-2), min(x+1, H-1)), 
                            range(max(1, y-2), min(y+1, W-1))):
        num = sum(bl(A, (ltx+i, lty+3)) - bl(A, (ltx+i, lty)) for i in range(3))
        ans[num] += 1
for i in range(1, len(ans)):
    ans[i] //= i
ans[0] = (H - 2) * (W - 2) - sum(ans)
print(*ans, sep="\n")


# Optimized solution
from itertools import product
H, W, N = list(map(int, input().split()))
A = [tuple(map(int, input().split())) for _ in range(N)]
count = {}
for x, y in A:
    for xx, yy in product(range(x-1, x+2), range(y-1, y+2)):
        if not(2 <= xx <= H-1 and 2 <= yy <= W-1):
            continue
        count[(xx, yy)] = count.get((xx, yy), 0) + 1
ans = [0] * 10
for k, v in count.items():
    ans[v] += 1
ans[0] = (H - 2) * (W - 2) - sum(ans)
print(*ans, sep="\n")
# Original solution
from itertools import product
H, W, N = list(map(int, input().split()))
A = [tuple(map(int, input().split())) for _ in range(N)]
count = {}
for x, y in A:
    for xx, yy in product(range(x-1, x+2), range(y-1, y+2)):
        if not(2 <= xx <= H-1 and 2 <= yy <= W-1):
            continue
        count[(xx, yy)] = count.get((xx, yy), 0) + 1
ans = [0] * 10
for k, v in count.items():
    ans[v] += 1
ans[0] = (H - 2) * (W - 2) - sum(ans)
print(*ans, sep="\n")


# Optimized solution
from itertools import product
H, W, N = list(map(int, input().split()))
A = [tuple(map(int, input().split())) for _ in range(N)]
count = {}
for x, y in A:
    for xx, yy in product(range(x-1, x+2), range(y-1, y+2)):
        if not(2 <= xx <= H-1 and 2 <= yy <= W-1):
            continue
        count[(xx, yy)] = count.get((xx, yy), 0) + 1
ans = [0] * 10
for v in count.values():
    ans[v] += 1
ans[0] = (H - 2) * (W - 2) - sum(ans)
print(*ans, sep="\n")
# Original solution
import sys
input = sys.stdin.buffer.readline

from collections import defaultdict

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

H, W, N = getlist()
D = defaultdict(int)
D[0] += (H - 2) * (W - 2)
L = []
for i in range(N):
	a, b = getlist()
	for j in range(3):
		for k in range(3):
			if H - 2 >= a - j and a - j >= 1 and W - 2 >= b - k and b - k >= 1:
				L.append((a - j, b - k))

L = sorted(L)
n = len(L)
if n != 0:
	v = L[0]
c = 0
for i in range(n):
	if v == L[i]:
		c += 1
	else:
		D[c] += 1
		c = 1
	v = L[i]

if n != 0:
	D[c] += 1
for i in range(1, 10):
	D[0] -= D[i]

for i in range(10):
	print((D[i]))

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

from collections import defaultdict

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


def main():
	H, W, N = getlist()
	D = defaultdict(int)
	D[0] += (H - 2) * (W - 2)
	L = []
	for i in range(N):
		a, b = getlist()
		for j in range(3):
			for k in range(3):
				if H - 2 >= a - j and a - j >= 1 and W - 2 >= b - k and b - k >= 1:
					L.append((a - j, b - k))

	L = sorted(L)
	n = len(L)
	if n != 0:
		v = L[0]
	c = 0
	for i in range(n):
		if v == L[i]:
			c += 1
		else:
			D[c] += 1
			c = 1
		v = L[i]

	if n != 0:
		D[c] += 1
	for i in range(1, 10):
		D[0] -= D[i]

	for i in range(10):
		print((D[i]))	


if __name__ == '__main__':
	main()
# Original solution
from collections import defaultdict
def gen_bound(x,B):
	if x < 3: lb = 2
	else: lb = x - 1
	if x > B-2: ub = B-1
	else: ub = x + 1
	return lb,ub+1
def solve():
	count = defaultdict(int)
	ans = [0]*10
	H,W,N = list(map(int,input().split()))
	ans[0] = (H-2)*(W-2)
	for i in range(N):
		a,b = list(map(int,input().split()))
		xlb,xub = gen_bound(a,H)
		ylb,yub = gen_bound(b,W)
		for x in range(xlb,xub):
			for y in range(ylb,yub):
				k = (x,y)
				bef_c = count[k]
				count[k] += 1
				ans[bef_c] -= 1
				ans[bef_c+1] += 1
	for c in ans:
		print(c)
solve()

# Optimized solution
from collections import defaultdict
def gen_bound(x,B):
	if x < 3: lb = 2
	else: lb = x - 1
	if x > B-2: ub = B-1
	else: ub = x + 1
	return lb,ub+1
def solve():
	count = defaultdict(int)
	ans = [0]*10
	H,W,N = list(map(int,input().split()))
	ans[0] = (H-2)*(W-2)
	for i in range(N):
		a,b = list(map(int,input().split()))
		xlb,xub = gen_bound(a,H)
		ylb,yub = gen_bound(b,W)
		for x in range(xlb,xub):
			for y in range(ylb,yub):
				k = x+(y<<34)
				bef_c = count[k]
				ans[bef_c] -= 1
				ans[bef_c+1] += 1
				count[k] += 1
	for c in ans:
		print(c)
solve()
# Original solution
from collections import defaultdict
def gen_bound(x,B):
	if x < 3: lb = 2
	else: lb = x - 1
	if x > B-2: ub = B-1
	else: ub = x + 1
	return lb,ub+1
def solve():
	count = defaultdict(int)
	ans = [0]*10
	H,W,N = list(map(int,input().split()))
	ans[0] = (H-2)*(W-2)
	for i in range(N):
		a,b = list(map(int,input().split()))
		xlb,xub = gen_bound(a,H)
		ylb,yub = gen_bound(b,W)
		for x in range(xlb,xub):
			for y in range(ylb,yub):
				k = x+(y<<34)
				bef_c = count[k]
				ans[bef_c] -= 1
				ans[bef_c+1] += 1
				count[k] += 1
	for c in ans:
		print(c)
solve()

# Optimized solution
from collections import defaultdict
def gen_bound(x,B):
	if x < 3: lb = 2
	else: lb = x - 1
	if x > B-2: ub = B-1
	else: ub = x + 1
	return lb,ub+1
def solve():
	count = defaultdict(int)
	ans = [0]*10
	H,W,N = list(map(int,input().split()))
	ans[0] = (H-2)*(W-2)
	for i in range(N):
		a,b = list(map(int,input().split()))
		xlb,xub = gen_bound(a,H)
		ylb,yub = gen_bound(b,W)
		for x in range(xlb,xub):
			for y in range(ylb,yub):
				count[x+(y<<34)] += 1
	for v in count.values():ans[v] += 1
	ans[0] -= sum(ans[1:])
	for c in ans: print(c)
solve()
# Original solution
from collections import defaultdict
def gen_bound(x,B):
	if x < 3: lb = 2
	else: lb = x - 1
	if x > B-2: ub = B-1
	else: ub = x + 1
	return lb,ub+1
def solve():
	count = defaultdict(int)
	ans = [0]*10
	H,W,N = list(map(int,input().split()))
	ans[0] = (H-2)*(W-2)
	for i in range(N):
		a,b = list(map(int,input().split()))
		xlb,xub = gen_bound(a,H)
		ylb,yub = gen_bound(b,W)
		for x in range(xlb,xub):
			for y in range(ylb,yub):
				count[x+(y<<34)] += 1
	for v in count.values():ans[v] += 1
	ans[0] -= sum(ans[1:])
	for c in ans: print(c)
solve()

# Optimized solution
from collections import defaultdict
from sys import stdin
def gen_bound(x,B):
	if x < 3: lb = 2
	else: lb = x - 1
	if x > B-2: ub = B-1
	else: ub = x + 1
	return lb,ub+1
def solve():
	count = defaultdict(int)
	ans = [0]*10
	L = [list(map(int,x.split())) for x in stdin.readlines()]
	H,W,N = L[0]
	ans[0] = (H-2)*(W-2)
	for i in range(1,N+1):
		xlb,xub = gen_bound(L[i][0],H)
		ylb,yub = gen_bound(L[i][1],W)
		for x in range(xlb,xub):
			for y in range(ylb,yub):
				count[x+(y<<34)] += 1
	for v in count.values():ans[v] += 1
	ans[0] -= sum(ans[1:])
	for c in ans: print(c)
solve()
# Original solution
from collections import defaultdict
from sys import stdin
def gen_bound(x,B):
	if x < 3: lb = 2
	else: lb = x - 1
	if x > B-2: ub = B-1
	else: ub = x + 1
	return lb,ub+1
def solve():
	count = defaultdict(int)
	ans = [0]*10
	L = [list(map(int,x.split())) for x in stdin.read().split("\n")]
	H,W,N = L[0]
	for i in range(1,N+1):
		xlb,xub = gen_bound(L[i][0],H)
		ylb,yub = gen_bound(L[i][1],W)
		for x in range(xlb,xub):
			for y in range(ylb,yub):
				count[x+(y<<34)] += 1
	for v in count.values():ans[v] += 1
	ans[0] = (H-2)*(W-2) - sum(ans[1:])
	for c in ans: print(c)
solve()

# Optimized solution
from collections import defaultdict
from itertools import product
from sys import stdin
def gen_b(x,B):
	if x < 3: lb = 2
	else: lb = x - 1
	if x > B-2: ub = B-1
	else: ub = x + 1
	return range(lb,ub+1)
def solve():
	count = defaultdict(int)
	ans = [0]*10
	L = [list(map(int,x.split())) for x in stdin.readlines()]
	H,W,N = L[0]
	for i in range(1,N+1):
		for x,y in product(gen_b(L[i][0],H),gen_b(L[i][1],W)):
			count[x+(y<<34)] += 1
	for v in count.values():ans[v] += 1
	ans[0] = (H-2)*(W-2) - sum(ans[1:])
	for c in ans: print(c)
solve()
# Original solution
from collections import Counter
h, w, n = list(map(int, input().split()))
d = Counter()
for _ in range(n):
    a, b = list(map(int, input().split()))
    for i in range(3):
        for j in range(3):
            if w > b+j-1 > 1 < a+i-1 < h:
                d[(a+i,b+j)] += 1
ans = Counter()
for i in list(d.values()):
    ans[i] += 1
print(((h-2)*(w-2) - sum(ans.values())))
for i in range(1,10):
    print((ans[i]))

# Optimized solution
i=lambda:map(int,input().split())
h,w,n=i()
r=[0,1,2]
d={} 
while n:
    a,b=i();n-=1
    for j in r:
        for k in r:
            if w>=b+k>2<a+j<=h:d[(a+j,b+k)]=d.get((a+j,b+k),0)+1
c=[0]*10
for i in d:c[d[i]]+=1
c[0]=(h-2)*(w-2)-sum(c)
print(*c,sep="\n")
# Original solution
from collections import Counter

h,w,n=map(int,input().split())
cc=Counter()
for _ in range(n):
    b,a=map(int,input().split())
    for i in range(3):
        for j in range(3):
            x=a+i
            y=b-j #brute forcing valid bottom right corners
            if x>=1 and x<=w and y>=1 and y<=h:
                if x-2>=1 and x-2<=w and y+2>=1 and y+2<=h:
                    cc[(x,y)]+=1
#                    print(x,y,end=' xy\n')#a valid 3*3 grid bottom right
ans=[0]*10
for i in cc.keys():
    ans[cc[(i)]]+=1
ans[0]=(h-2)*(w-2)-sum(ans)
print(*ans,sep='\n')


# Optimized solution
from collections import Counter
import sys
input=sys.stdin.buffer.readline
h,w,n=map(int,input().split())
cc=Counter()
for _ in range(n):
    b,a=map(int,input().split())
    for i in range(3):
        for j in range(3):
            x=a+i
            y=b-j #brute forcing valid bottom right corners
            if x>=1 and x<=w and y>=1 and y<=h:
                if x-2>=1 and x-2<=w and y+2>=1 and y+2<=h:
                    cc[(x,y)]+=1
#                    print(x,y,end=' xy\n')#a valid 3*3 grid bottom right
ans=[0]*10
for i in cc.keys():
    ans[cc[(i)]]+=1
ans[0]=(h-2)*(w-2)-sum(ans)
print(*ans,sep='\n')
# Original solution
import sys
n=int(eval(input()))
c=[int(i) for i in sys.stdin]
x=[0]*(200001)
c.append(0)
x[c[0]]+= 1
num=1
p=10**9 +7
for i in range(1,n):
  if c[i]-c[i-1]:
    x[c[i]]+= num
    x[c[i]]= x[c[i]]%p
  if c[i]-c[i+1]:
    num=x[c[i]]%p
  else:
    num=0
print(num)

# Optimized solution
import sys
n=int(eval(input()))
c=[int(i) for i in sys.stdin]
#連続した数を除去したlist
d=[]
#前の数を保存する変数
stack=0
for i in c:
  if i!=stack:
    d.append(i)
  stack=i
#0で初期化
x=[0]*200001
sum=1
p=10**9+7
for i in range(0,len(d)):
  x[d[i]]= (x[d[i]]+sum)%p
  sum=x[d[i]]%p
print(sum)
# Original solution
import sys

mod = 10**9 + 7
N = int(sys.stdin.readline())

stones = []
for _ in range(N):
    stones.append(int(sys.stdin.readline()))

left = [-1 for _ in range(2*10**5+1)]
dp = [0 for _ in range(N+5)]
dp[0] = 1
for i in range(N):
    dp[i+1] = dp[i]
    # 同じ色が前回出現した位置
    c = stones[i]
    if 0 <= left[c] < i - 1:
        dp[i+1] += dp[left[c] + 1]
    
    dp[i+1] %= mod
    left[c] = i

print((dp[N]))

# Optimized solution
import sys

mod = 10**9 + 7
N = int(sys.stdin.readline())

stones = []
for _ in range(N):
    stones.append(int(sys.stdin.readline()))

left = {}
dp = [0 for _ in range(N+5)]
dp[0] = 1
for i in range(N):
    dp[i+1] = dp[i]
    # 同じ色が前回出現した位置
    c = stones[i]
    if c in left and 0 <= left[c] < i - 1:
        dp[i+1] += dp[left[c] + 1]
    
    dp[i+1] %= mod
    left[c] = i

print((dp[N]))
# Original solution
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)

N = int(eval(input()))
mod = 10**9+7

from collections import defaultdict
from bisect import bisect_right
last = -1
dic = defaultdict(list)
idx = 0
lis = []
for i in range(N):
    c = int(eval(input()))
    if c==last:
        continue
    last = c
    dic[c].append(idx)
    lis.append(c)
    idx += 1
memo = {}
memo_s = set()
def dfs(i):
    if i==idx:
        return 1
    if i in memo_s:
        return memo[i]
    v = lis[i]
    ret = 0
    n_idx = bisect_right(dic[v], i)
    if n_idx<len(dic[v]):
        for nx in dic[v][n_idx:]:
            ret += dfs(nx+1)
            ret %= mod
    ret += dfs(i+1)
    ret %= mod
    memo[i] = ret
    memo_s.add(i)
    return ret
print((dfs(0)))

# Optimized solution
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)

N = int(eval(input()))
mod = 10**9+7

last = {}
dp = [0]*(N+1)
dp[0] = 1
for i in range(1, N+1):
    dp[i] = dp[i-1]
    c = int(eval(input()))
    if c in last and last[c]+1<i:
        dp[i] += dp[last[c]]
        dp[i] %= mod
    last[c] = i

print((dp[N]))
# Original solution
def read_values():
    return list(map(int, input().split()))


def read_list():
    return list(read_values())


def main():
    mod = 10 ** 9 + 7
    N = int(eval(input()))
    C = [int(eval(input())) for _ in range(N)]

    dp = [1] * (N + 1)
    dp[0] = 1
    D = {c: set() for c in set(C)}
    pre = -1
    for n in range(N):
        c = C[n]
        S = D[c]
        dp[n + 1] = dp[n]
        if pre == c:
            dp[n] = 0
            continue

        if len(S) != 0:
            dp[n + 1] = (dp[n + 1] + sum(dp[s] for s in S)) % mod
        D[c].add(n)
        pre = c
    print((dp[-1]))


if __name__ == "__main__":
    main()


# Optimized solution
def read_values():
    return list(map(int, input().split()))


def read_list():
    return list(read_values())


def main():
    mod = 10 ** 9 + 7
    N = int(eval(input()))

    dp = [1] * (N + 1)
    dp[0] = 1
    D = {}
    pre = -1
    for n in range(N):
        c = int(eval(input()))
        dp[n + 1] = dp[n]
        if pre == c:
            dp[n] = 0
            continue
        r = D.setdefault(c, 0)
        dp[n + 1] = (dp[n + 1] + r) % mod
        D[c] = r + dp[n]
        pre = c
    print((dp[-1]))


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

# Optimized solution
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]))
# Original solution
a=int(eval(input()))
C=list()
last=[[]for i in range(2*100002)]
for i in range(a):
    C.append(int(eval(input())))

ans=[1]*a
last[C[0]].append(0)
#print(last,ans)
for i in range(1,a):
    ans[i]=ans[i-1]
    if C[i]==C[i-1]:
        continue
    for j in last[C[i]]:
        if j==0:
            ans[i]+=1
        else:
            ans[i]+=ans[j-1]
    last[C[i]].append(i)

print((ans[a-1] % 1000000007))


# Optimized solution
a = int(eval(input()))
C = list()
last = [-1] * 2 * 100002
for i in range(a):
    C.append(int(eval(input())))

ans = [1] * a
last[C[0]] = 0
# print(last,ans)
for i in range(1, a):
    ans[i] = ans[i - 1]
    if C[i] == C[i - 1]:
        continue
    if last[C[i]] != -1:
        ans[i] += ans[last[C[i]]]
    last[C[i]] = i

print((ans[a - 1] % 1000000007))
# Original solution
MOD=10**9+7
N=int(eval(input()))

clist=[]
for i in range(N):
  c=int(eval(input()))
  clist.append(c)  
#print(clist)

c2list=clist[:1]
for i in range(1,N):
  if clist[i]!=c2list[-1]:
    c2list.append(clist[i])
#print(c2list)
N2=len(c2list)

cdic={}
for i in range(N2):
  c=c2list[i]
  if not c in cdic:
    cdic[c]=[i]
  else:
    cdic[c].append(i)
#print(cdic)

dp=[1]+[0]*(N2-1)
for i in range(1,N2):
  c=c2list[i]
  dp[i]=dp[i-1]
  
  if len(cdic[c])<5:
    for j in reversed(cdic[c]):
      if j<i:
        dp[i]+=dp[j]
        break
  else:
    l,r=0,len(cdic[c])
    while(l<=r):
      mid=(l+r)//2
      if cdic[c][mid]<i and cdic[c][mid+1]>=i:
        dp[i]+=dp[cdic[c][mid]]
        break
      elif cdic[c][mid]>=i:
        r=mid-1
      elif cdic[c][mid+1]<i:
        l=mid+1
      else:
        print("error")
    
#print(dp)
print((dp[-1]%MOD))

# Optimized solution
import bisect

MOD=10**9+7
N=int(eval(input()))

clist=[]
for i in range(N):
  c=int(eval(input()))
  clist.append(c)  
#print(clist)

c2list=clist[:1]
for i in range(1,N):
  if clist[i]!=c2list[-1]:
    c2list.append(clist[i])
#print(c2list)
N2=len(c2list)

cdic={}
for i in range(N2):
  c=c2list[i]
  if not c in cdic:
    cdic[c]=[i]
  else:
    cdic[c].append(i)
#print(cdic)

dp=[1]+[0]*(N2-1)
for i in range(1,N2):
  c=c2list[i]
  dp[i]=dp[i-1]

  if len(cdic[c])>0:
    ind=bisect.bisect_left(cdic[c],i)
    if ind>0:
      dp[i]+=dp[cdic[c][ind-1]]
      #print(cdic[c],i,ind-1)
    
#print(dp)
print((dp[-1]%MOD))
# Original solution
import bisect

MOD=10**9+7
N=int(eval(input()))

clist=[]
for i in range(N):
  c=int(eval(input()))
  clist.append(c)  
#print(clist)

c2list=clist[:1]
for i in range(1,N):
  if clist[i]!=c2list[-1]:
    c2list.append(clist[i])
#print(c2list)
N2=len(c2list)

cdic={}
for i in range(N2):
  c=c2list[i]
  if not c in cdic:
    cdic[c]=[i]
  else:
    cdic[c].append(i)
#print(cdic)

dp=[1]+[0]*(N2-1)
for i in range(1,N2):
  c=c2list[i]
  dp[i]=dp[i-1]

  if len(cdic[c])>0:
    ind=bisect.bisect_left(cdic[c],i)
    if ind>0:
      dp[i]+=dp[cdic[c][ind-1]]
      #print(cdic[c],i,ind-1)
    
#print(dp)
print((dp[-1]%MOD))

# Optimized solution
import bisect

MOD=10**9+7
N=int(eval(input()))

clist=[]
for i in range(N):
  c=int(eval(input()))
  clist.append(c)  
#print(clist)

c2list=clist[:1]
for i in range(1,N):
  if clist[i]!=c2list[-1]:
    c2list.append(clist[i])
#print(c2list)
N2=len(c2list)

cldic={}
dp=[0]*(N2-1)+[1]
for i in range(N2):
  c=c2list[i]
  dp[i]=dp[i-1]
  if c in cldic:
    dp[i]+=dp[cldic[c]]      
  cldic[c]=i
    
#print(dp)
print((dp[-1]%MOD))
# Original solution
n = int(eval(input()))
C = []
MOD = 10 ** 9 + 7
pre = -1
for i in range(n):
    a = int(eval(input()))
    if a != pre:
        C.append(a)
    pre = a

N = len(C)
dp = [0] * (N + 1)
col = {}
pre = -1
dp[0] = 1
for i in range(1, N + 1):
    if C[i - 1] not in col :
        dp[i] = dp[i - 1]
        col[C[i - 1]] = [i]
    else:
        dp[i] = dp[i - 1]
        for j in col[C[i - 1]]:
            dp[i] += dp[j - 1]
            dp[i] %= MOD
        col[C[i - 1]].append(i)

print((dp[N]))


# Optimized solution
n = int(eval(input()))
C = []
MOD = 10 ** 9 + 7
pre = -1
for i in range(n):
    a = int(eval(input()))
    if a != pre:
        C.append(a)
    pre = a

N = len(C)
dp = [0] * (N + 1)
col = {}
pre = -1
dp[0] = 1
for i in range(1, N + 1):
    if C[i - 1] not in col:
        dp[i] = dp[i - 1]
        col[C[i - 1]] = dp[i]
    else:
        dp[i] = dp[i - 1]
        dp[i] += col[C[i - 1]]
        dp[i] %= MOD
        col[C[i - 1]] += dp[i - 1]

print((dp[N]))
# Original solution
import sys
input = sys.stdin.readline

INF = 10 ** 9
MOD = 10 **9 + 7

N = int(eval(input()))

C = [int(eval(input())) for _ in range(N)]
lst = [INF] * (2 * 10 ** 5 + 10) #各番号がどこにあるかを管理するリスト
ans = [1] * N
 
lst[C[-1]] = N - 1

for i in range(N - 2, -1, -1):
    c = C[i]
    if lst[c] == INF or lst[c] == i + 1:
        ans[i] = ans[i + 1]
    else:
        ans[i] = ans[i + 1] + ans[lst[c]]
    lst[c] = i

# print (ans)
print((ans[0] % MOD))

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

INF = 10 ** 9
MOD = 10 **9 + 7

N = int(eval(input()))

C = [int(eval(input())) for _ in range(N)]
lst = [INF] * (2 * 10 ** 5 + 10) #各番号がどこにあるかを管理するリスト
ans = [1] * N
 
lst[C[-1]] = N - 1

for i in range(N - 2, -1, -1):
    c = C[i]
    if lst[c] == INF or lst[c] == i + 1:
        ans[i] = ans[i + 1]
    else:
        ans[i] = ans[i + 1] + ans[lst[c]]
    ans[i] %= MOD
    lst[c] = i

# print (ans)
print((ans[0] % MOD))
# Original solution
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]))


# Optimized solution
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]))