Harryxun/stf_run huggingface dataset:
n=int(input())
L=input()
S=input()
T=[]
i=0
while n-2>=i:
	if L[i]==L[i+1]:
		T.append(0)
		i+=2
	else:
		T.append(1)
		i+=1

def f(x,y):
	if x==0 and y==1:
		return 1
	if x==0 and y==0:
		return 3
	if x==1 and y==1:
		return 2
	if x==1 and y==0:
		return 2
if T[0]==0:
	ans=3
else:
	ans=6

print(T)
for i in range(len(T)-1):
	ans=ans*f(T[i],T[i+1])

print(ans)


			

### FIXED CODE ###

n=int(input())
L=input()+'?'
S=input()
T=[]
i=0


while n-1>=i:
	if L[i]==L[i+1]:
		T.append(0)
		i+=2
	else:
		T.append(1)
		i+=1

        
def f(x,y):
	if x==0 and y==1:
		return 1
	if x==0 and y==0:
		return 3
	if x==1 and y==1:
		return 2
	if x==1 and y==0:
		return 2
if T[0]==0:
	ans=6
else:
	ans=3
mod = 10**9 + 7
for i in range(len(T)-1):
	ans=ans*f(T[i],T[i+1])
	ans=ans%mod
print(ans)
n=int(input())
s=input()
s.pop(n)
print(s.append(s.pop(n)))

### FIXED CODE ###

N = int(input())
S = [i for i in input()]
alpha=['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
ans=''
for c in S:
    cnt = alpha.index(c)+N
    if cnt > 25:
        cnt=cnt-26
    c = alpha[cnt]
    ans+=c
print(ans)
a, b = input().split()
a, b = int(a), int(b)

n = 1
for i in range(a, b + 1):
    n *= i

if a < 0 < b:
    print("Zero")
else 0 < a < b:
    print("Positive")
if a < b < 0:
    if (b - a + 1) % 2 == 0:
        print("Positive")
    else:
        print("Negative")


### FIXED CODE ###

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

if a < 0 < b:
    print("Zero")
elif 0 < a < b:
    print("Positive")
elif a < b < 0:
    if (b - a + 1) % 2 == 0:
        print("Positive")
    else:
        print("Negative")
N=int(input())
C=input()
C=[str(c) for c in C]

for i in range(N):
    if C[i]=="R":
        C=C[i:]
        break
for i in range(N):
    if C[-i]=="W":
        C=C[:-i+1]
        break    
    

print(min(C.count("R"),C.count("W")))

### FIXED CODE ###

N=int(input())
C=input()

W=0
R=C.count("R")
ans=R
for i in range(N):
    
    if C[i]=="R":
        R-=1
    else:
        W+=1
    if  ans>max(W,R):
        ans=max(W,R)
print(ans)
N = int(input())
nums = [int(x) for x in input().split()]
cnt = 0
loop = True
while loop:
  if not all([n%2 is 0 for n in nums]):
    loop = Flase 
    break
  for i, n in enumerate(nums):
    nums[1] = n//2
  cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
nums = [int(x) for x in input().split()]
cnt = 0
loop = True
while loop:
  if not all([n % 2 is 0 for n in nums]):
    loop = False 
    break
    
  for i, n in enumerate(nums):
    nums[i] = n//2
  cnt += 1
print(cnt)
n = int(input())

if n == 1:
    print("Hello World")
else:
    a, b = map(int,input().split())
    print(a+b)
  

### FIXED CODE ###

n = int(input())

if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)
from fractions import gcd
s = input()
t = input()
sl = len(s)
tl = len(t)

stemp = s * ((tl)//gcd(sl, tl))
ttemp = t * ((sl)//gcd(sl, tl))
if stemp == ttemp:
    print(-1)

else:
    s *= tl//sl + 5
    s *= 3

    sl = len(s)
    count = 0
    ans = 0

    r = 0
    while r + tl <= sl-1:
        if s[r:r+tl] == t:
            count += 1
            ans = max(ans, count)
            r += tl
        else:
            count = 0
            r += 1

    print(ans)


### FIXED CODE ###

import sys
import random
s = input()
t = input()
sl = len(s)
tl = len(t)

l = 0
r = 1500000//tl + 1
r2 = r
s *= 1499999//sl + 1
n = len(s)

base1 = 1007
mod1 = 10**9+7
modTank1 = [3000012541,3000012553,3000012563,3000012649,3000012683,3000012709]
mod1 = modTank1[random.randint(0,5)]
base1 = 1007
mod1 = 10**9+7
hash1 = [0]*(n+1)
power1 = [1]*(n+1)
for i,e in enumerate(s):
    hash1[i+1] = (hash1[i]*base1 + ord(e))%mod1
    power1[i+1] = (power1[i]*base1)%mod1

def rolling_hash(i, j):
    return (hash1[j]-hash1[i]*power1[j-i]%mod1)%mod1


while r - l > 1:
    m = l + (r-l)//2
    lt = len(t)*m
    hash2 = [0]*(lt+1)
    power2 = [1]*(lt+1)
    for i,e in enumerate(t*m):
        hash2[i+1] = (hash2[i]*base1 + ord(e))%mod1
        power2[i+1] = (power2[i]*base1)%mod1
    r_hash = hash2[-1]%mod1

    lt = len(t)*m
    flag = 0
    for i in range(len(s)-lt+1):
        if r_hash == rolling_hash(i, i+lt):
            flag = 1
            break

    if flag == 1:
        l = m
    else:
        r = m

if l*tl >= 1000000:
    print(-1)
else:
    print(l)
N = int(input())

for i in range(N+1):
  if(N%3 !> 0 !< N%5):
    M += i
print(M)
        

### FIXED CODE ###

N = int(input())
Q = 0
for i in range(1,N+1):
  if(i%3 != 0 and i%5 != 0):
      Q += i
print(Q)
S = input()

count_list = []
for i in S:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        count_list.append(True)
    else:
        count_list.append(False)

l = len(S)
freq_list = []
for i in range(l):
    count = 0
    for j in range(l-i):
        if count_list[i+j] is True:
            count += 1
        else:
            freq_list.append(count)
            break

print(max(freq_list))




### FIXED CODE ###

S = input()

count_list = []
for i in S:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        count_list.append(True)
    else:
        count_list.append(False)

l = len(S)
freq_list = []
for i in range(l):
    count = 0
    for j in range(l-i):
        if count_list[i+j] is True:
            count += 1
            freq_list.append(count)
        else:
            freq_list.append(count)
            break

print(max(freq_list))
n,q = map(int,input().split())
s = list(input())
o = [1 for  i in range(n)]
t = []
r = []
for i in range(q):
    a,b = map(str,input().split())
    if a not in t:
        t.append(a)
        r.append([i for i, x in enumerate(s) if x == a])
    index1 = t.index(a)
    if b == "L":
        for i in range(len(r[index1])):
            if r[index1][i] == 0:
                n = n - o[0]
                o[0] = 0
            else:
                o[r[index1][i]-1] += o[r[index1][i]]
                o[r[index1][i]] = 0
    else:
        for i in range(len(r[index1])):
            if r[index1][i] == len(s)-1:
                n = n - o[-1]
                o[-1] = 0
            else:
                o[r[index1][i]+1] += o[r[index1][i]]
                o[r[index1][i]] = 0

print(n)

### FIXED CODE ###

a,b,c=map(int,input().split())
if a == b and b == c:
    print("Yes")
else:
    print("No")
while True:
    S = input()
    N = len(S)
    MOD = 1000000007
    dp = [[0]*4 for i in range(N+1)]
    for i in range(N, -1, -1):
        for j in range(3, -1, -1):
            if i == N:
                dp[i][j] = 1 if j == 3 else 0
            else:
                dp[i][j] = dp[i+1][j] * (3 if S[i] == '?' else 1)
                if j < 3 and (S[i] == '?' or S[i] == "ABC"[j]):
                    dp[i][j] += dp[i+1][j+1]
                dp[i][j] %= MOD
    print(dp[0][0])


### FIXED CODE ###

S = input()
N = len(S)
MOD = 1000000007
dp = [[0]*4 for i in range(N+1)]
for i in range(N, -1, -1):
    for j in range(3, -1, -1):
        if i == N:
            dp[i][j] = 1 if j == 3 else 0
        else:
            dp[i][j] = dp[i+1][j] * (3 if S[i] == '?' else 1)
            if j < 3 and (S[i] == '?' or S[i] == "ABC"[j]):
                dp[i][j] += dp[i+1][j+1]
            dp[i][j] %= MOD
print(dp[0][0])
n = int(input())
li = list(map(int, input().split()))
li = sorted(li)
count = 1
if  not (1 in li and 0 in li) :
    count = 0
else:
    for i in range(2,max(li) + 1):
        a = li.count(i-1)
        b = li.count(i)
        count *= a ** b
print(count % 998244353)A

### FIXED CODE ###

n = int(input())
li = list(map(int, input().split()))
box = [0 for x in range(max(li)+1)]
for i in li:
    box[i] += 1
count = 1

if len(box) > 2:
    for i in range(1, len(box)-1):
        count *= box[i] ** box[i+1]
        count %= 998244353
else:
    count = 1
    
if box[0] != 1 or li[0] != 0:
    count = 0

print(count % 998244353)
x = int(input())
key = [True] + [False]*99 + [True]*6 + [0]*(x+1)
def dp(x):
    if x <= 105:
        return key[x]
    if key[x] == 0:
        key[x] = any([dp(x-100), dp(x-101), dp(x-102), dp(x-103), dp(x-104), dp(x-105)])
    return key[x]
if dp(x):
    print(1)
else:
    print(0)

### FIXED CODE ###

import sys
x = int(input())
for i in range(1000):
    if 100*i <= x <= 105*i:
        print(1)
        sys.exit()
print(0)
H,W,A,B=map(int,input().split())
if A*H == B*W:
    str = '1'*A + '0'*(W-A)
    for i in range(H):
        print(str)
        str = str[W-A:]+str[:-A]
elif A == 0 and B == 0:
    for i in range(H)
        print('1'*W)
elif A == 0:
    for i in range(H):
        print('1'*W if i < B else '0'*W)
elif B == 0:
    for i in range(H):
        print('1'*A+'0'*(W-A))
else:
    print('No')

### FIXED CODE ###

H,W,A,B=map(int,input().split())
for i in range(H):
    print('1'*A+'0'*(W-A) if i < B else '0'*A+'1'*(W-A))
a = input()
b = input()
c = input()

count = 3

if a == b:
    count -= 1
if b == c:
    count -= 1
if a == c:
    count -= 1

print(count)

### FIXED CODE ###

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

if a == b and a == c:
    print(1)
elif a == b or a == c or b == c:
    print(2)
else:
    print(3)
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b, c = map(int, input().split())
# 文字列の入力
s = input()
# 出力
# print("{} {}".format(a+b+c, s))
print(f'{a+b+c} {s}')

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
# a = int(input())
# スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
# s = input()
# 出力
# print("{} {}".format(a+b+c, s))
# print(f'{a+b+c} {s}')
a,b,c = map(int, input().split())
a,b = b,a
a,c = c,a
print("{} {} {}".format(a,b,c))
W, a, b = map(int, input().split())

if a+W = b:
  tmp = b-a-W
  if tmp <= 0:
    print(0)
  else:
    print(tmp)
elif a > b+W:
  tmp = a-W-b
  if tmp <= 0:
    print(0)
  else:
    print(tmp)
else:
  print(0)




### FIXED CODE ###

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

if a+W < b:
  tmp = b-a-W
  if tmp <= 0:
    print(0)
  else:
    print(tmp)
elif a > b+W:
  tmp = a-W-b
  if tmp <= 0:
    print(0)
  else:
    print(tmp)
else:
  print(0)
input()
print " ".join(sorted(map(int,raw_input().split())))

### FIXED CODE ###

input()
print " ".join(map(str,sorted(map(int,raw_input().split()))))
N = int(input())
xy = []
for i in range(N):
    a, b = (int(x) for x in input().split())
    xy.append([a, b])
    
def distance(d, xy, i, j):
    return (
              (xy[i][0] - xy[j][0]) ** 2
            + (xy[i][1] - xy[j][1]) ** 2
        ) ** 0.5
 
import itertools
d = []
l1 = [x for x in range(N)]
for v in itertools.permutations(l1, N):
    l2 = list(v)
    d0 = []
    for c in range(N-1):
        i = l2[c]
        j = l2[c+1]
        d0.append(distance(d, xy, i, j))
    d.append(sum(d0))
 
print(sum(d) / len(d))

### FIXED CODE ###

r = int(input())
print(r * r)
def BIT_query(BIT,idx):
    res_sum = 0
    if idx == 0:
        return 0
    while idx > 0:
        res_sum += BIT[idx]
        idx -= idx&(-idx)
    return res_sum

#Ai += x O(logN)
def BIT_update(BIT,idx,x,n):
    while idx <= n:
        BIT[idx] += x
        idx += idx&(-idx)
    return

def main():
    N, Q = map( int, input().split())
    C = list( map( int, input().split()))
    for i in range(Q):
        l, r = map( int, input().split())
        LRI.append((r,l, i))
    LRI.sort(key=lambda x:x[0])
    lastAppend = [-1]*(N+1)
    BIT = [0]*(N+1)
    ANS = [0]*Q
    now = 1
    for r, l, i in LRI:
        while now <= r:
            c = C[now-1]
            if lastAppend[c] == -1:
                BIT_update(BIT, now, 1,N)
            else:
                BIT_update(BIT, now, 1,N)
                BIT_update(BIT, lastAppend[c],-1,N)
            lastAppend[c] = now                
            now += 1
        ANS[i] = BIT_query(BIT,r) - BIT_query(BIT,l-1)
    print( "\n".join( map( str, ANS)))
    
if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N, Q = map( int, input().split())
    C = list( map( int, input().split()))
    LRI = []
    for i in range(Q):
        l, r = map( int, input().split())
        LRI.append((r,l,i))
    LRI.sort(key=lambda x:x[0])
    lastAppend = [-1]*(N+1)
    BIT = [0]*(N+1)
    #A1 ~ Aiまでの和 O(logN)
    def BIT_query(idx):
        res_sum = 0
        if idx == 0:
            return 0
        while idx > 0:
            res_sum += BIT[idx]
            idx -= idx&(-idx)
        return res_sum

    #Ai += x O(logN)
    def BIT_update(idx,x):
        while idx <= N:
            BIT[idx] += x
            idx += idx&(-idx)
        return

    ANS = [0]*Q
    now = 1
    for r, l, i in LRI:
        while now <= r:
            c = C[now-1]
            if lastAppend[c] == -1:
                BIT_update(now, 1)
            else:
                BIT_update( now, 1)
                BIT_update(lastAppend[c],-1)
            lastAppend[c] = now                
            now += 1
        ANS[i] = BIT_query(r) - BIT_query(l-1)
    print( "\n".join( map( str, ANS)))
    
    

if __name__ == '__main__':
    main()
while True:
    N, Q = map(int, raw_input().split())

    if N == 0 and Q == 0:
        break

    t = [map(int, raw_input().split())[1:] for _ in range(N)]
    table = [[i, 0] for i in range(10)]

    for i in t:
        for j in i:
            table[j][1] += 1

    table.sort(reverse=True, key=lambda x: x[1])

    print table[0][0] if table[0][1] >= Q else 0



### FIXED CODE ###

while True:
    N, Q = map(int, raw_input().split())

    if N == 0 and Q == 0:
        break

    t = [map(int, raw_input().split())[1:] for _ in range(N)]
    table = [[i, 0] for i in range(101)]

    for i in t:
        for j in i:
            table[j][1] += 1

    table.sort(reverse=True, key=lambda x: x[1])

    print table[0][0] if table[0][1] >= Q else 0
import sys
import collections
S = input()
count_dict = collections.Counter(S)
Num_A = count_dict["a"]
Num_B = count_dict["b"]
Num_C = count_dict["c"]

judge = sorted([a, b, c])
if judge[2]-judge[0]>1:
    print('NO')
else:
    print('YES')

### FIXED CODE ###

import sys
import collections
S = input()
count_dict = collections.Counter(S)
Num_A = count_dict["a"]
Num_B = count_dict["b"]
Num_C = count_dict["c"]

judge = sorted([Num_A, Num_B, Num_C])
if judge[2]-judge[0]>1:
    print('NO')
else:
    print('YES')
n,k=map(int,input().split())
a=list(map(int,input().split()))
i=0
s=set()
s.add(1)
order=[1]
while 1:
    if a[i] in s:
        order.append(a[i])
        break
    else:
        order.append(a[i])
        s.add(a[i])
    i=a[i]-1
for i in range(len(order)):
    if order[-1]==order[i]:
        idx=i
        break
#print(order)
if idx==0:
    cnt=len(order)-(idx+1)
else:
    cnt=len(order)-idx
if len(order)>k:
    print(order[k])
else:
    order=order[idx+1:]
    #print(order)
    k%=cnt
    if k>=1:
        k-=1
    else:
        k=cnt-1
    #print(k)
    print(order[k])
#print(order)


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
i=0
s=set()
s.add(1)
order=[1]
while 1:
    if a[i] in s:
        order.append(a[i])
        break
    else:
        order.append(a[i])
        s.add(a[i])
    i=a[i]-1
for i in range(len(order)):
    if order[-1]==order[i]:
        idx=i
        break
#print(order)
cnt=len(order)-(idx+1)
if len(order)>k:
    print(order[k])
else:
    k-=len(order)
    order=order[idx+1:]
    #print(cnt)
    #print(order)
    k%=cnt
    #print(k)
    print(order[k])
#print(order)
a,b = list(map(int, input().split()))
if a == "H" and b == "H":
    print("H")
elif a == "D" and b == "D":
    print("H")
else:
    print("D")

### FIXED CODE ###

a,b = list(input().split())
if a == "H" and b == "H":
    print("H")
elif a == "D" and b == "D":
    print("H")
else:
    print("D")
N, K, Q = [int(s) for s in input().split()]
A = [0] * N
for i in range(N):
    A[int(input()) - 1] += 1

for a in A:
    print('Yes' if (K - Q + a) > 0 else 'No')

### FIXED CODE ###

N, K, Q = [int(s) for s in input().split()]
A = [0] * N
for i in range(Q):
    A[int(input()) - 1] += 1

for a in A:
    print('Yes' if (K - Q + a) > 0 else 'No')
n = int(input())
debt = 100000

for i in range(n):
	debt = debt * 1.05
	round = debt % 1000
	if round != 0:
		debt = (debt // 1000 + 1) * 1000
print(int(debt)

### FIXED CODE ###

n = int(input())
debt = 100000

for i in range(n):
	debt = debt * 1.05
	round = debt % 1000
	if round != 0:
		debt = (debt // 1000 + 1) * 1000

print(int(debt))
A, B = map(int, input().split())

import fractions

print(int(A * B / fractions.gcd(A, B)))


### FIXED CODE ###

A = int(input())
B = int(input())

r = list(filter(lambda x: x != A and x != B, [1, 2, 3]))
print(r[0])
in1 = input()
in2 = input()

#b, c = map(int, input().split())
#s = input()
#print("{} {}".format(a+b+c, s))

N,K = in1.split()

h_list = in2.split()

#print(N,K)


num=0
for h in h_list:
        if h >= K:
                num+=1

print(num)

### FIXED CODE ###

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


#h_list = in2.split()

h_list = list(map(int, input().split()))

num=0
for h in h_list:
        if h >= K:
                num+=1

print(num)
r=float(input())
p=3.141592653589
print(f'{p*r*r} {2*p*r}')

### FIXED CODE ###

r=float(input())
p=3.141592653589
print(p*r*r,2*p*r)
n,k,q = map(int,input().split())
A=[int(input()) for i in range(n)]

P=[k-q for i in rage(n)]

for i in range(q):
      P[A[i]-1] +=1

for i in range(n):
      if P[i]>0:
            print("Yes")
      else:
            print("No")
      

### FIXED CODE ###

lis_NKQ = list(map(int, input().split()))

lis_A = []
lis_K = [lis_NKQ[1] for i in range(lis_NKQ[0])]
lis_K = list(map(lambda x: x - lis_NKQ[2],lis_K))

for i in range(lis_NKQ[2]):
    inp = int(input())
    lis_A.append(inp)
    lis_K[inp - 1] += 1  

for i in lis_K:
    if i > 0:
        print("Yes")
    else:
        print("No")
N, K = map(int, input().split())
answer = [0] * K
mod = 10**9+7
for i in range(1,K+1):
    M = N-K
    if M - (i-1) < 0:
        answer[i-1] = 0
    else:
        tmp = 1
        for j in range(i-1):
            tmp *= K-1-j
        for j in range(i-1):
            tmp /= j+1
        tmp %= mod
        for j in range(i):
            tmp *= M+1-j
        for j in range(i):
            tmp /= j+1
        tmp %= mod
        answer[i-1] = int(tmp)
print(*answer, sep="\n")

### FIXED CODE ###

N, K = map(int, input().split())
answer = [0] * K
mod = 10**9+7
C_2000 = [0]*2001
C_2000[0] = 1
for i in range(1,2001):
    C_2000[i] = (C_2000[i-1] * i)%mod
def pow_r(x, n):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return (pow_r((x ** 2)%mod, n // 2))%mod
    else:  # standard case ② n is odd
        return (x * pow_r((x ** 2)%mod, (n - 1) // 2))%mod

for i in range(1,K+1):
    M = N-K
    if M - (i-1) < 0:
        answer[i-1] = 0
    else:
        tmp = (C_2000[K-1] * pow_r(C_2000[i-1],mod-2)*pow_r(C_2000[K-i],mod-2))%mod
        tmp = (tmp*C_2000[M+1] * pow_r(C_2000[i],mod-2) * pow_r(C_2000[M+1-i],mod-2))%mod
        answer[i-1] = int(tmp)
print(*answer, sep="\n")
import math

x1, y1, x2, y2 = [int(s) for s in input().split()]
print(math.sqrt((math.fabs(x1 - x2) ** 2) + (math.fabs(y1 - y2) ** 2)))

### FIXED CODE ###

import math

x1, y1, x2, y2 = [float(s) for s in input().split()]
print(math.sqrt((math.fabs(x1 - x2) ** 2) + (math.fabs(y1 - y2) ** 2)))
from collections import deque
n = int(input())
dList = deque()

for _ in range(n):
  op = list(map(str,input().split()))
  if(op[0] == "insert"):
    dList.appendleft(op[1])
  elif(op[0] == "delete"):
    try:
        dList.remove(op[1])
    except:
        pass
  elif(op[0] == "deleteFirst"):
    dList.popleft()
  elif(op[0] == "deleteLast") :
    dList.pop()

print(*dList[1])



### FIXED CODE ###


import collections,sys
def s():
  d = collections.deque()
  input()
  for e in sys.stdin:
    if "i"==e[0]: d.appendleft(e[7:-1])
    else:
      if " "==e[6]:
        m = e[7:0-1]
        if m in d: d.remove(m)
      elif "i"==e[7]: d.popleft()
      else: d.pop()
  print(*d)

s()
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np
import math
from collections import deque
from collections import defaultdict
from math import gcd




def main():
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    P = np.array(P)
    
    P = np.sort(P)
    ind = bisect.bisect_right(P, X)

    if len(P) == 0 or P[ind-1] != X:
        return X
    
    Left = P[:ind-1] - X
    Right = P[ind:] - X

    Left = abs(Left[::-1])
    diff = 1
    Left_over = False
    Right_over = False
    while True:
        if not Left_over and Left[0] != diff:
            return X - diff
        elif not Right_over and Right[0] != diff:
            return X + diff
        diff += 1
        if len(Left) >= 2:
            Left = Left[1:]
        else:
            Left_over = True
        if len(Right) >= 2:
            Right = Right[1:]
        else:
            Right_over = True

        if Left_over and Right_over:
            return P[0]-1


print(main())

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np
import math
from collections import deque
from collections import defaultdict
from math import gcd


def main():
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    P = np.array(P)
    
    P = np.sort(P)
    ind = bisect.bisect_right(P, X)

    if len(P) == 0 or P[ind-1] != X:
        return X
    
    if len(P) == 1:
        if P[0] != X:
            return X
        else:
            return X-1
    
    Left = P[:ind-1] - X
    Right = P[ind:] - X

    Left = abs(Left[::-1])

    diff = 1
    Left_over = False
    Right_over = False

    if len(Left) == 0:
        Left_over = True
    if len(Right) == 0:
        Right_over = True

    while True:
        if not Left_over and Left[0] != diff:
            return X - diff
        elif Left_over:
            return P[0] - 1
        elif not Right_over and Right[0] != diff:
            return X + diff
        elif Right_over:
            return P[-1] + 1
        diff += 1
        if len(Left) >= 2:
            Left = Left[1:]
        else:
            Left_over = True
        if len(Right) >= 2:
            Right = Right[1:]
        else:
            Right_over = True

        if Left_over and Right_over:
            return P[0]-1


print(main())
import math
input_a= input().split(" ")
X=int(input_a[0])
N=int(input_a[1])
dis=X+3
if N!=0:
  array= input().split(" ")
else:
  array=[0,0]

num=X
num2=-100
for i in range(101-X):

  
  if str(num) not in array:
    dis=abs(X-num)
    num2=X-dis
    num1=num
    if str(num2) not in array:
    	numa=min([num,num2])
    else:
      numa=num1
    break
  num=num+1
    

num=X
i=0
for i in range(dis):
  
  if str(num) not in array:
    
    dis2=abs(X-num)
    num3=X+dis2
    #print(num,dis2,num3)
    if str(num3) not in array:
    	numb=min([num,num3])
    else:
      numb=num
      break
  num=num-1
#print(numa,numb,dis,dis2)
if dis<dis2:
  print(numa)
elif dis==dis2:
  print(numb)
else:
  print(numb)

### FIXED CODE ###

import math
input_a= input().split(" ")
X=int(input_a[0])
N=int(input_a[1])
dis=X+3
dis2=100
if N!=0:
  array= input().split(" ")
else:
  array=[0,0]

num=X
num2=-100
for i in range(N+1):

  
  if str(num) not in array:
    dis=abs(X-num)
    num2=X-dis
    num1=num
    if str(num2) not in array:
    	numa=min([num,num2])
    else:
      numa=num1
    break
  num=num+1
    

num=X
i=0
for i in range(dis):
  
  if str(num) not in array:
    
    dis2=abs(X-num)
    num3=X+dis2

    if str(num3) not in array:
    	numb=min([num,num3])
    else:
      numb=num
      break
  num=num-1

if dis<dis2:
  print(numa)
elif dis==dis2:
  print(numb)
else:
  print(numb)
_,s,*a=map(int,open(0).read().split())
c,i,*d=[0]*s*3
for a in a:
 for j in range(s,0,-1):d[a+j]+=d[j]
 d[a]-=~i;c+=d[s];i+=1
print(c%(998244353))

### FIXED CODE ###

n,s,*a=map(int,open(0).read().split())
d=[0]*3001
c=0
for i,a in enumerate(a):
    for j in range(s-a,0,-1):d[a+j]+=d[j]
    d[a]-=~i
    c+=d[s]
print(c%(998244353))