Harryxun/stf_run huggingface dataset:
from sympy import nextprime
import math
x=int(input())
for k in range(2, int(math.sqrt(x)) + 1):
    if x % k == 0:
        print(nextprime(x))
        exit()
print(x)

### FIXED CODE ###

x=int(input())
p=x**0.5
while any(x%i==0 for i in range(2,int(p)+1)):
  x+=1
else:
  print(x)
import collections


def mod_pow(a, n, mod):
    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


def main(n, d):
    MOD = 998244353
    counter = collections.Counter(d)
    if counter[0] != 1:
        return 0
    if 0 in counter.values:
        return 0
    pows = [mod_pow(a=counter[i - 1], n=counter[i], mod=MOD) for i in
            range(1, max(counter.keys()) + 1)]
    patterns = 1
    for p in pows:
        patterns *= p
        patterns %= MOD
    return patterns


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    print(main(n=N, d=D))


### FIXED CODE ###

import collections


def mod_pow(a, n, mod):
    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


def main(n, d):
    MOD = 998244353
    counter = collections.Counter(d)
    if counter[0] != 1 or d[0] != 0:
        return 0
    pows = [mod_pow(a=counter[i - 1], n=counter[i], mod=MOD) for i in
            range(1, max(counter.keys()) + 1)]
    patterns = 1
    for p in pows:
        patterns *= p
        patterns %= MOD
    return patterns


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    print(main(n=N, d=D))
n = stdin.readline()
    n, K = n.split(' ')
    n = int(n)
    K = int(K)
    arr = stdin.readline()
    arr = [int(a) for a in arr.split(' ')]
    dp = [float('inf')]*n
    dp[0] = 0
    for i in range(n):
        for k in range(1, K+1):
            if i - k >= 0:
                dp[i] = min(dp[i], dp[i-k]+abs(arr[i]-arr[i-k]))
    print(dp[-1])

### FIXED CODE ###

n, k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]

def abs(x):
    if x >= 0:
        return x
    return -x

c = [0]
c.append(abs(h[1] - h[0]))
for i in range(2, n):
    cmin = None
    for cur in range(i-1, i-1-k, -1):
        if cur < 0:
            break
        val = abs(h[i] - h[cur]) + c[cur]
        if cmin is None or val < cmin:
            cmin = val
    c.append(cmin)

print(c[-1])
poland = input().split()

num = []
for p in poland:
    if p.isdisit():
        num.append(int(p))
    else:
        b = num.pop()
        a = num.pop()
        if p == '*':
            num.append(a * b)
        elif p == '+':
            num.append(a + b)
        elif p == '-':
            num.append(a - b)
print(num.pop())

### FIXED CODE ###

poland = input().split()
num = []
for p in poland:
    if p.isdigit():
        num.append(int(p))
    else:
        b = num.pop()
        a = num.pop()
        if p == '*':
            num.append(a * b)
        elif p == '/':
            num.append(a / b)
        elif p == '+':
            num.append(a + b)
        elif p == '-':
            num.append(a - b)
print(num.pop())
n=int(input())
d=[int(di) for di in int(input()).split()]
print(sum(d[i]*d[j] for i in range(n) for j in range(i+1,n)))

### FIXED CODE ###

n=int(input())
d=[int(di) for di in input().split()]
print(sum(d[i]*d[j] for i in range(n) for j in range(i+1,n)))
a,b =map(int,input().split())
ans=a*b
ans=ans//1
print(ans)

### FIXED CODE ###

s=input().split()
a=int(s[0])
b=int(float(s[1])*1000) 
ans=a*b
print(ans//1000)
import sys
input = sys.stdin.readline
from itertools import accumulate

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]+list(accumulate(A))
b = [0]+list(accumulate(B))
ans,j = 0,M
for i in range(N+1):
    if i > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
from itertools import accumulate

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]+list(accumulate(A))
b = [0]+list(accumulate(B))
ans,j = 0,M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)
X=int(input())
Y=int(input())
Z=int(input())
print(Z)
print(X)
print(Y)

### FIXED CODE ###

X,Y,Z = map(int, input().split())
print(Z,X,Y)
x1, y1, x2, y2 = map(int, input().split())
x = x1 - x2
y = y1 - y2
print(c - y, d + x, a - y, b + x)

### FIXED CODE ###

a, b, c, d = map(int, input().split())
x = c - a
y = d - b
print(c - y, d + x, a - y, b + x)
import numpy as np
n,m = map(int,input().split())
H = list(map(int,input().split()))
A=np.zeros((n,n))
for i in range(m):
    a,b=input().split()
    A[int(a)-1][int(b)-1]=1
    A[int(b)-1][int(a)-1]=1
count = 0    
for i in range(n):
  best = H[i]
  for j in range(n):
      if A[i][j]==1 and best <= H[j]:
        best = H[j]
  if best == H[i]:
    count += 1
print(count)  

### FIXED CODE ###

s= input()
if s == 'ABC':
  print('ARC')
elif s == 'ARC':
  print('ABC')
n = int(input())
h = list(map(int,input().split()))

ans = []
count = 0
for i in range(n-1):
  if h[i] >= h[i+1]:
    count+=1
  else:
    ans.append(count)
    count = 0
print(max(ans))

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))
ans = []
ans.append(0)
count = 0
for i in range(n-1):
  if h[i] >= h[i+1]:
    count += 1
    ans.append(count)
  else:
    count=0
print(max(ans))
n=int(input())
l=[]
from collections import defaultdict
d=defaultdict(lambda:defaultdict(int))
l1=[[] for i in range(n+1)]
#d=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  l1[a].append(b)
  l1[b].append(a)
  l.append([a,b])
max1=0
for i in l1:
  if max1<len(i):
    max1=len(i)
def dfs(x,y):#xは頂点yは入ってくる色
  l2=l1[x]
  now=1
  for i in range(len(l2)):
    if d[x][l2[i]]!=0:
      pass
    else:                
      if now==y:
        now+=1
      d[x][l2[i]]=now
      d[l2[i]][x]=now
      dfs(l2[i],now)
      now+=1
print(max1)
dfs(1,0)
for i in range(len(l)):
  print(d[l[i][0]][l[i][1]])

### FIXED CODE ###

n=int(input())
l=[]
import sys
sys.setrecursionlimit(20000000)
from collections import defaultdict
d=defaultdict(lambda:defaultdict(int))
l1=[[] for i in range(n+1)]
#d=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  l1[a].append(b)
  l1[b].append(a)
  l.append([a,b])
max1=0
for i in l1:
  if max1<len(i):
    max1=len(i)
def dfs(x,y):#xは頂点yは入ってくる色
  l2=l1[x]
  now=1
  for i in range(len(l2)):
    if d[x][l2[i]]!=0:
      pass
    else:                
      if now==y:
        now+=1
      d[x][l2[i]]=now
      d[l2[i]][x]=now
      dfs(l2[i],now)
      now+=1
print(max1)
dfs(1,0)
for i in range(len(l)):
  print(d[l[i][0]][l[i][1]])
S = input()
wk = S[:4]+S[5:7]+S[8:10]
if wk=<20190430:
    print("Heisei")
else:
    print("TBD")

### FIXED CODE ###

S = input()
wk = int(S[:4]+S[5:7]+S[8:10])
if wk<=20190430:
    print("Heisei")
else:
    print("TBD")
N,A=map(int,input().split())
if N>=A and (N-1*A)%500==0:
    print("Yes")
elif N<A:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

N=int(input())
A=int(input())
if N%500<=A:
    print("Yes")
else:
    print("No")
n,k = map(int,input().split())
from math import factorial
for i in range(1,k+1):
    if n-k < i-1:
        print(0)
    if n-k == i-1:
        print(factorial(k-1) / factorial(i-1) / factorial((k-1) - (i-1)))
    else:
        a = factorial(k-1) // factorial(i-1) // factorial(k-i)
        b = factorial(n-k+1) // factorial(i) // factorial(n-k-i+1)
        #print(a)
       #print(b)
        print(a*b % (10**9+7))

### FIXED CODE ###

n,k = map(int,input().split())
from math import factorial
for i in range(1,k+1):
    if n-k < i-1:
        print(0) 
    else:
        a = factorial(k-1) // factorial(i-1) // factorial(k-i)
        b = factorial(n-k+1) // factorial(i) // factorial(n-k-i+1)
        #print(a)
        #print(b)
        print(a*b % (10**9+7))
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
a.sort()
for i in range(m):
    b,c = map(int,input().split())
    if a[0] < b:
        for j in range(b):
            a[j] = max(a[j],c)
    a.sort()
print(sum(a))


### FIXED CODE ###

a,b = map(int,input().split())
if a < 6:
    b = 0
elif a < 13:
    b /= 2
print(int(b))
from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
for i in combinations(range(L,R+1),2):
    if ans>=i[0]*i[1]%2019:
        ans=i[0]*i[1]%2019
    elif L==0 or R==0:
        ans=0
print(ans)

### FIXED CODE ###

from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
if R-L>=2018:
    print(0)
else:
    for i in combinations(range(L,R+1),2):
        if ans>=i[0]*i[1]%2019:
            ans=i[0]*i[1]%2019
    print(ans)
import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

if N == 0:
    print(X)
    exit()

# p.sort()

# minimum = p[0]
# maximum = p[len(p) - 1]

# if X < minimum or maximum < X:
#     print(X)
#     exit()

# diff_min = abs(X - minimum - 1)
# diff_max = abs(X - maximum + 1)
# if diff_min == diff_max:
#     answer = min(minimum - 1, maximum + 1)
# else:
#     answer = minimum - 1 if diff_min < diff_max else maximum + 1

for candidate in range(0, 100 + 2):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)


### FIXED CODE ###

import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

if N == 0:
    print(X)
    exit()

p.sort()

minimum = p[0]
maximum = p[len(p) - 1]

if X < minimum or maximum < X:
    print(X)
    exit()

diff_min = abs(X - minimum - 1)
diff_max = abs(X - maximum + 1)
if diff_min == diff_max:
    answer = min(minimum - 1, maximum + 1)
else:
    answer = minimum - 1 if diff_min < diff_max else maximum + 1

for candidate in range(0, 100 + 2):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)
n = int(input())
as = list(map(int,input().split()))

ans = 1

for i in as:
    ans *= i
    ans = min(ans, 10*18+1)
    if ans == 10**18+1:
        print('-1')

else:
    print(ans)


### FIXED CODE ###

n = int(input())
As = list(map(int,input().split()))

ans = 1

for i in As:
    ans *= i
    ans = min(ans, 10**18 + 1)

if ans == 10**18 + 1:
    print(-1)

else:
    print(ans)
#!/usr/bin/env python
while 1:
    try:
        n=int(raw_input())
        if n==0: break
        h1=map(int, raw_input().split())
        for h in h1:
            h2=[ x for x in h1 if x!=h ]
            g=[ h2[i+1]-h2[i] for i in range(n-1) ]
            if len(set(g))==1:
                print h
                break
    except RuntimeError, e:
        print n, h1
        print e.message

### FIXED CODE ###

#!/usr/bin/env python
while 1:
    n=int(raw_input())
    if n==0: break
    grass=map(int, raw_input().split())
    for i in range(n+1):
        h=[ x for j,x in enumerate(grass) if i!=j ]
        g=[ h[j+1]-h[j] for j in range(len(h)-1) ]
        if len(set(g))==1:
            print grass[i]
            break
from math import factorial

N = int(input())
d = {}
for _ in range(N):
    s = input()
    s_sorted = "".join(sorted(s))
    if not d.get(s_sorted):
        d[s_sorted] = 1
    else:
        d[s_sorted] += 1

ans = 0
for _, v in d.items():
    if v == 1:
        continue
    x = factorial(v) / factorial(2) / factorial(v - 2)
    ans += x

print(round(ans))


### FIXED CODE ###

from math import factorial

N = int(input())
d = {}
for _ in range(N):
    s = input()
    s_sorted = "".join(sorted(s))
    if not d.get(s_sorted):
        d[s_sorted] = 1
    else:
        d[s_sorted] += 1

ans = 0
for _, v in d.items():
    if v == 1:
        continue
    ans += v * (v - 1) // 2

print(round(ans))
a, b = map(str, input().split())
m = {'D': 'H', 'H': 'D'}

if a == 'H':
  print(b)
else a == 'D':
  print(m[b])

### FIXED CODE ###

a, b = map(str, input().split())
m = {'D': 'H', 'H': 'D'}
 
if a == 'H':
  print(b)
else:
  print(m[b])
s1, s2, s3 = map(int, input().split())

print(str.upper(s1[0]+" "+s2[0]+" "+s3[0]))

### FIXED CODE ###

s1, s2, s3 = input().split()

print(str.upper(s1[0]+s2[0]+s3[0]))
a,b=map(int,input().split())
if (a=="H" and b=="H") or (a=="D" and b=="D"):
    print("H")
else:
    print("D")


### FIXED CODE ###

a,b=input().split()
if a=="H" and b=="H":
    print("H")
elif a=="D" and b=="D":
    print("H")
else:
    print("D")
print("".join(s[0] for s in input()split()))

### FIXED CODE ###

print("".join(s[0] for s in input().split()))
s=input()
w=int(input())
for i in range(len(s)//w+1):
    print(s[i*w],end='')

### FIXED CODE ###

s=input()
w=int(input())
for i in range((len(s)-1)//w+1):
    print(s[i*w],end='')
N = int(input())
L = [0 for i in range(N)]
L[0]=2
L[1]=1
for i in range(2, N):
  L[i] = L[i-1]+L[i-2]
print(L[N-1])

### FIXED CODE ###

N = int(input())
L = [0 for i in range(N+1)]
L[0]=2
L[1]=1
for i in range(2, N+1):
  L[i] = L[i-1]+L[i-2]
print(L[N])
import bisect
N = int(input())
S = list(map(int,input().split()))
S.sort(reverse=True)
slime = [S[0]]
S[0] = -1
for i in range(N):
    slime.sort()
    S.sort(reverse=True)
    ai = 0
    for j in range(2**N):
        while S[ai] != -1:
            if slime[j] > S[ai]:
                slime.append(S[ai])
                S[ai] = -1
                ai += 1
                break
            ai += 1
        if S[ai] == -1:
            print("No")
            exit()
print("Yes")


### FIXED CODE ###

N = int(input())
S = list(map(int,input().split()))
S.sort(reverse=True)
slime = [S[0]]
S[0] = -1
for i in range(N):
    slime.sort(reverse = True)
    S.sort(reverse=True)
    ai = 0
    for j in range(2**i):
        while S[ai] != -1:
            if slime[j] > S[ai]:
                slime.append(S[ai])
                S[ai] = -1
                ai += 1
                break
            ai += 1
    if len(slime) < 2**(i+1):
        print("No")
        exit()
print("Yes")
from enum import Enum
from queue import Queue
import collections

import sys
import math
import time

t1=time.time()
input = sys.stdin.readline
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


#S = str(input())
S = str('?'*(10**5))
N = 13

dp =[0]*N
dp[0]=1

mul = 1
reversed_S = reversed(S)
for c in reversed_S:
    nextDP = [0]*N
    if c == '?':
        # print('test')
        # print(mul)
        for k in range(10):
            for j in range(N):
                nextDP[(mul*k+j)%N] += dp[j]
                nextDP[(mul*k+j)%N] %= MOD
    else:
        k = int(c)
        for j in range(N):
            nextDP[(mul*k+j)%N] += dp[j]
            nextDP[(mul*k+j)%N] %= MOD

    mul *= 10
    mul %= N
    dp = nextDP[:]
print(dp[5])
#print(time.time()-t1)


### FIXED CODE ###

#from enum import Enum
#from queue import Queue
#import collections

#import sys
#import math
#import time

#t1=time.time()
#input = sys.stdin.readline
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


S = input().strip()
# S = str('?'*(10**5))
N = 13

dp =[0]*N
dp[0]=1

mul = 1
reversed_S = S[::-1]
for c in reversed_S:
    nextDP = [0]*N
    if c == '?':
        # print('test')
        # print(mul)
        for k in range(10):
            for j in range(N):
                nextDP[(mul*k+j)%N] += dp[j]
                nextDP[(mul*k+j)%N] %= MOD
    else:
        k = int(c)
        for j in range(N):
            nextDP[(mul*k+j)%N] += dp[j]
            nextDP[(mul*k+j)%N] %= MOD

    mul *= 10
    mul %= N
    dp = nextDP[:]
print(dp[5])
#print(time.time()-t1)
n = int(input())
d = []
for i in range(n):
    s = input()
    if not(s in d): d.append(s)

print(len(d))



### FIXED CODE ###

S,W = list(map(int,input().split()))
if W >= S:print('unsafe')
else: print('safe')
A,B,X = map(int, input().split())
# 整数Nにたいして値段PはP=A*N + B*d(N), P<Xとなる最大のNを求める.ただしN<10**9以下となる
#d(N)に対して探索してみる
ketasu = 20
while True:
    if ketasu == 0:  # なんにもかえない場合
        n=0
        break
    Bdn = ketasu * B
    min_num = 1*10**(ketasu-1)
    min_P = min_num * A + Bdn
    if min_P > X:
        ketasu -= 1
        continue
    else:  # Xで買える桁数
        n = (X-Bdn) // A
        if n == 10**ketasu:  # 10**ketasu 
            n -= 1
        break
if n>10**9:
    print(10**9)
else:
    print(n)



### FIXED CODE ###

S=input()
days = ['SUN','MON','TUE','WED','THU','FRI','SAT']
print(7-days.index(S))
def main():
  n = input()
  A = map(int, raw_input().split())
  p = input()
  m = map(int, raw_input().split())
  for i in range(q)
    if solve(0, m[q], A)
  for j in range()

def solve(int i, int m, A):
  if m == 0:
    return 1
  if i >= n:
    return 0
  res = solve(i+1, m) or solve(i+1, m-A[i])
  return res

### FIXED CODE ###

def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())

dp = [[-1 for col in range(2000)] for row in range(n+1)]

for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
answer = 1
while True:
    d += l[answer-1]
    if d > x:
        break
    answer += 1
print(answer)

### FIXED CODE ###

n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
answer = 1
for _ in range(n):
    d += l[answer-1]
    if d > x:
        break
    answer += 1
print(answer)
list(combinations([i for i in range(_[0],_[1]+1)],2)if _[1]-_[0]<2019else combinations([i for i in range(_[0],_[0]+2020)],2))

### FIXED CODE ###

from itertools import combinations
_=list(map(int,input().split()))
a=list(combinations([i for i in range(_[0],_[1]+1)],2) if _[1]-_[0]<2019 else combinations([i for i in range(_[0],_[0]+2020)],2))
print(min([i[0]*i[1]%2019 for i in list(a)]))
a,b = input().split()
M = a * b
print(M)

### FIXED CODE ###

a, b = map(int,input().split())
M = a * b
S = 2 * (a + b)
print(M,S)
X,K,D = map(int,input().split())

X = abs(X)

if X-K*D <= 0:
    d = X//D
    K -= d
    x -= D*d
    if K%2 == 0:
        print(a)
    else:
        print(abs(a-d))
else:
    print(X-K*D)

### FIXED CODE ###

X,K,D = map(int,input().split())

X = abs(X)

if X-K*D <= 0:
    d = X//D
    if (K-d%2)%2:
        print(D-X%D)
    else:
        print(X%D)
else:
    print(X-K*D)
N, K = map(int,input().split())
A = sorted(map(int,input().split()))
start = 0
end = A[-1]
l = (start + end)/2
while int(end) - int(start) >= 1:
   l = (start + end)/2
   count = 0
   for i in range(N):
      q, mod = divmod(A[i], l)
      if mod == 0.0;
         q -= 1
      count += q
   if count > K:
      start = l
   else:
      end = l
ans = (start + end)/2
print(int(end)+1)

### FIXED CODE ###

N, K = map(int,input().split())
A = list(map(int,input().split()))
start = 0
end = 10**9
while end - start > 1:
   l = (start + end)/2
   l = int(l)
   count = 0
   for i in range(N):
      q = A[i]/l
      if q == int(q):
         q -= 1
      count += int(q)
   if count <= K:
      end = l
   else:
      start = l
print(end)
S = list(input())
N = len(S)

c=0
i=0
f=0
while(1):
    if S[i] != S[i+1]:
        del S[i:i+2]
        c+=2
        N-=2
        if i>=1:
            i-=2
        else:
            i-=1
    i+=1
    #print(i,N,S,f)                                                                      
    if i+1 == N or N < 2:
        break
print(c)

### FIXED CODE ###

S = list(input())
N = len(S)

c=0
i=0
f=0
while(1):
    if i+1 == N or N < 2:
        break
    if S[i] != S[i+1]:
        del S[i:i+2]
        c += 2
        N -= 2
        if i >= 1:
            i -= 2
        else:
            i -= 1
    i += 1
    #print(i,N,S,f)                                                                      
print(c)
W, H, N = map(int, input().split())
P = [list(map(int, input().split())) for i in range(N)]
X1, X2, Y1, Y2 = 0, W, 0, H

for i in range(N):
    if P[i][2] == 1:  # ai=1
        X1 = max(X1, P[i][0])
    elif P[i][2] == 2:  # ai=2
        X2 = min(X2, P[i][0])
    elif P[i][2] == 3:  # ai=3
        Y1 = max(Y1, P[i][1])
    elif P[i][2] == 4:  # ai=4
        Y2 = min(Y2, P[i][1])

if X1 < X2 and Y1 < Y2:
    S = (X2 - X1) * (Y2 - Y1)
else:
    S = 0
print(S)

### FIXED CODE ###

[a,b,c]=list(map(int,input().split()))
if a+b==c or a+c==b or b+c==a :
    print("Yes")
else:
    print("No")
#N = int(input())
#A = list(map(int, input().split()))
n, a = input().split("\n")
N = int(n)
A = list(map(int, a.split()))

mod = 7 + 10**9
s = 0

for i in range(N-1): 
	for	j in range(i+1, N):
		t = A[i] * A[j] % mod
		s += t

ans = s % mod
print(ans)

### FIXED CODE ###

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

ans = 0
mod = 7 + 10**9

s = sum(A)
for i in range(N):
	s -= A[i]
	ans += s * A[i]
	ans %= mod

print(ans)
import math
a,b,c = map(int,input().split())
ans = math.sqrt(c*a) - math.sqrt(c*b)
if 1 < ans/(a-b):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a,b,c = map(int,input().split())
x = c-a-b
if x <= 0:
    print('No')
else:
    if x*x > 4* a*b:
        print('Yes')
    else:
        print('No')
r,d,x=list(map(int,input().split()))
for i in 9:
  x=r*x-d
  print(x)

### FIXED CODE ###

r,d,x=list(map(int,input().split()))
for i in range(10):
  x=r*x-d
  print(x)
n = int(input())

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

co = 0

for i in range(1,len(li)-1):
  work = sort([li[i-1],li[i],li[i+1]])

  if work.index(li[i]) == 1:
    co += 1
print(co)

### FIXED CODE ###

n = int(input())

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

co = 0

for i in range(1,len(li)-1):
  work = sorted([li[i-1],li[i],li[i+1]])

  if work.index(li[i]) == 1:
    co += 1
print(co)
S = input()
T = input()
X = 0
for i in range(len(S)):
  S = S[-1] + S[:-1] 
  print(S)
  if S == T:
    X = 1

if X == 0:
  print('No')
elif X == 1:
  print('Yes')

### FIXED CODE ###

a,b,c = input().split(' ')
A = abs(int(a)-int(b))
B = abs(int(b)-int(c))
C = abs(int(c)-int(a))
N = A + B + C -max(A, B, C)
print(N)
x,y,l=0,5,len(s)
for _ in range(10**5):
  if x>=l-7:
    if x==l-7 and s[x:l]=='dreamer':
      print('YES')
    elif x==l-6 and s[x:l]=='eraser':
      print('YES')
    elif x==l-5 and (s[x:l]=='dream' or s[x:l]=='erase'):
      print('YES')
    else:
      print('NO')
    exit()
    
  if s[x:y]=='erase':
    x=y+1 if s[y]=='r' else y
    y=x+5
  elif s[x:y]=='dream':
    x=y+2 if s[x:y+2]=='er' else y
    y=x+5
  else:
    print('NO')
    exit()

### FIXED CODE ###

s=input()
x,y,l=0,5,len(s)
for _ in range(10**5):
  if x>=l-7:
    if x==l-7 and s[x:l]=='dreamer':
      print('YES')
    elif x==l-6 and s[x:l]=='eraser':
      print('YES')
    elif x==l-5 and (s[x:l]=='dream' or s[x:l]=='erase'):
      print('YES')
    else:
      print('NO')
    exit()
    
  if s[x:y]=='erase':
    x=y+1 if s[y]=='r' else y
    y=x+5
  elif s[x:y]=='dream':
    x=y if s[y:y+3]=='era' else (y+2 if s[y:y+2]=='er' else y) 
    y=x+5
  else:
    print('NO')
    exit()