CodeEff/ECCO huggingface dataset:
# Original solution
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
A = LIST()
B = LIST()

# データの持ち方を座標から区間長にして累積和
A2 = []
for i in range(N-1):
    A2.append(A[i+1] - A[i])
B2 = []
for i in range(M-1):
    B2.append(B[i+1] - B[i])
A2 = [0] + list(accumulate(A2))
B2 = [0] + list(accumulate(B2))

# 縦横独立に、累積和の全区間総和を取る
lsm = rsm = 0
for i in range(N):
    lsm += A2[i] * (N-i-1)
    rsm += A2[i] * i
    lsm %= MOD
    rsm %= MOD
h = rsm - lsm
lsm = rsm = 0
for i in range(M):
    lsm += B2[i] * (M-i-1)
    rsm += B2[i] * i
    lsm %= MOD
    rsm %= MOD
w = rsm - lsm

ans = h * w % MOD
print(ans)


# Optimized solution
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
A = LIST()
B = LIST()

# 縦横独立に、全区間総和を取る
lsm = rsm = 0
for i in range(N):
    lsm += A[i] * (N-i-1)
    rsm += A[i] * i
    lsm %= MOD
    rsm %= MOD
h = rsm - lsm
lsm = rsm = 0
for i in range(M):
    lsm += B[i] * (M-i-1)
    rsm += B[i] * i
    lsm %= MOD
    rsm %= MOD
w = rsm - lsm

ans = h * w % MOD
print(ans)
# Original solution
# -*- coding: utf-8 -*-
# 整数の入力
n,m= list(map(int, input().split()))
x=list(map(int, input().split()))
y=list(map(int, input().split()))
yoko=0
tate=0
for i in range (0,n-1):
  for j in range (i+1,n):
    yoko+=x[j]-x[i]
for i in range (0,m-1):
  for j in range (i+1,m):
    tate+=y[j]-y[i]

print((yoko*tate%(10**9+7)))

# Optimized solution
# -*- coding: utf-8 -*-
# 整数の入力
n,m= list(map(int, input().split()))
x=list(map(int, input().split()))
y=list(map(int, input().split()))
yoko=0
tate=0
for i in range (0,len(x)):
  yoko+=(n-2*i-1)*x[i]
for i in range (0,len(y)):
  tate+=(m-2*i-1)*y[i]

print((yoko*tate%(10**9+7)))
# Original solution
n, m = list(map(int, input().split()))
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
for i in range(n-1):
  for j in range(m-1):
    t = (X[i+1]-X[i]) * (Y[j+1]-Y[j])
    t %= MOD
    t *= (n-i-1)*(i+1)
    t %= MOD
    t *= (m-j-1)*(j+1)
    t %= MOD
    ans += t
    ans %= MOD
print(ans)

# Optimized solution
n, m = list(map(int, input().split()))
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10**9+7
sx, sy = 0, 0
for i in range(n):
  t = 2*i+1-n
  t *= X[i]
  t %= MOD
  sx += t
  sx %= MOD
for j in range(m):
  t = 2*j+1-m
  t *= Y[j]
  t %= MOD
  sy += t
  sy %= MOD
print((sx*sy%MOD))
# Original solution
n,m=list(map(int,input().split()))
x=list(map(int,input().split()))
y=list(map(int,input().split()))
ans=0
for i in range(n-1):
    for j in range(m-1):
        ans=(ans+(x[i+1]-x[i])*(y[j+1]-y[j])*(i+1)*(n-1-i)*(j+1)*(m-1-j))%(10**9+7)
print(ans)

# Optimized solution
n,m=list(map(int,input().split()))
x=list(map(int,input().split()))
y=list(map(int,input().split()))
X=0
Y=0
for i in range(n-1):X=(X+(x[i+1]-x[i])*(i+1)*(n-1-i))%(10**9+7)
for i in range(m-1):Y=(Y+(y[i+1]-y[i])*(i+1)*(m-1-i))%(10**9+7)
print((X*Y%(10**9+7)))
# Original solution
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10**9+7

ans = 0
for i in range(n-1):
    for j in range(m-1):
        s = ((x[i+1] - x[i])*(y[j+1] - y[j]))%mod
        ans = (ans + s * (((i+1) * (n-i-1))%mod) * (((j+1) * (m-j-1))%mod)) % mod

print(ans)


# Optimized solution
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10**9+7

ans = 0
y01 = (y[1] - y[0])%mod
ynum = m-1
for i in range(n-1):
    s = (((x[i+1] - x[i])%mod) * y01) % mod
    xnum = (i+1) * (n-i-1)
    ans = (ans + (s*xnum*ynum) % mod) % mod
band = ans

inv = [0] * (m + 1)
inv[1] = 1
for i in range(2, m):
    inv[i] = mod - inv[mod % i] * (mod // i) % mod

for j in range(1, m-1):
    band = (((((band * inv[j])%mod) * inv[m-j])%mod) * (((j+1) * (m-j-1))%mod))%mod
    band = ((band * ((y[j+1] - y[j])%mod))%mod * pow(((y[j]-y[j-1])%mod), mod-2, mod))%mod
    ans = (ans + band)%mod

print(ans)
# Original solution
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

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

X = sorted(list(map(int,input().split())))
Y = sorted(list(map(int,input().split())))
ans = 0
for i in range(n - 1):
    for j in range(m - 1):
        S = (X[i + 1] - X[i]) * (Y[j + 1] - Y[j])
        num = (i + 1) * (n - (i + 1)) * (j + 1) * (m - (j + 1))
        S *= num
        S %= 10 ** 9 + 7
        ans += S
        ans %= 10 ** 9 + 7
print(ans)




# Optimized solution
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

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

X = [0] + sorted(list(map(int,input().split())))
Y = [0] + sorted(list(map(int,input().split())))
sum1 = 0
sum2 = 0
MOD = 10 ** 9 + 7
for i in range(1, n + 1):
    sum1 += ((i - 1)*X[i] - (n - i)*X[i]) % MOD
for i in range(1, m + 1):
    sum2 += ((i - 1)*Y[i] - (m - i)*Y[i])%MOD
print((sum1 * sum2 % MOD))
# Original solution
import sys
readline = sys.stdin.readline

N,M = list(map(int,readline().split()))
X = list(map(int,readline().split()))
Y = list(map(int,readline().split()))
DIV = 10 ** 9 + 7

# カウントする回数分X,Y軸ともに辺の長さを伸ばしていって巨大な長方形を作るイメージ
# X軸の、長さLの辺を3回数える場合、L * 2分X軸の辺の長さを伸ばす。
# X軸Y軸ともに各辺を数える回数が分かれば、巨大な長方形の面積はその積で求められる
# 
# X軸について、i番目の辺は、((i - 1) + 1) * (N - i)回数える
# 例：4番目の辺の場合
# ...X.. 
# Xより左から4通り（0も含むため） * Xより右から3通り(0も含むため)
# この回数分、辺の長さを掛けることを全ての辺に対して行った総和がX軸の辺の総量
# Y軸についても同じものを求めて、掛け合わせたものが答え

xsum = 0
for i in range(1, len(X)):
  # i番目の辺は、長さX[i] - X[i - 1]
  edge = X[i] - X[i - 1]
  # i番目の辺は((i - 1) + 1) * (N - i)回数える
  times = i * (N - i)
  xsum += ((edge % DIV) * (times % DIV)) % DIV
  xsum %= DIV

ysum = 0
for i in range(1, len(Y)):
  # i番目の辺は、長さY[i] - Y[i - 1]
  edge = Y[i] - Y[i - 1]
  # i番目の辺は((i - 1) + 1) * (M - i)回数える
  times = i * (M - i)
  ysum += ((edge % DIV) * (times % DIV)) % DIV
  ysum %= DIV

print(((xsum * ysum) % DIV))

# Optimized solution
import sys
readline = sys.stdin.readline

N,M = list(map(int,readline().split()))
X = list(map(int,readline().split()))
Y = list(map(int,readline().split()))
DIV = 10 ** 9 + 7

def f(V):
  vsum = 0
  for i in range(1, len(V)):
    vsum += (((V[i] - V[i - 1]) % DIV) * ((i * (len(V) - i)) % DIV)) % DIV
    vsum %= DIV
  return vsum
  
print(((f(X) * f(Y)) % DIV))
# Original solution
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(eval(input())) # n=1
def inpm(): return list(map(int,input().split())) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(eval(input())) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(eval(input())) for _ in range(n)]
def inplT(n): return [tuple(eval(input())) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)] # [[2,2,2,2],[1,1,1,1],[3,3,3,3]] 
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 

def main():
    n,m = inpm()
    x = inpl()
    y = inpl()
    N = [0 for _ in range(n-1)]
    M = [0 for _ in range(m-1)]
    cnt = n-1
    plus = 0
    for i in range(n-1):
        plus += cnt
        N[i] = plus
        N[-i-1] = plus
        cnt -= 2
        if cnt <= 0:
            break
    cnt = m-1
    plus = 0
    for i in range(m-1):
        plus += cnt
        M[i] = plus
        M[-i-1] = plus
        cnt -= 2
        if cnt <= 0:
            break
    ans = 0
    for i in range(n-1):
        for j in range(m-1):
            area = ((x[i+1]-x[i])*(y[j+1]-y[j])) % mod
            area = (area*N[i]) % mod
            area = (area*M[j]) % mod
            ans = (ans+area) % mod
    print(ans)   
    
if __name__ == "__main__":
    main()

# Optimized solution
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(eval(input())) # n=1
def inpm(): return list(map(int,input().split())) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(eval(input())) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(eval(input())) for _ in range(n)]
def inplT(n): return [tuple(eval(input())) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)] # [[2,2,2,2],[1,1,1,1],[3,3,3,3]] 
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 

def main():
    n,m = inpm()
    x = inpl()
    y = inpl()
    X = 0
    Y = 0
    cntX, cntY = n-1, m-1
    for i in range(n-1,-1,-1):
        X += x[i]*cntX
        X %= mod
        cntX -= 2
    for i in range(m-1,-1,-1):
        Y += y[i]*cntY
        Y %= mod
        cntY -= 2
    print(((X*Y)%mod))


    
if __name__ == "__main__":
    main()
# Original solution
def d_igeta(N, M, X, Y):
    tmp1 = 0
    tmp2 = 0
    for k, x in enumerate(X):
        k += 1
        tmp1 += (k - 1) * x - (N - k) * x
    for k, y in enumerate(Y):
        k += 1
        tmp2 += (k - 1) * y - (M - k) * y
    return (tmp1 * tmp2) % (10**9 + 7)

N,M = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
print((d_igeta(N, M, X, Y)))

# Optimized solution
def d_rectangles(MOD=10**9 + 7):
    N, M = [int(i) for i in input().split()]
    X = [int(i) for i in input().split()]
    Y = [int(i) for i in input().split()]

    ans1 = sum([x * (2 * k - N - 1) for k, x in enumerate(X, 1)])
    ans2 = sum([y * (2 * k - M - 1) for k, y in enumerate(Y, 1)])
    return (ans1 * ans2) % MOD

print((d_rectangles()))
# Original solution
MOD = 10 ** 9 + 7
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
SUM = 0

for i in range(N):
    for j in range(M):
        pos = i * j + (N - i - 1) * (M - j - 1)
        neg = i * (M - j - 1) + (N - i - 1) * j
        SUM = (SUM + X[i] * Y[j] * (pos - neg)) % MOD
print(SUM)


# Optimized solution
MOD = 10 ** 9 + 7
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

x_sum = 0
for i in range(N):
    x_sum = (x_sum + X[i] * (N - i - 1) - X[i] * i) % MOD

y_sum = 0
for i in range(M):
    y_sum = (y_sum + Y[i] * (M - i - 1) - Y[i] * i) % MOD

result = (x_sum * y_sum) % MOD

print(result)
# Original solution
def rren(): return list(map(int, input().split()))
n, m = rren()
x = rren()
y = rren()
ans = 0
for now_x in range(n-1):
    for now_y in range(m-1):
        S = (x[now_x+1]-x[now_x])*(y[now_y+1]-y[now_y])
        count = (now_x+1)*(n-now_x-1)*(now_y+1)*(m-now_y-1)
        ans = (ans + S*count) % 1000000007

print(ans)

# Optimized solution
def rren(): return list(map(int, input().split()))
n, m = rren()
x = rren()
y = rren()
ans = 0
x_sum = 0
y_sum = 0
for now_x in range(n):
    x_sum += x[now_x] * (now_x - (n-1 - now_x))
for now_y in range(m):
    y_sum += y[now_y] * (now_y - (m-1 - now_y))

print((x_sum * y_sum % 1000000007))
# Original solution
print(('a' if input().islower() else 'A'))


# Optimized solution
print(('Aa'[input().islower()]))
# Original solution
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = readline().strip()

    n = ord(N)
    low = list(range(97, 97+ 26))

    if n in low:
        print("a")
    else:
        print("A")




if __name__ == "__main__":
    main()


# Optimized solution
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    a = readline().strip()

    print(("a" if a.islower() else "A"))


if __name__ == "__main__":
    main()
# Original solution
X = int(eval(input()))


def is_prime_number(number):
    is_dividable = lambda divided, divider: divided % divider == 0
    result = all([not is_dividable(number, divider) for divider in range(2, number)])

    return result


answer = X
while True:
    if is_prime_number(answer): break
    answer += 1

print(answer)


# Optimized solution
import math

X = int(eval(input()))


def is_prime_number(number):
    is_dividable = lambda divided, divider: divided % divider == 0
    result = all([not is_dividable(number, divider) for divider in range(2, int(math.sqrt(number)))])

    return result


answer = X
while True:
    if is_prime_number(answer): break
    answer += 1

print(answer)
# Original solution
x=int(eval(input()))
flag=0
while(1):
    flag=0
    for i in range(2,int(x/2+1)):
        if x%i==0:
            flag=1
            x+=1
            break
    if flag==0:
        print(x)
        break


# Optimized solution
n=int(eval(input()))
flag=1
for i in range(n,10*n):
  j=2
  flag=1
  while(j<=int(i**(0.5))):
    if(i%j==0):
      flag=0
      break
    j+=1
  if(flag==1):      
    print(i)
    break
# Original solution

n = int(eval(input()))

pr = []
i = 2
while(True):
    for p in pr:
        if(i % p == 0):break
    else:
        if(i >= n):
            print(i)
            exit()
        pr.append(i)
    i += 1


# Optimized solution
import random

def is_prime(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n = int(eval(input()))

i = n
while(not is_prime(i)):i += 1
print(i)
# Original solution
x=int(eval(input()))
ans=x-1
cnt=0
while cnt==0:
	cnt=1
	ans+=1
	for i in range(2,ans):
		if ans%i==0:
			cnt=0
print(ans)

# Optimized solution
x=int(eval(input()))
ans=x-1
cnt=0
while cnt==0:
	cnt=1
	ans+=1
	for i in range(2,ans):
		if ans%i==0:
			cnt=0
			break
print(ans)
# Original solution
X = int(eval(input()))

def is_prime(x):
	if x == 2:
		return True
	if x % 2 == 0:
		return False
	else:
		for i in range(3, x, 2):
			if x % i == 0:
				return False
		return True

a = X
if (X % 2 == 0) & (X > 2):
	a += 1
while 1:	
	if is_prime(a):
		print(a)
		break
	else:
		a += 2
			

# Optimized solution
import math
X = int(eval(input()))

def is_prime(x):
	if x == 2:
		return True
	if x % 2 == 0:
		return False
	else:
		for i in range(3, int(math.sqrt(x))+1, 2):
			if x % i == 0:
				return False
		return True

a = X
if (X % 2 == 0) & (X > 2):
	a += 1
while 1:	
	if is_prime(a):
		print(a)
		break
	else:
		a += 2
# Original solution
from bisect import bisect
def main():
    maxa2 = 200000
    maxa2 = max(6, maxa2)  # maxa2が6未満だとエラーになる
    p = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(maxa2)]
    p[0] = p[1] = False
    p[2] = p[3] = p[5] = True
    for is1 in range(3, maxa2, 2):
        for is2 in range(is1 ** 2, maxa2, is1):
            p[is2] = False
    prime_list = [i for i, b in enumerate(p) if b]

    x = int(eval(input()))
    if x in prime_list:
        print(x)
    else:
        xp = bisect(prime_list, x)
        r = prime_list[xp]
        print(r)

if __name__ == '__main__':
    main()

# Optimized solution
from math import sqrt, ceil
def main():
    x = int(eval(input()))
    while True:
        for i1 in range(2, ceil(sqrt(x))):
            if x % i1 == 0:
                x += 1
                break
        else:
            break
    print(x)

if __name__ == '__main__':
    main()
# Original solution
x = int(eval(input()))
num = 101000
arr = list(range(2,num))
arr = set(arr)
primes = {2}

prime = min(arr)
while prime < num-500:
    primes.add(prime)
    nonprime = {prime * i for i in range(1,num//prime + 2)}
    arr = arr.difference(nonprime)
    prime = min(arr)

sol = {i for i in primes if i >= x}

print((min(sol)))

# Optimized solution
x = int(eval(input()))
num = 100200
arr = list(range(2,num))
arr = set(arr)
primes = {2}
floor = int(num**0.5)+2

prime = min(arr)
while prime < floor:
    prime = min(arr)
    primes.add(prime)
    nonprime = {prime * i for i in range(1,num//prime + 2)}
    arr = arr.difference(nonprime)

primes = primes.union(arr)

sol = {i for i in primes if i >= x}

print((min(sol)))
# Original solution
# ABC149 C - Next Prime
X = int(eval(input()))

def isPrime(n):
    cnt = 0
    for i in range(1, n + 1):
        if n % i == 0:
            cnt += 1
    if cnt == 2:
        return True
    else:
        return False

while True:
    if isPrime(X):
        print(X)
        break
    else:
        X += 1

# Optimized solution
# ABC149 C - Next Prime
X = int(eval(input()))

def isPrime(n):
    for i in range(2, n):
        if n % i == 0:
            return False
    return True

while True:
    if isPrime(X):
        print(X)
        break
    else:
        X += 1
# Original solution
x= int(eval(input()))
a = [2]
n = 2
while a[-1] < x:
    n += 1
    if all(n%i for i in a):
        a.append(n)
print(n)

# Optimized solution
def f(n):
    if n==2:return 2
    for i in range(2,[n, 5][n>5]):
        if i**n%n != i:
            return f(n+1)
    return n
print((f(int(eval(input())))))
# Original solution
x=int(eval(input()))
cont=0
for i in range(x,10**12):
    for j in range(2,i):
        if i%j==0:
            cont+=1
    if cont==0:
        print(i)
        exit()
    cont=0  

# Optimized solution
x=int(eval(input()))
j=x
while True:
    cnt=0
    for i in range(2,j+1):
        if j%i==0:
            cnt+=1
    if cnt==1:
        print(j)
        exit()
    else:
        j+=1
# Original solution
x = int(eval(input()))
flg = 0
def isPrimenum(n):
	if n < 2:
		return False
	if n == 2:
		return True
	for p in range(2, n):
		if n % p == 0:
			return False
	return True
while flg == 0:
	if isPrimenum(x) == True:
		flg = 1
		break
	x += 1
print (x)


# Optimized solution
import math
n = int(eval(input()))

def check(s):
	if s == 1:
		return False
	for i in range(2, int(math.sqrt(s)) + 1):
		if s%i == 0:
			return False
	return True

for i in range(n,10**6):
	if check(i):
		print (i)
		exit()
# Original solution
#探索範囲増やすとどのくらい時間が伸びるのか

x=int(eval(input()))

def is_prime(p):
  cnt=0
  for i in range(2,p):
    if p%i==0:
      cnt+=1
  if cnt==0:
    return True
  #2からp-1までみて、cntが0ならpは素数
  else:
    return False
      
#print(*[(x,is_prime(x)) for x in range(1,10+1)])
num=x
while True:
  if is_prime(num):
    ans=num
    break
  num+=1
print(ans)


# Optimized solution
x=int(eval(input()))

mod=10**7+9
for i in range(x,mod):
  if not any(i%j==0 for j in range(2,i+1-1)):
    ans=i
    break
    
print(ans)
# Original solution
import math

for i in range(int(eval(input())),100004):
  ri = math.floor(i**0.5) + 1
  for j in range(ri):
    for k in range(ri,i):
      if j*k == i:
        break
    else:
      continue
    break
  else:
    print(i)
    break

# Optimized solution
for i in range(int(eval(input())),100004):
  for j in range(2, i):
    if i % j == 0:
      break
  else:
    print(i)
    break
# Original solution
n = int(eval(input()))
while 1:
  for i in range(2, n):
    if n % i == 0:
      break
  else:
    print(n)
    break
  n += 1

# Optimized solution
x=int(eval(input()))
while 1:
  if all(x%i for i in range(2,int(x**.5)+1)):
    print(x); break
  x+=1
# Original solution
import math
x=int(eval(input()))

def is_prime(x):
    ma = math.ceil(math.sqrt(x))
    for i in range(2,ma):
        if x%i==0:
            return False
    else:
        return True

while(1):
    if x==1:
        x+=1
        continue
    if is_prime(x):
        print(x)
        break
    x+=1

# Optimized solution
import math
x=int(eval(input()))

def is_prime(x):
    ma = math.ceil(math.sqrt(x))
    for i in range(2,ma+1):
        if x%i==0:
            return False
    else:
        return True

while(1):
    if x==1:
        x+=1
        continue
    elif x==2:
        print(x)
        break
    if is_prime(x):
        print(x)
        break
    x+=1
# Original solution
X = int(eval(input()))
LEN = int(1e6)
p = [True] * LEN

p[0] = False
p[1] = False

for i in range(LEN):
  if p[i]:
    for j in range(i * 2, LEN, i):
      p[j] = False

for i in range(X, LEN):
  if p[i]:
    print(i)
    exit()


# Optimized solution
X = int(eval(input()))
LEN = int(1e6)
p = [True] * LEN

p[0] = False
p[1] = False

for i in range(LEN):
  if p[i]:
    if i >= X:
      print(i)
      exit()
      
    for j in range(i * 2, LEN, i):
      p[j] = False
# Original solution
#coding:utf-8
import math
import collections

def prime():
    prime = [2, 3]
    for i in range(5, 1000000, 2):
        flag = True
        for j in range(1, len(prime)):
            if prime[j] ** 2 > i:
                break
            if i % prime[j] == 0:
                flag = False
                break
        if flag:
            prime.append(i)
    return prime

if __name__ == "__main__":
    x = int(eval(input()))
    prime = prime()
    #print(prime)
    for num in prime:
        if int(num) >= x:
            print(num)
            break

# Optimized solution
#coding:utf-8
import math

#素数判定
def prime(n):
    if n == 2:
        return True
    elif (n < 2) or (n % 2 == 0):
        return  False
    else:
        i = 3
        while i <= math.sqrt(n):
            if n % i == 0:
                return False
            i += 2

        return True

if __name__ == "__main__":
    x = int(eval(input()))
    num = x

    while prime(num) == False:
        num += 1

    print(num)
# Original solution
def nprime(x):
  prim=[]
  i=1
  while(1):
    i+=1
    non=False
    for num in prim:
      if i%num==0:
        non=True
        break
    if non:
      continue
    elif(i>=x):
      return i
    prim.append(i)

print((nprime(int(eval(input())))))

# Optimized solution
import math
def prim(x):
  for i in range(2,math.floor(math.sqrt(x))):
    if not x%i:
      return 0
  return 1

def np(x):
  while(1):
    if prim(x):
      return x
    else:
      x+=1
      
print((np(int(eval(input())))))