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

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

sum_s =[0]*n
sum_s[0]=a[0]
for i in range(1,n):
  sum_s[i] = (a[i]+ sum_s [i-1])%m

#print(sum_s)

count = 0
for i in range(n):
  if sum_s[i]%m == 0:
    count += 1
  for j in range(0,i):
    if (sum_s[i]-sum_s[j])%m == 0 :
      count +=1
    
print(count)

### FIXED CODE ###

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

sum_s =[0]*n
sum_s[0]=(a[0])%m
for i in range(1,n):
  sum_s[i] = (a[i]+ sum_s [i-1])%m

#print(sum_s)
dict = {}
for i in range(n):
  if sum_s[i] not in dict:
    dict[sum_s[i]] = 1
  else:
    dict[sum_s[i]] += 1

#print(sum_s)

def combination(n,r):
    r = min(r,n-r)
    result = 1
    for i in range(n-r+1,n+1):
        result *= i
    for i in range(1,r+1):
        result //= i
    return result

ans=0
for i in dict:
  if i == 0:
    if dict[i]>=2:
      ans +=combination(dict[i],2)
    ans +=dict[i] 
  else:
    if dict[i]>=2:
      ans += combination(dict[i],2)
      #print(i,dict[i],combination(dict[i],2))
print(ans)
### BUGGY CODE ###

from collections import deque as dq
N, M = map(int, input().split())
ab = []
c = []
inf = 10 ** 10
for i in range(M):
  ab.append(list(map(int, input().split())))
  c.append(list(map(int, input().split())))
dp = [[inf] * M for _ in range(2 ** 12)]
#print(ab, c)
Q = dq([])
Q.append((0, 0))
vis = set()
while len(Q):
  q = Q.popleft()
  i, j = q[0], q[1]
  if j >= M:
    continue
  if q in vis:
    continue
  vis.add(q)
  temp = i ^ 0
  temp2 = 0
  for k in range(ab[j][1]):
    t = 2 ** (c[j][k] - 1)
    temp2 = temp2 | t
  if j > 0:
    #print(temp | temp2, j, ab[j][0])
    dp[temp | temp2][j] = min(dp[temp][j - 1] + ab[j][0], dp[temp | temp2][j])
    dp[temp][j] = min(dp[temp][j], dp[temp][j - 1])
    dp[temp2][j] = min(ab[j][0], dp[temp2][j])
    Q.append((temp | temp2, j + 1))
    Q.append((temp, j + 1))
    Q.append((temp2, j + 1))
  else:
    #print(temp | temp2, j, ab[j][0])
    dp[temp | temp2][j] = min(ab[j][0], dp[temp | temp2][j])
    Q.append((temp | temp2, j + 1))
if dp[2 ** N - 1][-1] == inf:
  print(-1)
else:
  print(dp[2 ** N - 1][-1])



### FIXED CODE ###

from collections import deque as dq
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
ab = []
c = []
inf = 2 << 31
for i in range(M):
  ab.append(list(map(int, input().split())))
  c.append(list(map(int, input().split())))
dp = [[inf] * M for _ in range(2 ** 12)]
cc = []
for i in range(M):
  temp = 0
  for k in range(ab[i][1]):
    t = 2 ** (c[i][k] - 1)
    temp = temp | t
  cc.append(temp)
def less(a, b):
  if a > b:
    return b
  else:
    return a
#print(ab, c)
Q = dq([])
Q.append((0, 0))
vis = [[0] * M for _ in range(2 ** 12)]
while len(Q):
  q = Q.popleft()
  i, j = q[0], q[1]
  if j >= M:
    continue
  if vis[i][j] == 1:
    continue
  vis[i][j] = 1
  temp = i ^ 0
  temp2 = cc[j]
  if j > 0:
    #print(temp | temp2, j, ab[j][0])
    dp[temp | temp2][j] = less(dp[temp][j - 1] + ab[j][0], dp[temp | temp2][j])
    dp[temp][j] = less(dp[temp][j], dp[temp][j - 1])
    dp[temp2][j] = less(ab[j][0], dp[temp2][j])
    Q.append((temp | temp2, j + 1))
    Q.append((temp, j + 1))
    Q.append((temp2, j + 1))
  else:
    #print(temp | temp2, j, ab[j][0])
    dp[temp | temp2][j] = less(ab[j][0], dp[temp | temp2][j])
    Q.append((temp | temp2, j + 1))
if dp[2 ** N - 1][-1] == inf:
  print(-1)
else:
  print(dp[2 ** N - 1][-1])
### BUGGY CODE ###

import bisect
a,b,q=map(int,input().split())
s=sorted([int(input()) for i in range(a)])
t=sorted([int(input()) for i in range(b)])
for i in range(q):
    ans=999999999999
    x=int(input())
    w=bisect.bisect_left(s,x)
    for j in range(2):
        if not 0<=w-j<len(s):
            continue
        z=bisect.bisect_left(t,s[w-j])
        for k in range(2):
            if not 0<=z-k<len(t):
                continue
            ans=min(ans,abs(x-s[w-j])+abs(s[w-j]-t[z-k]))
    w=bisect.bisect_left(t,x)
    for j in range(2):
        if not 0<=w-j<len(t):
            continue
        z=bisect.bisect_left(s,t[w-j])
        for k in range(2):
            if not 0<=z-k<len(s):
                continue
            ans=min(ans,abs(x-t[w-j])+abs(t[w-j]-s[z-k]))
    print(ans)

### FIXED CODE ###

import sys
import bisect
a,b,q=map(int,input().split())
s=sorted([int(input()) for i in range(a)])
t=sorted([int(input()) for i in range(b)])
i=0
for line in sys.stdin:
    ans=999999999999
    x=int(line)
    w=bisect.bisect_left(s,x)
    for j in range(2):
        if not 0<=w-j<len(s):
            continue
        z=bisect.bisect_left(t,s[w-j])
        for k in range(2):
            if not 0<=z-k<len(t):
                continue
            tmp=abs(x-s[w-j])+abs(s[w-j]-t[z-k])
            if ans>tmp:
                ans=tmp
    w=bisect.bisect_left(t,x)
    for j in range(2):
        if not 0<=w-j<len(t):
            continue
        z=bisect.bisect_left(s,t[w-j])
        for k in range(2):
            if not 0<=z-k<len(s):
                continue
            tmp=abs(x-t[w-j])+abs(t[w-j]-s[z-k])
            if ans>tmp:
                ans=tmp
    print(ans)
    i+=1
### BUGGY CODE ###

k,s=[int(i) for i in input().split()]

count=0
for i in range(k+1):
    for j in range(k+1):
        for r in range(k+1):
            if i+j+r==s:
                count+=1
                
print(count)


### FIXED CODE ###

k,s=[int(i) for i in input().split()]

count=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-(x+y)<=k:
            count+=1
               
                
print(count)
### BUGGY CODE ###

import operator
from functools import reduce

count = int(input())
list = list(map(int, input().split()))
sum = reduce(operator.mul, list, 1)

if sum > 1000000000000000000:
    sum = -1

print(sum)

### FIXED CODE ###

from functools import reduce
from operator import mul
import sys
input = sys.stdin.readline

count = int(input())
list = list(map(int, input().split()))
sum = list[0]
if 0 in list:
    print(0)
    exit()
else:
    for i in range(count - 1):
        sum = sum * list[i + 1]
        if sum > 1000000000000000000:
            print(-1)
            exit()


    print(sum)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

N, W = map(int, input().split())
weight = [0]*N
value = [0]*N
dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
  weight[i], value[i] = map(int, input().split())
  
for i in range(N):
  for sum_w in range(W+1):
    if sum_w - weight[i] >= 0:
      dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-weight[i]]+value[i])
    dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[-1][-1]) 


### FIXED CODE ###

import sys
input = sys.stdin.readline

weight = [0]*110
value = [0]*110
dp = [[0]*100010 for i in range(110)]

N, W = map(int, input().split())
for i in range(N):
  weight[i], value[i] = map(int, input().split())

# dp roop
for i in range(N):
  sum_w = 0
  while sum_w <= W:
    if sum_w >= weight[i]:
      dp[i+1][sum_w] = max(dp[i][sum_w - weight[i]] + value[i], dp[i][sum_w])
    else:
      dp[i+1][sum_w] = dp[i][sum_w]
    sum_w += 1
print(dp[N][W])
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline
from itertools import permutations

def main():
    N,C = map(int,input().split())
    D = [list(map(int,input().split())) for _ in range(C)]
    col = [list(map(int,input().split())) for _ in range(N)]
    
    mod_color = [[],[],[]]
    for i in range(N):
        for j in range(N):
            mod_color[(i+j)%3].append(col[i][j]-1)

    ans = 10**10
    for x,y,z in permutations(range(C),3):
        ret = 0
        for num in mod_color[0]:
            ret += D[num][x]
        for num in mod_color[1]:
            ret += D[num][y]
        for num in mod_color[2]:
            ret += D[num][z]
        ans = min(ans,ret)
        
    print(ans)
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N,C = map(int,input().split())
    D = [list(map(int,input().split())) for _ in range(C)]
    c = [list(map(int,input().split())) for _ in range(N)]
    mod_0 = [0 for _ in range(C)]
    mod_1 = [0 for _ in range(C)]
    mod_2 = [0 for _ in range(C)]
    for i in range(N):
        for j in range(N):
            if (i+j)%3 == 0:
                mod_2[c[i][j]-1] += 1
            if (i+j)%3 == 1:
                mod_0[c[i][j]-1] += 1
            if (i+j)%3 == 2:
                mod_1[c[i][j]-1] += 1
    INF = 10**10
    ans = INF
    for i in range(C):
        for j in range(C):
            if i == j:
                continue
            for k in range(C):
                if i == k or j == k:
                    continue
                ans = min(ans,sum(mod_0[n]*D[n][i] for n in range(C))+\
                              sum(mod_1[n]*D[n][j] for n in range(C))+\
                              sum(mod_2[n]*D[n][k] for n in range(C)))
    print(ans)

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

import sys
input = lambda: sys.stdin.readline().rstrip('\r\n')

from collections import defaultdict

N = int(input())

S = 'RULD'

class Plane:
	__slots__ = ('x', 'y', 'd')

	def __init__(s, x, y, d):
		s.x, s.y, s.d = int(x), int(y), d

	def __lt__(s, o):
		return s.x < o.x

	def rotate(s):
		s.x, s.y = -s.y, s.x
		s.d = S[(S.index(s.d)+1)%4]


P = [Plane(*input().split()) for _ in range(N)]

INF = 10 ** 18
best = INF
MAXC = 400000

for trial in range(4):
	P.sort()

	rdu, rdd, ry = ([INF] * (2*MAXC+1) for _ in range(3))

	for p in P:
		if p.d == 'R':
			ry[p.y+MAXC] = p.x
			rdu[p.y-p.x+MAXC] = p.x
			rdd[p.y+p.x+MAXC] = p.x
		elif p.d == 'L':
			ty = p.y + MAXC
			if ry[ty] != INF:
				best = min(best, (p.x - ry[ty]) * 5)
		elif p.d == 'U':
			ty = p.x + p.y + MAXC
			if rdd[ty] != INF:
				best = min(best, (p.x - rdd[ty]) * 10)
		elif p.d == 'D':
			ty = p.y - p.x + MAXC
			if rdu[ty] != INF:
				best = min(best, (p.x - rdu[ty]) * 10)

	if trial != 3:
		for p in P: p.rotate()

print('SAFE' if best == INF else best)


### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip('\r\n')

from collections import defaultdict

N = int(input())

S = 'RULD'

class Plane:
	__slots__ = ('x', 'y', 'd')

	def __init__(s, x, y, d):
		s.x, s.y, s.d = int(x), int(y), d

	def __lt__(s, o):
		return s.x < o.x

	def rotate(s):
		s.x, s.y = -s.y, s.x
		s.d = S[(S.index(s.d)+1)%4]

P = []
for _ in range(N):
	x, y, d = input().split()
	P.append((int(x), int(y), d))

def rotate(s):
	return (-s[1], s[0], S[(S.index(s[2])+1)%4])

INF = 10 ** 18
best = INF
MAXC = 400000

for trial in range(4):
	P.sort(key=lambda v: v[0])

	rdu, rdd, ry = ([INF] * (2*MAXC+1) for _ in range(3))

	for (x, y, d) in P:
		if d == 'R':
			ry[y+MAXC] = x
			rdu[y-x+MAXC] = x
			rdd[y+x+MAXC] = x
		elif d == 'L':
			ty = y + MAXC
			if ry[ty] != INF:
				best = min(best, (x - ry[ty]) * 5)
		elif d == 'U':
			ty = x + y + MAXC
			if rdd[ty] != INF:
				best = min(best, (x - rdd[ty]) * 10)
		elif d == 'D':
			ty = y - x + MAXC
			if rdu[ty] != INF:
				best = min(best, (x - rdu[ty]) * 10)

	if trial != 3:
		P = [rotate(p) for p in P]

print('SAFE' if best == INF else best)
### BUGGY CODE ###

import collections

N = int(input())
s = [collections.Counter(list(input())) for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        if s[i] == s[j]:
            ans += 1
print(ans)


### FIXED CODE ###

N = int(input())
ans = 0
S = {}
for i in range(N):
    s = ''.join(sorted(input()))
    if s not in S.keys():
        S[s] = 0
        continue
    S[s] += 1
    ans += S[s]
print(ans)
### BUGGY CODE ###

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

ans=0
j=2
l=1

if k%2==1:
    ans=int(n/k)**3

if k%2==0:
    for i in range(1,n+1):
        a=k-i
        while a<1:
            a+=k
        c=a
        while a<=n:
            b=c
            while a+b<k:
                b+=k
            if (a+b)%k==0:
                while b<=n:
                    ans+=1
                    b+=k
            a+=k    
    
                
print(ans)

### FIXED CODE ###

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

ans=0

if k%2==1:
    ans=int(n/k)**3
else:
    ans=int(n/k+0.5)**3+(n//k)**3
    
print(ans)
### BUGGY CODE ###

#いろはコンテスト day2
import functools
import sys
from heapq import*

input=sys.stdin.readline

@functools.lru_cache(maxsize=None)
class UNION_FIND(object):
    def __init__(self,n):
        self.parent=[-1 for i in range(n)]
        
    def root(self,x):
        if self.parent[x]<0:
            return x
        else:
            self.parent[x]=self.root(self.parent[x])
            return self.parent[x]
 
    def size(self,x):
        return -self.parent[self.root(x)]
    def union(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x==y:
            return False
        if self.size(x)<self.size(y):
            x,y=y,x
        self.parent[x]+=self.parent[y]
        self.parent[y]=x
        return True
def compute_mst_kruskal(max_v, edges, flip):
    edges.sort(key=lambda x: x[2],reverse=flip)
    uf = UNION_FIND(max_v)
    mst = []
    for (a,b,c) in edges:
        if uf.root(a)!= uf.root(b):
            uf.union(a,b)
            mst.append((c))
    return mst
 
max_v, a,b=map(int,input().split()) 
*x,=map(int,input().split())

edges = []
for i in range(max_v):
    for j in range(max_v):
        heappush(edges,(i,j,min(abs(a*(x[i]-x[j])),b)))
mst = compute_mst_kruskal(max_v, edges , 0) #0が最小化
print(sum(mst))

### FIXED CODE ###

n,a,b=map(int,input().split())
*x,=map(int,input().split())
print(sum(min(abs(a*(x[i-1]-x[i])),b)for i in range(1,n)))
### BUGGY CODE ###

k,s = [int(n) for n in input().split()]
ac = 0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z == s:
        ac += 1
print(str(ac))

### FIXED CODE ###

k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z<=k:
            ans+=1
print(ans)
### BUGGY CODE ###

from bisect import bisect_left,bisect_right
import string 
dic = {c:[] for c in string.ascii_lowercase}

n = int(input())
s = list(input())
q = int(input())

for i,c in enumerate(s,start=1):
  dic[c].append(i)
  
for i in range(q):
  p,l,r = map(str,input().split())
  if p =='1':
    j = int(l)
    c = s[j-1]
    dic[c].pop(bisect_left(dic[c],j))
    dic[r].insert(bisect_left(dic[r],j),j)
    s[j-1] = r
  else:
    ans = 0
    for c in dic.keys():
      if bisect_left(dic[c],int(l)) != bisect_right(dic[c],int(r)):
        ans += 1
    print(ans)

### FIXED CODE ###

from bisect import bisect_left,bisect_right
import string 

dic = {c:[] for c in string.ascii_lowercase}

n = int(input())
s = list(input())
q = int(input())

for i,c in enumerate(s,start=1):
  dic[c].append(i)
  
for i in range(q):
  p,l,r = map(str,input().split())
  if p =='1':
    j = int(l)
    if r == s[j-1]:
      continue
    c = s[j-1]    
    dic[c].pop(bisect_left(dic[c],j))
    dic[r].insert(bisect_left(dic[r],j),j)
    s[j-1] = r
  else:
    ans = 0
    l = int(l)
    r = int(r)
    for c in string.ascii_lowercase:
      pl = bisect_left(dic[c],l)
      if pl < len(dic[c]):
        if dic[c][pl] <= r:
          ans += 1
    print(ans)
### BUGGY CODE ###

import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N, K = MI()
    D = [0] * N
    L = [LI() for i in range(K)]
    D[0] = 1
    for index, num in enumerate(D):
        for l, r in L:
            if index + r + 1 <= N:
                D[index+l:index+r+1] = [_+num for _ in D[index+l:index+r+1]]
            elif index+l <= N-1:
                D[index+l:N] = [_+num for _ in D[index+l:N]]
    print(D[N-1] % 998244353)
                
    
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    

def main():
    N, K = MI()
    L = [LI() for i in range(K)]
    D = [0] * N
    D[0] = 1
    D[1] = -1
    num = 0
    mod = 998244353
    for index in range(N):
        num += D[index] % mod
        for l, r in L:
            if index + r + 1 <= N-1:
                D[index+l] += num
                D[index+r+1] -= num
            elif index+l <= N-1:
                D[index+l] += num
                
    print(num % mod)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())
A = [int(a)-i-1 for i,a in enumerate(input().split(),1)]
A.sort()
b = sum(A)//len(A)
d = sum(A)%len(A)
c = 10**9
for j in range(b-d, b+d+1):
    k = sum(map(lambda x:abs(x-j), A))
    c = min(c,k)
print(c)


### FIXED CODE ###

import statistics
N = int(input())
A = [int(a)-i-1 for i,a in enumerate(input().split(),1)]
b = statistics.median_low(A)
c = statistics.median_high(A)
d = sum(map(lambda x:abs(x-b),A))
e = sum(map(lambda x:abs(x-c),A))
print(min(d,e))
### BUGGY CODE ###

from collections import defaultdict
N, Q = map(int, input().split())
events = []

for i in range(N):
    s, t, x = map(int, input().split())
    events.append([s - x, 'add', x])
    events.append([t - x, 'delete', x])

events.sort()
events.append([float('inf'), 'guard', None])

i = 0
closing_cnt = defaultdict(int)
closing = set()
for q in range(Q):
    d = int(input())
    while d >= events[i][0]:
        time, event, x = events[i]
        if event == 'add':
            closing_cnt[x] += 1
            closing.add(x)
        elif event == 'delete':
            closing_cnt[x] -= 1
            if closing_cnt[x] == 0:
                closing.remove(x)

        i += 1

    if closing:
        print(min(closing))
    else:
        print(-1)

### FIXED CODE ###

def main():

    import sys
    import heapq

    N, Q = map(int, sys.stdin.readline().split())
    events = []

    for i in range(N):
        s, t, x = map(int, sys.stdin.readline().split())
        events.append((s - x, 1, x))  # 通行止め追加
        events.append((t - x, -1, x))  # 通行止め削除

    for i in range(Q):
        d = int(input())
        events.append((d, 2, 0))

    events.sort()
    events.append([float('inf'), 'guard', None])

    i = 0
    closing = set()
    hq = []  # 最小値を高速に入手するため
    while d >= events[i][0]:
        time, event, x = events[i]
        if event == 1:
            closing.add(x)
            heapq.heappush(hq, x)

        elif event == -1:
            closing.remove(x)

        else:
            while hq and (hq[0] not in closing):
                heapq.heappop(hq)

            if hq:
                print(hq[0])
            else:
                print(-1)

        i += 1


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

N,K = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
for i in range(N):
    p[i] = (1+p[i])/2
s = sum(p[:K])
max_s = s
for i in range(N):
    if max_s < sum(p[i:K+i]):
        max_s = sum(p[i:K+i])

print(max_s)


### FIXED CODE ###

N, K = map(int, input().split())
p = list(map(int,input().split()))
box = []
for i in p:
    box.append((i+1)/2)

sum_a = sum(box[:K])
max_a = sum_a
for i in range(N-K):
    max_a -= box[i]
    max_a += box[i+K]
    if max_a > sum_a:
        sum_a = max_a

print(sum_a)
### BUGGY CODE ###

N, M = [int(_) for _ in input().split()]

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

result = 1

a = 1

while True:
    b = M - (a * (N - 1))
    if b < 1:
        break
    # print(a, b)
    x = gcd(a, b)
    result = max(result, x)
    a += 1

print(result)

### FIXED CODE ###

import math

N, M = [int(_) for _ in input().split()]


sr = int(math.sqrt(M))

result = 1

for i in range(sr, 0, -1):
    if M % i == 0:
        r = i
        if M >= N * r:
            result = max(r, result)
        r = M // i
        if i >= N:
            result = max(r, result)

print(result)
### BUGGY CODE ###

n = int(input())
a = []
for _ in range(n):
  a.append(int(input()))

maxnum = max(a)

for i in range(n):
  tmp = a.pop(i)
  if tmp == maxnum:
    print(max(a))
  else:
    print(maxnum)
  a.insert(i, tmp)


### FIXED CODE ###

n = int(input())
a = []
for _ in range(n):
  a.append(int(input()))

b = sorted(a)
maxnum = b[-1]
nextmaxnum = b[-2]

if maxnum == nextmaxnum:
  for i in range(n):
    print(maxnum)
else:
  for i in range(n):
    if a[i] == maxnum:
      print(nextmaxnum)
    else:
      print(maxnum)
### BUGGY CODE ###

import sys
n = int(input())
a = list(map(int, input().split()))
b = []
for i in a:
    if i in b:
        print('NO')
        sys.exit()
    else:
        b.append(i)
print('YES')

### FIXED CODE ###

import sys
n = int(input())
a = list(map(int, input().split()))
if len(a) != len(set(a)):
    print('NO')
else:
    print('YES')
### BUGGY CODE ###

import math
n,m = map(int,raw_input().split())

if abs(n-m) > 1:
	print 0
	quit()

if max(n,m) > min(n,m):
	print math.factorial(max(n,m)) * math.factorial(min(n,m)) % (10**9 + 7)

else :
	print (math.factorial(n)**2 * 2)%(10**9 + 7)

### FIXED CODE ###


mod = 10**9+7
n,m = map(int,raw_input().split())
def factorial(x):
	retval = 1
	for i in range(2,x+1):
		retval = (retval * i)% mod
	return retval

if abs(n-m) > 1:
	print 0
	quit()

if max(n,m) > min(n,m):
	print (factorial(max(n,m)) * factorial(min(n,m))) % mod

else :
	print ((factorial(n)**2)%mod * 2)%mod