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

n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
for i in  temparr:
    if first == 0 :
        totallen += len(i)
        first = 1 
    else:
        totallen += len(i) - 1 
    if totallen > 19:
        flag = 2
        break
    if "0" in temparr:
        flag = 1 
        break 

    arr.append(int(i))
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)
        
        
        

### FIXED CODE ###

n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
arr =[]
arr1 = []
for i in temparr:
    arr1.append(int(i))
arr1 = sorted(arr1)
for i in arr1:
    if i == 0 :
        flag = 1 
        break 
    if i == 1 :
        continue 
    
    if first == 0 :
        totallen += len(str(i))
        first = 1 
    else:
        totallen += len(str(i)) - 1 
    if totallen > 19:
        flag = 2
        break
    arr.append(i)
    
    
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    arr = sorted(arr)
    arr = arr[::-1]
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)
### BUGGY CODE ###

N = int(input())
As = sorted(list(map(int, input().split())), reverse = True)

points = []
for i in range(N):
  points = points + [As[i]] * (i+1)
print(sum(points[:N-1]))

### FIXED CODE ###

N = int(input())
As = sorted(list(map(int, input().split())), reverse = True)
ans = As[0]
N -= 2

p = N // 2
ans += sum(As[1:1+p]) * 2

if N % 2 == 1:
  ans += As[1+p]

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

N,A,B=map(int,input().split())
a=[]
while len(a) < N:
    for i in range(A):
        a.append("x")
    for j in range(B):
        a.append("y")
ans=a[:N]
print(ans.count("x"))




### FIXED CODE ###

N,A,B=map(int,input().split())
K=N//(A+B)
print(K*A+min(A,N%(A+B)))
### BUGGY CODE ###

import itertools
N, M, K = map(int, input().split())
Q = [list(map(int, input().split())) for i in range(N)]
min_cost = 10**9
for q in itertools.permutations(Q):
  cost = 0
  C = [0] * M
  for i in q:
    cost += i[0]
    for j,c in enumerate(i[1:]):
      C[j] += c
    if len([c for c in C if c >= K]) == M:
      min_cost = min([cost, min_cost])
      break
print(min_cost) if min_cost != 10**9 else print(-1)


### FIXED CODE ###

import numpy as np
import itertools
N, M, K = map(int, input().split())
Q = [np.asarray(input().split(), dtype=int) for i in range(N)]
min_cost = 10**9
def dfs(cost, C, depth=0):
  global min_cost
  if (C >= K).all():
    min_cost = min([cost, min_cost])
    return
  if depth == N:
    return
  dfs(cost+Q[depth][0], C + Q[depth][1:], depth+1)
  dfs(cost, C, depth+1)
  
dfs(0, np.zeros(M))
    
print(min_cost) if min_cost != 10**9 else print(-1)
### BUGGY CODE ###

from collections import Counter

N = int(input())
S = []
for _ in range(N):
    S.append(Counter(list(input())))

count = 0
for i in range(N):
    for j in range(i + 1, N):
        if S[i] == S[j]:
            count += 1

print(count)

### FIXED CODE ###

from collections import Counter

N = int(input())
S = []
for _ in range(N):
    S.append("".join(sorted(input())))

c = Counter(S)
print(sum([k*(k-1)//2 for k in c.values()]))
### BUGGY CODE ###

N = int(input())
D = input().split()
M = int(input())
T = input().split()
judge = 0

for t in T:
    if t in D:
        D.remove(t)
    else:
        judge = 1
        break

if judge == 0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

N = int(input())
Di = input().split()
D = {}
for d in Di:
    if d in D:
        D[d] += 1
    else:
        D[d] = 1
M = int(input())
T = input().split()
judge = 0

for t in T:
    if (t in D) and (D[t] != 0):
        D[t] -= 1
    else:
        judge = 1
        break

if judge == 0:
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

import sys
n, m = map(int, sys.stdin.readline().split())
req = [ list(sorted(map(int, sys.stdin.readline().split())))
        for _ in range(m) ]
req.sort(reverse=True)
cutlist = []
for a, b in req:
    cut = False
    for i in cutlist:
        if a <= i and i < b:
            cut = True
            break
    if not cut:
        cutlist.append(a)
print(len(cutlist))


### FIXED CODE ###

import sys
n, m = map(int, sys.stdin.readline().split())
req = [ list(sorted(map(int, sys.stdin.readline().split())))
        for _ in range(m) ]
req.sort(reverse=True)
lastcut = None
c = 0
for a, b in req:
    if lastcut is None or a > lastcut or lastcut >= b:
        lastcut = a
        c += 1
print(c)
### BUGGY CODE ###

import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n, m = map(int, input().split())
data = getSomeInputListInt(n)

ans = 0
for i in range(1, m+1):
    tmp = 0
    tmpidx = -1
    for j in range(len(data)-1, -1, -1):
        if data[j][0] <= i:
           if tmp < data[j][1]:
               tmp = data[j][1]
               tmpidx = j
    if tmpidx != -1:
        ans += tmp
        data[tmpidx][1] = 0

print(ans)

### FIXED CODE ###

import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

input = sys.stdin.readline
sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n, m = map(int, input().split())
data = getSomeInputListInt(n)

data_list = [[0] for _ in range(m)]

for i in range(n):
    if data[i][0]-1 < m:
        data_list[data[i][0]-1].append(-data[i][1])

heap_list = []
heapq.heapify(heap_list)
# heapq.heapify(data_list)

ans = 0
for j in range(m):
    for i in range(len(data_list[j])):
        heapq.heappush(heap_list, data_list[j][i])
    a = heapq.heappop(heap_list)
    ans += a

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

k,s = map(int,input().split())
counter = 0
for i in range(k+1):
  for m in range(k+1):
    for l in range(k+1):
      if (i + m + l) ==  s:
        counter+= 1
print(counter)

### FIXED CODE ###

k,s = map(int,input().split())
counter = 0
for i in range(k+1):
  for m in range(k+1):
    if 0 <= s-i-m <= k:
      counter += 1
print(counter)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
kami = []
for i in range(N):
    if A[i] in kami:
        kami.remove(A[i])
    else:
        kami.append(A[i])
print(len(kami))

### FIXED CODE ###

import collections
N = int(input())
A = [int(input()) for i in range(N)]
acount = collections.Counter(A)
a = acount.most_common()
count = 0
alen = len(a)
for j in range(alen):
    if a[j][1]%2 == 1:
        count+=1
print(count)
### BUGGY CODE ###

h, w = map(int, input().split())
inf = float('INF')
A = []
B = []

for i in range(h):
    line = list(map(int, input().split()))
    A.append(line)

for i in range(h):
    line = list(map(int, input().split()))
    B.append(line)

D = [[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        D[i][j] = abs(A[i][j] - B[i][j])


def slide_down(y, x, possible: set):
    new = set()
    delta = D[y+1][x]
    for num in possible:
        if num + delta <=16000:
            new.add(num+delta)
        if abs(num-delta) <= 16000:
            new.add(abs(num-delta))
    return new


def slide_right(y, x, possible: set):
    new = set()
    delta = D[y][x+1]
    for num in possible:
        if num + delta <=16000:
            new.add(num+delta)
        if abs(num-delta) <=16000:
            new.add(abs(num-delta))
    return new


DP = [[set() for j in range(w)] for i in range(h)]
DP[0][0] = {D[0][0]}
for row in range(h):
    for col in range(w):
        possible = DP[row][col]
        if col < w-1:
            new = slide_right(row, col, possible)
            DP[row][col+1] |= new
        if row < h-1:
            new = slide_down(row, col, possible)
            DP[row+1][col] |= new

ans = min(DP[h-1][w-1])
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline


h, w = map(int, input().split())
inf = float('INF')
A = []
B = []

for i in range(h):
    line = list(map(int, input().split()))
    A.append(line)

for i in range(h):
    line = list(map(int, input().split()))
    B.append(line)

D = [[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        D[i][j] = abs(A[i][j] - B[i][j])


def slide_down(y, x, possible):
    new = set()
    delta = D[y+1][x]
    limit = (h+w) * 80
    for num in possible:
        if num + delta <= limit - (y+x)*80:
            new.add(num+delta)
        if abs(num-delta) <= limit - (y+x)*80:
            new.add(abs(num-delta))
    return new


def slide_right(y, x, possible):
    new = set()
    delta = D[y][x+1]
    limit = (h+w) * 80
    for num in possible:
        if num + delta <= limit - (y+x)*80:
            new.add(num+delta)
        if abs(num-delta) <= limit - (y+x)*80:
            new.add(abs(num-delta))
    return new


DP = [[set() for j in range(w)] for i in range(h)]
DP[0][0] = {D[0][0]}
for row in range(h):
    for col in range(w):
        possible = DP[row][col]
        if col < w-1:
            new = slide_right(row, col, possible)
            DP[row][col+1] |= new
        if row < h-1:
            new = slide_down(row, col, possible)
            DP[row+1][col] |= new

ans = min(DP[h-1][w-1])
print(ans)
### BUGGY CODE ###

N ,Q = map(int, input().split())
S = input()
    
def countAC(S, r, l):
    data = S[r-1:l]
    cnt = 0
    for i in range(0, len(data), 2):
        if data[i]=='A':
            if (i+1)<len(data):
                if data[i+1] == 'C':
                    cnt+=1
        elif data[i]=='C':
            if (i-1)>=0:
                if data[i-1] == 'A':
                    cnt+=1
    return cnt
  
ret = []

for i in range(Q):
    r, l = map(int, input().split())
    cnt = countAC(S, r, l)
    ret.append(str(cnt))
print('\n'.join(ret))

### FIXED CODE ###

N ,Q = map(int, input().split())
S = input()

cumul = [0]*len(S)
cnt = 0
for i in range(len(S)-1):
    cumul[i] = cnt
    if S[i]=='A':
        if S[i+1] == 'C':
            cnt+=1
cumul[-1]=cnt

ret = []
for i in range(Q):
    l, r = map(int, input().split())
    cnt = cumul[r-1] - cumul[l-1]
    ret.append(str(cnt))
print('\n'.join(ret))
### BUGGY CODE ###

import functools

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

l_gcd = []

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

for i,j in enumerate(A):
    B = j
    A.pop(i)
    l_gcd.extend([functools.reduce(gcd,A)])
    A.insert(i,B)

print(max(l_gcd))


### FIXED CODE ###

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

w_min = A[1]

for i in range(w_min,0,-1):
    count = 0
    for j in A:
        if j%i != 0:
            count = count + 1
            if count > 1:
                break
    if count < 2:
        print(i)
        break
### BUGGY CODE ###

import numpy as np


def z_algorithm(S):
    n = len(S)
    A = [0] * n
    A[0] = n
    L = 0
    R = 0
    # 過去にS[R]まで調べたとする
    for i in range(1, n):
        if R <= i:
            L = R = i
            while R < n and S[R] == S[R - L]:
                R += 1
            A[i] = R - L
        elif A[i - L] < R - i:
            A[i] = A[i - L]
        else:
            L = i
            while R < n and S[R] == S[R - L]:
                R += 1
            A[i] = R - L
    return A


def main():
    N = int(input())
    S = input()
    answer = 0
    for i in range(1, N - 1):
        a = np.array(z_algorithm(S[i:]), np.int64)
        arange = np.arange(N - i)
        cnt = np.minimum(arange, a)
        cnt = cnt[1:].max()
        if cnt > answer:
            answer = cnt

    print(answer)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def z_algorithm(S):
    n = len(S)
    A = [0] * n
    A[0] = n
    L = 0
    R = 0
    # 過去にS[R]まで調べたとする
    for i in range(1, n):
        if R <= i:
            L = R = i
            while R < n and S[R] == S[R - L]:
                R += 1
            A[i] = R - L
        elif A[i - L] < R - i:
            A[i] = A[i - L]
        else:
            L = i
            while R < n and S[R] == S[R - L]:
                R += 1
            A[i] = R - L
    return A


def main():
    N = int(input())
    S = input()
    answer = 0
    for i in range(N):
        a = z_algorithm(S[i:])
        for j in range(1, N - i):
            cnt = min(j, a[j])
            if cnt > answer:
                answer = cnt

    print(answer)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

def merge_sort(A):
    if len(A) <= 1:
        return A, 0
    mid = len(A) // 2
    #print A[:mid]
    #print A[mid:]
    left, lcount = merge_sort(A[:mid])
    right, rcount = merge_sort(A[mid:])
    merged, count = merge(left, right)
    return merged, lcount + rcount + count

def merge(left, right):
    lpos = 0
    rpos = 0
    rcount = 0
    merged = []
    while lpos < len(left) and rpos < len(right):
        if left[lpos] < right[rpos]:
            merged.append(left[lpos])
            lpos += 1
        else:
            merged.append(right[rpos])
            rpos += 1
            rcount += len(left[lpos:])
    
    if left[lpos:]:
        merged.extend(left[lpos:])
    if right[rpos:]:
        merged.extend(right[rpos:])
    
    return merged, rcount
    
if __name__ == '__main__':
    n = int(raw_input())
    A = map(long, raw_input().split())
    
    sorted, count = merge_sort(A)
    #print ' '.join(str(x) for x in sorted)
    print count

### FIXED CODE ###

from array import array

def merge_sort(A):
    if len(A) <= 1:
        return A, 0
    mid = len(A) // 2
    left, lcount = merge_sort(A[:mid])
    right, rcount = merge_sort(A[mid:])
    merged, count = merge(left, right)
    return merged, lcount + rcount + count

def merge(left, right):
    lpos = 0
    rpos = 0
    rcount = 0
    merged = array('I', [])  # List is too slow. Use an array instead.
    len_left = len(left)
    len_right = len(right)
    while lpos < len_left and rpos < len_right:
        if left[lpos] < right[rpos]:
            merged.append(left[lpos])
            lpos += 1
        else:
            merged.append(right[rpos])
            rpos += 1
            #rcount += len(left[lpos:])
            rcount += len_left - lpos
    
    if left[lpos:]:
        merged.extend(left[lpos:])
    if right[rpos:]:
        merged.extend(right[rpos:])
    
    return merged, rcount
    
if __name__ == '__main__':
    n = int(raw_input())
    A = array('I', map(int, raw_input().split()))
    
    sorted, count = merge_sort(A)
    #print ' '.join(str(x) for x in sorted)
    print count
### BUGGY CODE ###

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

ans = 0

for i in range(a,b+1):
    if i % x == 0:
        ans = ans + 1

print(ans)

### FIXED CODE ###

a,b,x=map(int,input().split())
b_count=b//x
a_count=(a-1)//x
print(b_count-a_count)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n = int(input())
a = [list(map(lambda x: int(x)-1, input().split())) for _ in range(n)]
idx = [0] * n

remain_games = n * (n-1) // 2
ans = 0
while remain_games:
    flag = [0] * n
    update = False
    for i in range(n):
        if idx[i] == n-1 or idx[ a[i][idx[i]] ] == n-1:
            continue

        b = a[i][idx[i]]
        if flag[i] == 0 and a[b][ idx[b] ] == i and flag[b] == 0:
            # b = a[i].popleft()
            # _ = a[b].popleft()
            idx[b] += 1
            idx[i] += 1
            flag[i] = 1
            flag[b] = 1
            remain_games -= 1
            # print(ans, i, b)
            update = True
    if not update:
        ans = -1
        break
    ans += 1

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
a = [list(map(lambda x: int(x)-1, input().split())) for _ in range(n)]

def calc_idx(x, y):
    if x > y:
        x, y = y, x
    return x + y*(y-1)//2

n_game = n * (n-1) // 2
edge = [[] for i in range(n_game)]
for i in range(n):
    for j in range(1, n-1):
        g1 = calc_idx(i, a[i][j-1])
        g2 = calc_idx(i, a[i][j])
        edge[g1].append(g2)

indegree = [0] * n_game
for i in range(n_game):
    for v in edge[i]:
        indegree[v] += 1

ans = 0
cand = [i for i in range(n_game) if indegree[i] == 0]
ts = []
while cand:
    ts.extend(cand)
    cand2 = []
    for ci in cand:
        for v in edge[ci]:
            indegree[v] -= 1
            if indegree[v] == 0:
                cand2.append(v)
    cand = cand2
    ans += 1

if len(ts) != n_game:
    ans = -1

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

#input = ["3 5","0 0 1","0 1 2","0 2 3","1 0 2","1 1 2"]
#input = ["1 3","1 0 0","0 0 5","1 0 0"]
#input = ["2 15","1 0 1","1 0 0","1 1 1","0 0 2","1 0 1","1 0 0","1 1 1","0 1 1","1 0 1","1 0 0","1 1 1","0 1 5","1 0 1","1 0 0","1 1 1"]
output=[]

l = raw_input().split()
#l=input[0].split()

n = int(l[0])
a = [2147483647]*n

for i in range(0,int(l[1])):
	l = raw_input().split()
#	l=input[i+1].split()
	if int(l[0])==0:
		a[int(l[1])]=int(l[2])
	else:
		output.append(min(a[int(l[1]):int(l[2])+1]))

for i in output:
	print i

### FIXED CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
def main(init=int(2**31-1), readline=stdin.readline):
    n, q = (int(s) for s in readline().split())
 
    a = [init] * n
    b = [init] * ((n // 100) + 1)
 
    for _ in range(q):
        com, x, y = (int(s) for s in readline().split())
        if com:
            bx = x - (x % 100) + 100
            by = y - (y % 100)
            if bx < by:
                m = min(min(a[x:bx]), min(b[bx//100:by//100]),
                        min(a[by:y+1]))
            else:
                m = min(a[x:y+1])
            print(m)
        else:
            a[x] = y
            bx = x - (x % 100)
            b[x//100] = min(a[bx:bx+100])
 
 
main()
### BUGGY CODE ###

import collections

n, m = map(int, input().split())

l = []
l2 = []
count = 0

for i in range(m):
    array = list(map(int, input().split()))
    l.append(array)

for i in range(m):
    for j in range(l[i][0], l[i][1]+1):
        l2.append(j)

c = collections.Counter(l2)
d = sorted(list(c.values()),reverse=True)

for i in d:
    if i == m:
        count += 1

print(count)


### FIXED CODE ###

n, m = map(int, input().split())

x = []
y = []

for i in range(m):
    array = list(map(int, input().split()))
    x.append(array[0])
    y.append(array[1])

a = max(x[:])
b = min(y[:])

print(len(list(range(a, b+1))))
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
print(*[l.index(i)+1 for i in range(1,n+1)],sep=" ")

### FIXED CODE ###

def main():
  n=int(input())
  l=list(map(int,input().split()))
  k=[0]*n
  for i in range(1,n+1):
    k[l[i-1]-1]=str(i)
  print(" ".join(k))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

N = int(input())
A = [[int(i) for i in input().split()] for j in range(N)]

Possible = True
NoNeed = set()
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            a, b, c = A[i][j], A[j][k], A[i][k]
            if a+b>=c and b+c>=a and c+a>=b:
                if a+b==c:
                    NoNeed |= {(i, k)}
                elif b+c==a:
                    NoNeed |= {(i, j)}
                elif c+a == b:
                    NoNeed |= {(j, k)}
            else:
                Possible = False
                break 

if Possible:
    Total = 0
    for i in range(N-1):
        for j in range(i+1, N):
            if (i, j) in NoNeed:
                continue
            else:
                Total += A[i][j]
    print(Total)
else:
    print(-1)

### FIXED CODE ###

import sys
from itertools import permutations, combinations
  
def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [[int(a) for a in input().split()] for _ in range(N)]

    length = 0
    possible = True
    for a, b in combinations(range(N), 2):
        Lab = A[a][b]
        create_pass = True
        for k in range(N):
            if k != a and k != b:
                if Lab >  A[a][k] + A[k][b]:
                    possible = False
                    break
                elif Lab ==  A[a][k] + A[k][b]:
                    create_pass = False
                    break
        if create_pass: length += Lab
        if not possible:
            print(-1)
            break
    else: print(length)
    
    return 0
  
if __name__ == "__main__":
    solve()
### BUGGY CODE ###

import sys

def main():
    N, M = map(int, input().split())
    a = [int(input()) for _ in range(M)]

    dp = [0]*(N+1)

    for i in range(0, N+1):
        if i in a:
            dp[i] = 0
            continue

        if i == 0 or i == 1:
            dp[i] = 1
            continue

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

    print(dp[N] % 1000000007)

main()

### FIXED CODE ###

import sys
from collections import deque

def main():
    N, M = map(int, input().split())
    a = deque([int(sys.stdin.readline().strip()) for _ in range(M)])

    atmp = -1
    if len(a) != 0:
        atmp = a.popleft()

    dp=[0] * (N+1)
    for i in range(0, N+1):
        if i == atmp:
            if len(a) != 0:
                atmp = a.popleft()
            continue

        if i == 0 or i == 1:
            dp[i] = 1
            continue

        if dp[i-1] == 0 and dp[i-2] == 0:
            break


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

    print(dp[N] % 1000000007)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import heapq


hq = []
while True:
    cmd = input().split()
    if cmd[0] == "insert":
        heapq.heappush(hq, -int(cmd[1]))
    elif cmd[0] == "extract":
        heapq.heapify(hq)
        print(-heapq.heappop(hq))
    else:
        break

### FIXED CODE ###

import heapq


hq = []
while True:
    cmd = input().split()
    if cmd[0] == "insert":
        heapq.heappush(hq, -int(cmd[1]))
    elif cmd[0] == "extract":
        print(-heapq.heappop(hq))
    else:
        break
### BUGGY CODE ###

def main(N, M, a_list):
    div = 10**9 + 7
    
    dp = {}
    dp[0] = 1
    if 1 in a_list:
        dp[1] = 0
    else:
        dp[1] = 1

    for i in range(N):
        if i+2 in a_list:
            dp[i+2] = 0
        else:
            dp[i+2] = (dp[i+1] + dp[i])
    
    print(dp[N] % div)


if __name__ == "__main__":
    N, M = [int(x) for x in input().split()]
    a_list = []
    for _ in range(M):
        a_list.append(int(input()))

    main(N, M, a_list)


### FIXED CODE ###

def main(N, M, a_list):
    div = 10**9 + 7

    a_set = set(a_list)
    
    dp = {}
    dp[0] = 1
    if 1 in a_set:
        dp[1] = 0
    else:
        dp[1] = 1

    for i in range(N):
        if i+2 in a_set:
            dp[i+2] = 0
        else:
            dp[i+2] = (dp[i+1] + dp[i])
    
    print(dp[N] % div)


if __name__ == "__main__":
    N, M = [int(x) for x in input().split()]
    a_list = []
    for _ in range(M):
        a_list.append(int(input()))

    main(N, M, a_list)