Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import math

a, b = map(int, input().split())
fa = math.factorial(a)
fb = math.factorial(b)

if abs(a-b) >= 2:
  print(0)
elif abs(a-b) == 1:
  print(fa*fb)
elif abs(a-b) == 0:
  print(2*(fa*fb))

### FIXED CODE ###

import math

a, b = map(int, input().split())

diff = abs(a - b)
if diff >= 2:
  print(0)
  exit(0)
  
n = (10 ** 9) + 7
f = math.factorial(a) * math.factorial(b)
if diff == 1:
  print(f % n)
  exit(0)
  
print((2 * f) % n)
### BUGGY CODE ###

def main():
  import sys
  input = sys.stdin.readline
  n=int(input())
  a=sorted(list(map(int,input().split())))
  mod=pow(10,9)+7
  x=[0]*63
  for i in a:
    i=bin(i)
    l=len(i)
    for j in range(1,l-1):
      if i[-j]=='1':
        x[j]+=1
  ans=0
  for i in range(1,l+1):
    if x[i]>0 and x[i]<n:
      ans+=pow(2,i-1,mod)*(x[i]%mod)*((n-x[i])%mod)%mod
      ans%=mod
  print(ans)
if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  import sys
  input = sys.stdin.readline
  import numpy as np
  n=int(input()) 
  a=np.array(list(map(int,input().split())))
  mod=pow(10,9)+7
  ans=0
  
  for i in range(60):
    x=np.count_nonzero(a & 1)
    ans+=pow(2,i,mod)*x*(n-x)
    ans=ans%mod
    a=a>>1
  print(ans)
if __name__=='__main__':
  main()
### BUGGY CODE ###

N, M = map(int,input().split(' '))
a = [int(input()) for i in range(M)]
ans = [0]*(N+1)
ans[0] = 1
for i in range(1,N+1):
  ans[i] = (ans[i-1]+ans[i-2])%(10**9+7)
  if i in a:
    ans[i] = 0
print(ans[N])

### FIXED CODE ###

N, M = map(int,input().split(' '))
a = set([int(input()) for i in range(M)])
ans = [0]*(N+1)
ans[0] = 1
for i in range(1,N+1):
  if i in a:
    ans[i] = 0
  else:
    ans[i] = (ans[i-1]+ans[i-2])%(10**9+7)
print(ans[N])
### BUGGY CODE ###

N = list(map(int, input()))
MOD = 2019
cnt = 0
M = len(N)
for i in range(0,M):
    n = N[i]
    for j in range(i+1,M):
        n = ((n * 10) + N[j])%MOD
        if n == 0:
            cnt += 1

print(cnt)

### FIXED CODE ###

from collections import Counter

N = list(map(int, input()))
MOD = 2019
cnt = 0
M = len(N)
ans = 0
mod_list = [0]
ten = 1

for n in N[::-1]:
    ans += ten*n
    mod_list.append(ans%MOD)
    ten *= 10
    ten %= MOD

SUM = 0
for k,v in Counter(mod_list).items():
    SUM += v * (v-1) /2

print(int(SUM))
### BUGGY CODE ###

from math import factorial
from functools import lru_cache

@lru_cache(maxsize=None)
def cmbcount(n):
    if n > 1:
        return factorial(n) // (factorial(n - 2) * factorial(2))
    return 0

N = int(input())
A = list(map(int, input().split()))
samecnt = [0] * (N + 1)
for a in A:
    samecnt[a] += 1
cnts = [cmbcount(n) for n in samecnt]
allcnt = sum(cnts)
for i in range(N):
    a = A[i]
    o = cnts[a]
    n = cmbcount(samecnt[a] - 1)
    ans = allcnt - (o - n)
    print(ans)

### FIXED CODE ###

from math import factorial
from functools import lru_cache

@lru_cache(maxsize=None)
def cmbcount(n):
    if n > 1:
        return factorial(n) // (factorial(n - 2) * factorial(2))
    return 0

N = int(input())
A = list(map(int, input().split()))
samecnt = [0] * (N + 1)
for a in A:
    samecnt[a] += 1
cnts = [cmbcount(n) for n in samecnt]
allcnt = sum(cnts)
for i in range(N):
    a = A[i]
    o = cnts[a]
    n = cmbcount(samecnt[a] - 1)
    ans = allcnt - (o - n)
    print(ans)
### BUGGY CODE ###

N = int(input())
M = [[0 for col in range(N)] for row in range(N)]

for i in range(N-1):
    a, b, c = list(map(int, input().split(" ")))
    M[a-1][b-1] = M[b-1][a-1] = c

Qn, K = list(map(int, input().split(" ")))

Q = []
for i in range(Qn):
    Q.append(list(map(int, input().split(" "))))

distance = [0]*N

def dfs(k, graph, dist):
    result = {}
    for n in range(N):
        x = graph[k][n]
        if x != 0:
            distance[n] = dist + x
            graph[n][k] = 0
            dfs(n, graph, dist + x)

dfs(K-1, M, 0)

for q in Q:
    print(distance[q[0]-1] + distance[q[1]-1])


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

N = int(input())
M = [[] for i in range(N+1)]

for i in range(N-1):
    a, b, c = list(map(int, input().split(" ")))
    M[a].append((b,c))
    M[b].append((a,c))

Qn, K = list(map(int, input().split(" ")))

Q = []
for i in range(Qn):
    Q.append(list(map(int, input().split(" "))))

distance = [0]*(N+1)

def dfs(k, parent, dist):
    for n, x in M[k]:
        if n != parent:
            distance[n] = dist + x
            dfs(n, k, dist + x)

dfs(K, 0, 0)
for q in Q:
    print(distance[q[0]] + distance[q[1]])
### BUGGY CODE ###

n, w = [int(e) for e in input().split()]
d = [[int(e) for e in input().split()] for i in range(n)]
t = {}
t[w] = 0
for i in range(n):
  keys = list(sorted(t.keys())) # sort しないと品物iを複数回ナップサックに詰める可能性がある
  tw, tv = d[i]
  for j in keys:
    nw = j - tw
    if nw < 0:
      continue
    nv = t[j] + tv
    if nw in t:
      if nv > t[nw]:
        for k in list(t.keys()):
          if k <= nw and t[k] < nv:
            del t[k]
        t[nw] = nv
    else:
      Flag = False
      for k in t:
        if nw <= k and nv <= t[k]:
          Flag = True
          break
      if Flag:
        continue
      for k in list(t.keys()):
        if k <= nw and t[k] < nv:
          del t[k]
      t[nw] = nv
        
print(max(t.values()))

### FIXED CODE ###

n, w = [int(e) for e in input().split()]
d = [[int(e) for e in input().split()] for i in range(n)]
t = {}
t[w] = 0
for i in range(n):
  keys = list(sorted(t.keys()))
  tw, tv = d[i]
  for j in keys:
    nw = j - tw
    if nw < 0:
      continue
    nv = t[j] + tv
    if nw in t:
      if nv > t[nw]:
        t[nw] = nv
    else:
      t[nw] = nv
print(max(t.values()))
### BUGGY CODE ###

L, R = map(int, input().split())
min = float("inf")
for i in range(L, R + 1):
	for j in range(i + 1, R + 1):
		mod = ((i % 2019) * (j % 2019)) % 2019
		if min > mod:
			min = mod
print(min)


### FIXED CODE ###

L, R = map(int, input().split())
# min = float("inf")
# for i in range(L, R + 1):
# 	for j in range(i + 1, R + 1):
# 		mod = ((i % 2019) * (j % 2019)) % 2019
# 		if min > mod:
# 			min = mod

# 2019 = 3 * 673

if R - L >= 2019:
	print(0)
else:
	R %= 2019
	L %= 2019
	if L > R:
		R += 2019
	min = float("inf")
	for i in range(L, R + 1):
		for j in range(i + 1, R + 1):
			mod = ((i % 2019) * (j % 2019)) % 2019
			if min > mod:
				min = mod
	print(min)

# 2020 2040 -> 1 21
# 2010 2030 -> 2010 11
### BUGGY CODE ###

from fractions import gcd


def lcm(x, y):
    return x // gcd(x, y) * y


def greatLcm(array):
    ans = 1
    for i in array:
        ans = lcm(ans, i)
    return ans


mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
p = greatLcm(a)
ans = 0
for j in a:
    ans += p // j
    ans %= mod
print(ans)


### FIXED CODE ###

import fractions

N = int(input())
A = list(map(int, input().split()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def solve():
    memo = A[0]
    for i in range(1, N):
        memo = lcm(memo, A[i])

    ans = 0
    for i in range(N):
        ans += memo // A[i]

    return ans % (10 ** 9 + 7)

print(solve())
### BUGGY CODE ###

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

# input
n = int(input())
a_list = list(map(int, input().split()))

a_count_list = []

a_dic = {}

for i in range(len(a_list)):
    key = a_list[i]
    if key in a_dic:
        a_dic[key] += 1
    else:
        a_dic[key] = 1

a_solution_dic = {}
a_solution_dic_at_k = {}
for key in a_dic:
    if key in a_solution_dic:
        continue
    else:
        a_solution_dic[key] = int(a_dic[key] * (a_dic[key]-1) / 2)
        a_solution_dic_at_k[key] = int((a_dic[key]-1) * (a_dic[key]-2) / 2)


for k, ak in enumerate(a_list):
    sum_select = 0
    sum_select += a_solution_dic_at_k[ak]
    for key in a_solution_dic:
        if key != ak:
            sum_select += a_solution_dic[key]


    print(sum_select)


### FIXED CODE ###

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

# input
n = int(input())
a_list = []
a_dic = {}
for ai in input().split():
    int_ai = int(ai)
    a_list.append(int_ai)
    if int_ai in a_dic:
        a_dic[int_ai] += 1
    else:
        a_dic[int_ai] = 1

a_solution_dic = {}
all_sum_select = 0
for key in list(a_dic.keys()):
    all_sum_select += int(a_dic[key] * (a_dic[key]-1) / 2)
    #a_solution_dic_at_k[key] = int((a_dic[key]-1) * (a_dic[key]-2) / 2)

for k, ak in enumerate(a_list):
    sum_select_at_k = all_sum_select + int((a_dic[ak]-1) * (a_dic[ak]-2) / 2) \
                       - int(a_dic[ak] * (a_dic[ak]-1) / 2)


    print(sum_select_at_k)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
ac = []
for i in range(n-1):
  if s[i:i+2] == "AC":
    ac.append(1)
  else:
    ac.append(0)
for j in range(q):
  l,r = map(int, input().split())
  if r == q:
    r -= 1
  ls = ac[l-1:r-1]
  print(sum(ls))


### FIXED CODE ###

n, q = map(int, input().split())
s = input()
ac = [0] * (n+1)
for i in range(n):
  if s[i:i+2] == "AC":
    ac[i+1] = ac[i] + 1
  else:
    ac[i+1] = ac[i]
for j in range(q):
  l,r = map(int, input().split())
  print(ac[r-1]-ac[l-1])
### BUGGY CODE ###

H, W, D = map(int,input().split())
dist = [0]*(H*W+1)#dist[i]はiからi+Dまでの距離
pos = [[0,0] for i in range(H*W+1)]
for i in range(H):
  A = list(map(int,input().split()))
  for j in range(W):
    pos[A[j]] = [i+1, j+1]
    
for i in range(H*W+1-D):
  dist[i] = abs(pos[i][0]-pos[i+D][0])+abs(pos[i][1]-pos[i+D][1])

distances = [[] for i in range(D)]#あまりがiの距離
for i in range(1,H*W+1-D):
  distances[i%D]+=[dist[i]]

Q = int(input())
for i in range(Q):
  L, R = map(int, input().split())
  l, r = (L-1)//D, (R-1)//D
  print(sum(distances[L%D][l:r]))

### FIXED CODE ###

H, W, D = map(int,input().split())
dist = [0]*(H*W+1)#dist[i]はiからi+Dまでの距離
pos = [[0,0] for i in range(H*W+1)]
for i in range(H):
  A = list(map(int,input().split()))
  for j in range(W):
    pos[A[j]] = [i+1, j+1]
for i in range(H*W+1-D):
  dist[i] = abs(pos[i][0]-pos[i+D][0])+abs(pos[i][1]-pos[i+D][1])
distances = [[] for i in range(D)]#あまりがiの距離
for i in range(1,H*W+1-D):
  d = dist[i]
  distances[i%D]+=[d]
distances2 = [[0] for i in range(D)]#累積和に直す
for i in range(D):
  for j in range(len(distances[i])):
    distances2[i]+=[distances2[i][-1]+distances[i][j]]
Q = int(input())
for i in range(Q):
  L, R = map(int, input().split())
  q = L%D
  l, r = (L-1)//D, (R-1)//D
  print(distances2[q][r]-distances2[q][l])
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
x = 1
t = 0
for i in range(N):
  x*= A[i]
  
if x>10**18:
  print(-1)
else:
  print(x)
  
  


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
x = 1
t = 0
A.sort()
for i in range(N):
  x*= A[i]
  if x>10**18:
    t = 1
    break
  
if t == 1:
  print(-1)
else:
  print(x)
### BUGGY CODE ###

def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines

  h,w = map(int,readline().split())
  a = []
  A = [list(map(int,readline().split())) for _ in range(h)]
  B = [list(map(int,readline().split())) for _ in range(h)]
  C = [[False]*w for _ in range(h)]
  for i in range(h):
      for j in range(w):
          C[i][j] = abs(A[i][j] - B[i][j])

  dp = [[set() for _ in range(w)] for _ in range(h)]
  dp[0][0].add(C[0][0])

  for i in range(h):
    for j in range(w):
      for k in dp[i][j]:
          if i < h-1:
            c = C[i+1][j]
            if k+c < 6321:
              dp[i+1][j].add(k+c)
            dp[i+1][j].add(abs(k-c))
          if j < w-1:
            d = C[i][j+1]
            if k+d < 6321:
              dp[i][j+1].add(k+d)
            dp[i][j+1].add(abs(k-d))

  print(min(dp[h-1][w-1]))
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines

  h,w = map(int,readline().split())
  a = []
  for i in range(h):
    s = list(map(int,readline().split()))
    a.append(s)
  b = []
  for i in range(h):
    t = list(map(int,readline().split()))
    b.append(t)
  C = [[0]*w for _ in range(h)]
  for i in range(h):
      for j in range(w):
          C[i][j] = abs(a[i][j] - b[i][j])

  dp = [[[0]*6321 for i in range(w)] for _ in range(h)]
  dp[0][0][C[0][0]] = 1

  for i in range(h):
    for j in range(w):
      for k in range(6321):
        if dp[i][j][k]:
          if i < h-1:
            c = C[i+1][j]
            if k+c < 6321:
              dp[i+1][j][k+c] = 1
            dp[i+1][j][abs(k-c)] = 1
          if j < w-1:
            d = C[i][j+1]
            if k+d < 6321:
              dp[i][j+1][k+d] = 1
            dp[i][j+1][abs(k-d)] = 1

  for i in range(6321):
    if dp[h-1][w-1][i]:
      print(i)
      break
      
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))

dict_A={}
B=list(set(A))
C=0

for a in A:
    if a not in dict_A.keys():
        dict_A[a]=1
    else:
        dict_A[a]+=1

for n in range(N):
    C=0
    for i in dict_A.keys():
        if A[n]==i:
            C+=(dict_A[i]-1)*(dict_A[i]-2)//2
        else:
            C+=dict_A[i]*(dict_A[i]-1)//2
    print(C)
#print(dict_A)
#print(B)
        
        

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))


dict_A={}
B=list(set(A))
sum=0


for a in A:
    if a not in dict_A.keys():
        dict_A[a]=1
    else:
        dict_A[a]+=1
for b in B:
    sum+=dict_A[b]*(dict_A[b]-1)//2

for a in A:
    print(sum-dict_A[a]+1)
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)

left, right = -1, a[-1] * f[0]

while right - left > 1:#2分探索で探す。
    mid = (left + right) // 2
    ck = 0#修行回数
    for i in range(n): 
      ck += max(0, a[i] - mid // f[i])# (a[i] - ck) * f[i] = midを解いて左記になる。
    if ck <= k: right = mid
    else: left = mid

print(right)


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)

left, right = -1, a[-1] * f[0]

while right - left > 1:#2分探索で探す。
    mid = (left + right) // 2
    ck = 0#修行回数
    for i in range(n): 
      ck += max(0, a[i] - mid // f[i])# (a[i] - ck) * f[i] = midを解いて左記になる。
    if ck <= k: right = mid
    else: left = mid

print(right)
### BUGGY CODE ###

import sys

N=int(input())
A=list(map(int, input().split()))
if 0 in A:
    print(0)
    sys.exit(0)
ans=1
for i in A:
    ans = ans*i
if ans <= 1000000000000000000:
    print(ans)
else:
    print(-1)

### FIXED CODE ###

def cal():
    N=int(input())
    A=list(map(int, input().split()))
    if 0 in A:
        print(0)
        return
    ans=1
    for i in A:
        ans = i*ans
        if ans > 1000000000000000000:
            print(-1)
            return
    print(ans)

cal()
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split()))
ans = 1

for i in range(1, N):
    if P[i] <= min(P[:i]):
        ans += 1

print(ans)


### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))

'''
参考
https://cocoinit23.com/abc152/
すべての(i, j)を調べていると制限時間を超過してしまう。
listの2つ目の要素(index=1)から順に見ていって、最小値が更新されたら解をカウントアップする。
ただし、解の最小値は常に1となるので、解の初期値は1にしておくこと。
'''
ans = 1
min_p = P[0]

for i in range(1, N):
    if P[i] <= min_p:
        min_p = P[i]
        ans += 1

print(ans)
### BUGGY CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import deque

H, W = map(int,input().split())
sth, stw = map(int,input().split())
glh, glw = map(int,input().split())
sth, stw = sth-1, stw-1
glh, glw = glh-1, glw-1

INF = -1
Gmap = [list(input()) for _ in range(H)]
seen = [[INF]*W for _ in range(H)]
direc = {(1,0), (-1,0), (0,1), (0,-1)}
direc5 = set([])
for i in range(-2,3):
    for j in range(-2,3):
        direc5.add((i, j))
direc5 = direc5 - direc
direc5 = direc5 - {(0,0)}
nxt_st = set([])

def bfs(pnxt):
    next_q = deque([])
    for hw in pnxt:
        next_q.append(hw)
    nxt = set([])
    while len(next_q)!=0:
        #キュー取り出し(先頭)
        h,w = next_q.popleft()
        if h == glh and w == glw:
            print(ret)
            exit()
        seen[h][w] = 0
        for dh, dw in direc:
            hs, ws = h + dh, w + dw
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='.' and seen[hs][ws]==INF:
                next_q.append((hs, ws))
        for dh, dw in direc5:
            hs, ws = h + dh, w + dw
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='.' and seen[hs][ws]==INF and not (hs, ws) in pnxt:
                nxt.add((hs, ws))

    return nxt

ret = -1
nxt_st.add((sth, stw))
while len(nxt_st)>0:
    ret += 1
    nxt_st = bfs(nxt_st)
print(-1)


### FIXED CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import deque

H, W = map(int,input().split())
sth, stw = map(int,input().split())
glh, glw = map(int,input().split())
sth, stw = sth-1, stw-1
glh, glw = glh-1, glw-1

INF = -1
Gmap = [list(input()) for _ in range(H)]
seen = [[INF]*W for _ in range(H)]
direc = {(1,0), (-1,0), (0,1), (0,-1)}
direc5 = set([])
for i in range(-2,3):
    for j in range(-2,3):
        direc5.add((i, j))
direc5 = direc5 - direc
direc5 = direc5 - {(0,0)}

def bfs(pnxt):
    next_q = deque([])
    for h, w in pnxt:
        next_q.append((h,w))
        seen[h][w] = 0
    nxt = set([])
    while len(next_q)!=0:
        h, w = next_q.popleft()
        if h == glh and w == glw:
            print(ret)
            exit()
        for dh, dw in direc:
            hs, ws = h + dh, w + dw
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='.' and seen[hs][ws]==INF:
                next_q.append((hs, ws))
                seen[hs][ws] = 0
        for dh, dw in direc5:
            hs, ws = h + dh, w + dw
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='.' and seen[hs][ws]==INF and not (hs, ws) in nxt:
                nxt.add((hs, ws))
    return nxt

ret = 0
nxt_st = set([])
nxt_st.add((sth, stw))
while len(nxt_st)>0:
    nxt_st = bfs(nxt_st)
    ret += 1
print(-1)
### BUGGY CODE ###

from collections import deque
N,K = map(int,input().split())
P = list(map(int,input().split()))

s = [1]*N
r = 0
for l in range(N):
    r = max(l,r)
    while r < N-1:
        if P[r]<P[r+1]:
            r += 1
        else:
            break
    s[l] = r-l+1
    
q = deque([N]+P[:K-1])

ans = 0

for i in range(N-K+1):
    q.append(P[i+K-1])
    if min(q)!=P[i-1] or max(q)!=P[i+K-1]:
        if s[i]<K:
            ans += 1
    q.popleft()

if max(s) >= K:
    ans += 1

print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
P = list(map(int,input().split()))

N0 = 2**(N-1).bit_length()
INF = 2**31-1
data_m = [INF]*(2*N0)
data_M = [INF]*(2*N0)

def update(k, x, data):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])

def query(l, r, data):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])

        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

for i in range(N):
    update(i, P[i], data_m)
    update(i, -P[i], data_M)

s = [1]*N
r = 0
for l in range(N):
    r = max(l,r)
    while r < N-1:
        if P[r]<P[r+1]:
            r += 1
        else:
            break
    s[l] = r-l+1
    
ans = 0
if s[0]<K:
    ans += 1

for i in range(1,N-K+1):
    if query(i-1,i+K,data_m)!=P[i-1] or query(i-1,i+K,data_M)!=-P[i+K-1]:
        if s[i]<K:
            ans += 1

if max(s) >= K:
    ans += 1

print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
s=[0]*(n+1)
s[0]=1
for i in range(1,n+1):
    if a.count(i)!=0:
        s[i]=0
    else:
        if i-2>=0:
            s[i]+=(s[i-1]+s[i-2])%1000000007
        else:
            s[i]+=s[i-1]%1000000007
print(s[n])
        


### FIXED CODE ###

n,m=map(int,input().split())
a=0
if m!=0:
    a=int(input())
    
b=1
s=[1]*(n+1)
for i in range(1,n+1):
    if i!=a:
        if i-2>=0:
            s[i]=(s[i-1]+s[i-2])%1000000007
        else:
            s[i]=s[i-1]%1000000007
    elif b!=m:
        s[i]=0
        a=int(input())
        b+=1
    else:
        s[i]=0
print(s[n])
### BUGGY CODE ###

class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    # assert i > 0
    while i <= self.n:
      self.data[i] += x
      i += i & -i

N, Q = map(int, input().split())
Cs = [0] + list(map(int, input().split()))

Qs = []
for i in range(Q):
  l,r = map(int, input().split())
  Qs.append((i,l,r))
  
Qs.sort(key=lambda x:x[2])

ans = [-1]*Q
dic = {}
b = 1
bt = BIT(N)

for i,l,r in Qs:
  if b < r + 1:
    st = set()
    for j in range(b,r+1):
      if not Cs[j] in st and Cs[j] in dic:
        bt.add(dic[Cs[j]],-1)
      st.add(Cs[j])
      dic[Cs[j]] = j
    for s in st:
      bt.add(dic[s], 1)
    b = r + 1
  ans[i] = bt.sum(r) - bt.sum(l-1)
    
for a in ans:
  print(a)

### FIXED CODE ###

from sys import stdin
input = stdin.readline
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
n, q = map(int, input().split())
tmp = list(map(int, input().split()))
color = [-1]
for v in tmp:
    color.append(v)
qry = [None]*q
ans = [0]*q
p = 0
for _ in ans:
    l, r = map(int, input().split())
    qry[p] = [l-1, r, p]
    p += 1
qry.sort(key=lambda x: x[1])
dic = {}
last_update_idx = 1
bit = Bit(n)
for l, r, i in qry:
    if last_update_idx < r+1:
        st = set()
        for j in range(last_update_idx, r+1):
            if not color[j] in st and color[j] in dic:
                bit.add(dic[color[j]], -1)
            dic[color[j]] = j
            st.add(color[j])
        for v in st:
            bit.add(dic[v], 1)
        last_update_idx = r+1
    ans[i] = bit.sum(r) - bit.sum(l)
for v in ans:
    print(v)
### BUGGY CODE ###

import sys

input = sys.stdin.readline
N = int(input())
Ss = []
for i in range(N):
    Ss.append(''.join(sorted(list(input().rstrip("\n")))))

c = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if Ss[i] == Ss[j]:
            c += 1

print(c)

### FIXED CODE ###

import sys

input = sys.stdin.readline
N = int(input())
Ss = {}
for i in range(N):
    s = ''.join(sorted(list(input().rstrip("\n"))))
    if s in Ss:
        Ss[s] += 1
    else:
        Ss[s] = 1

c = 0
for s in Ss.values():
    c += (s - 1) * s // 2

print(c)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

if N % 2 == 0:
    for i in range(1, N, 2):
        if A.count(i) != 2:
            print(0)
            exit()
else:
    if A.count(0) != 1:
        print(0)
        exit()
    for i in range(2, N, 2):
        if A.count(i) != 2:
            print(0)
            exit()

print(2 ** (N // 2) % mod)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

A.sort()
if N % 2 == 0:
    # print(A[0:N:2])
    # print(A[1:N+1:2])
    if A[0:N:2] != A[1:N+1:2]:
        print(0)
        exit(0)
else:
    if A[0] != 0:
        print(0)
        exit()
    if A[1:N-1:2] != A[2:N:2]:
        print(0)
        exit()

print(2 ** (N // 2) % mod)