Harryxun/stf_run huggingface dataset:
a,s=map(int,input().split())
sa,ss=[input() for i in range(2)]
if a<s:
    a,s=s,a
    sa,ss=ss,sa
from math import gcd
g=gcd(a,s)
x,y=a//g,s//g
for i in range(1,s//x):
    if sa[y*i]!=ss[x*i]:print(-1);break
else:print(x*s)

### FIXED CODE ###

a,s=map(int,input().split())
sa,ss=[input() for i in range(2)]
if a<s:
    a,s=s,a
    sa,ss=ss,sa
from fractions import gcd
g=gcd(a,s)
x,y=a//g,s//g
for i in range(g):
    if sa[x*i]!=ss[y*i]:print(-1);break
else:print(x*s)
from fractions import Fraction
l = map(int, raw_input().split())
toshisuu= l[0]
starttoshi= l[1]
mathlist=[0]
toshilist = map(int, raw_input().split())
ans=100000000000000000000
das=0
for i in toshilist:
    counts=abs(i-starttoshi)
    if das==0:
        mathlist[0]=counts
        das=1
    else:
        mathlist.append(counts)
mathlist.sort(reverse = True)
# print mathlist
print gcd(mathlist[0], mathlist[1])


### FIXED CODE ###

ls = raw_input().split()
l=[0,0]
l[0]=int(ls[0])
l[1]=int(ls[1])

if (l[0]%2==0)or(l[1]%2==0):
    print "No"
else:
    print "Yes"
n = int(input())
s = list(map(int,input().split()))
q = int(input())
r = list(map(int,input().split()))
cou = 0

for i in range(q):
    for j in range(n):
        if(s[i] == r[j]):
            cou += 1
            break
print(cou)


### FIXED CODE ###

n = int(input())
s = list(map(int,input().split()))
q = int(input())
r = list(map(int,input().split()))
cou = 0

for i in range(q):
    for j in range(n):
        if(s[j] == r[i]):
            cou += 1
            break
print(cou)
L,N = (int, input().split())
s = sorted([input() for i in range(N)])
print(s,end="")

### FIXED CODE ###

n,l=map(int,input().split())
s=sorted([input() for i in range(n)])
print("".join(s))
A, B, C, D = [int(e) for e in input().split()]

import math
G = math.gcd(C, D)

A_B = []
for AB in [A-1, B]:
  AB_c = AB // C
  AB_d = AB // D
  AB_g = AB // G
  A_B.append(AB_c + AB_d - AB_g)
can_divide = A_B[1] - A_B[0]
ans = (B - (A-1)) - can_divide
print(ans)

### FIXED CODE ###

A, B, C, D = [int(e) for e in input().split()]
E = max(C, D)
F = min(C, D)

mod = 1
while mod > 0:
  mod = E % F
  if mod == 0:
    break
  else:
    E = F
    F = mod
G = C*D // F

A_B = []
for AB in [A-1, B]:
  AB_c = AB // C
  AB_d = AB // D
  AB_g = AB // G
  A_B.append(AB_c + AB_d - AB_g)
can_divide = A_B[1] - A_B[0]
ans = (B - (A-1)) - can_divide
print(ans)
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for q in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

sam = float(sum(A))
baketu = [0]*(10**5)
for a in A:
    baketu[a] += 1

for q in range(Q):
    sam = sam + baketu[B[q]] * (C[q] - B[q])
    baketu[C[q]] += baketu[B[q]]
    baketu[B[q]] = 0
    print(sam)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for q in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

sam = sum(A)
baketu = [0]*(100001)
for a in A:
    baketu[a] += 1

for q in range(Q):
    sam = sam + baketu[B[q]] * (C[q] - B[q])
    baketu[C[q]] += baketu[B[q]]
    baketu[B[q]] = 0
    #print(baketu)
    print(sam)
a,b,c,d = map(int, [input() for i in range(4)])
print(min(a,b) + (c,d))

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(min(a,b) + min(c,d))
#!/usr/bin/env python3
import sys
import statistics
import collections

def solve(n: int, v: "List[int]"):
    half_length = len(v) // 2
    O = [v[i] for i in range(1, n, 2)]
    E = [v[i] for i in range(0, n, 2)]

    co = list(collections.Counter(O).most_common())
    ce = list(collections.Counter(E).most_common())
    o1 = co[0][0]
    e1 = ce[0][0]

    O_ = list(filter(lambda o: o != o1, O))
    E_ = list(filter(lambda e: e != e1, E))
    num_o_1 = len(O_) 
    num_e_1 = len(E_)
    if e1 != o1:
        num = num_o_1 + num_e_1
    else:
        if len(co) == 1 and len(ce) == 1:
            num = half_length
        elif len(co) == 1:
            e2 = ce[1][0]
            num_e_2 = len(filter(lambda e: e != e2, E))
            num = num_o_1 + num_e_2
        elif len(ce) == 1:
            o2 = co[1][0]
            num_o_2 = len(filter(lambda o: o != o2, O))
            num = num_o_2 + num_e_1
        else:
            e2 = ce[1][0]
            o2 = co[1][0]
            o1e2 = num_o_1 + num_e_2
            o2e1 = num_o_2 + num_e_1
            num = o1e2 if o1e2 < o2e1 else o2e1
    print(num)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, v)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import statistics
import collections

def solve(n: int, v: "List[int]"):
    half_length = len(v) // 2
    O = [v[i] for i in range(1, n, 2)]
    E = [v[i] for i in range(0, n, 2)]

    co = list(collections.Counter(O).most_common())
    ce = list(collections.Counter(E).most_common())
    o1 = co[0][0]
    e1 = ce[0][0]

    O_ = list(filter(lambda o: o != o1, O))
    E_ = list(filter(lambda e: e != e1, E))
    num_o_1 = len(O_) 
    num_e_1 = len(E_)

    num = 0
    if e1 != o1:
        num = num_o_1 + num_e_1
    else:
        if len(co) == 1 and len(ce) == 1:
            num = half_length
        elif len(co) == 1:
            e2 = ce[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num = num_o_1 + num_e_2
        elif len(ce) == 1:
            o2 = co[1][0]
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = num_o_2 + num_e_1
        else:
            e2 = ce[1][0]
            o2 = co[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)
    print(num)
    return

def len2(l):
    n = 0
    for i in l:
        n += 1
    return n

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, v)

if __name__ == '__main__':
    main()
mod = 1000000007
 
N, M = [int(i) for i in input().split()]
A = [int(input()) for _ in range(M)] + [N + 1]
 
for i in range(len(A) - 1):
    if A[i] + 1 == A[i + 1]:
        print(0)
        quit()
 
memo = {0: 1, 1: 1, 2: 2, 3: 3}
 
def fib(n):
    if n not in memo:
        memo[n] = fib(n - 1) + fib(n - 2)
    return memo[n]
 
ans = 1
pre = -1
lo = 0
for a in A:
    f = fib(a - 1 - lo)
    ans = (ans * f) % mod
 
    lo = a + 1
    pre = a
 
print(ans)

### FIXED CODE ###

mod = 1000000007

N, M = [int(i) for i in input().split()]
A = [int(input()) for _ in range(M)] + [N + 1]

for i in range(len(A) - 1):
    if A[i] + 1 == A[i + 1]:
        print(0)
        quit()

fib = [-1] * (N + 1)
fib[0] = 1
fib[1] = 1
for i in range(2, len(fib)):
    fib[i] = fib[i - 1] + fib[i - 2]


ans = 1
pre = -1
lo = 0
for a in A:
    f = fib[a - 1 - lo]
    ans = (ans * f) % mod

    lo = a + 1
    pre = a

print(ans)
n = input()
if n % 2 == 0:
    print(n)
else:
    print(n*2)


### FIXED CODE ###

n = int(input())
if n % 2 == 0:
    print(n)
else:
    print(n*2)
import sys
import numpy as np 

n = int(sys.stdin.readline().rstrip())
graph = [None] * n
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    graph[i] = np.array([[sys.stdin.readline().split()] for _ in range(a)], dtype=np.int8).T

def main():
    comb = np.arange(1 << n)[:, None] >> np.arange(n) & 1
    for i in range(n):
        x, y = graph[i]
        bl = (comb[:, i][:, None] ^ 1) | (comb[:, x-1] == y).reshape(len(comb), -1)
        bl = np.all(bl, axis=1)
        comb = comb[bl]
    print(np.amax(comb.sum(axis=1)))

if __name__ ==  '__main__':
    main()

### FIXED CODE ###

import sys
# import numpy as np

n = int(sys.stdin.readline().rstrip())
xy = [[] for _ in range(n)]

for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    for j in range(a):
        x, y = map(int, sys.stdin.readline().split())
        xy[i].append((x-1, y))

# xy = np.array(xy)
# x, y = xy[:, :].T
# x = x.T 
# y = y.T

def main():
    ans = 0
    for comb in range(2 ** n):
        cnt = 0
        ok = True
        for i in range(n):
            if not comb >> i & 1:
                continue
            for x, y in xy[i]:
                if comb >> x & 1 ^ y:
                    ok = False
                    break
            if ok:
                cnt += 1
            else:
                break
        else:
            ans = max(ans, cnt)
    return ans
                
if __name__ == '__main__':
    ans = main()
    print(ans)
a, b, c, d = map(int, list(input()))
if a+b+c+d == 7: print(a,"+", b, "+", c, "+", d, sep="")
elif a+b+c-d == 7: print(a,"+", b, "+", c, "-", d, sep="")
elif a+b-c+d == 7: print(a,"+", b, "-", c, "+", d, sep="")
elif a-b+c+d == 7: print(a,"-", b, "+", c, "+", d, sep="")
elif a+b-c-d == 7: print(a,"+", b, "-", c, "-", d, sep="")
elif a-b-c+d == 7: print(a,"-", b, "-", c, "+", d, sep="")
elif a-b+c-d == 7: print(a,"-", b, "+", c, "-", d, sep="")
else: print(a,"-", b, "-", c, "-", d, sep="")1222

### FIXED CODE ###

a, b, c, d = map(int, list(input()))
if a+b+c+d == 7: print(a,"+", b, "+", c, "+", d, "=7", sep="")
elif a+b+c-d == 7: print(a,"+", b, "+", c, "-", d, "=7", sep="")
elif a+b-c+d == 7: print(a,"+", b, "-", c, "+", d, "=7", sep="")
elif a-b+c+d == 7: print(a,"-", b, "+", c, "+", d, "=7", sep="")
elif a+b-c-d == 7: print(a,"+", b, "-", c, "-", d, "=7", sep="")
elif a-b-c+d == 7: print(a,"-", b, "-", c, "+", d, "=7", sep="")
elif a-b+c-d == 7: print(a,"-", b, "+", c, "-", d, "=7", sep="")
else: print(a,"-", b, "-", c, "-", d, "=7", sep="")
a, b, c = map(int, input().split())

ans = ((a-b)-c)*-1
if 0>ans:
    ans = 0
print(ans)

### FIXED CODE ###

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

ans = ((a-b)-c)*-1
if 0>ans:
    ans = 0
print(ans)
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

orders = [A, B, C, D, E]
max_fp = 10
time = 0

for i, order in enumerate(orders):
    if order % 10 < max_fp and order % 10 != 0:
        max_fp = order % 10
        last_order = i

for i, order in enumerate(orders):
    if i == last_order or order % 10 == 0:
        time += order
    else:
        time += (order // 10 + 1) * 10

print(time)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

orders = [A, B, C, D, E]
max_fp = 10
ans = 0
last_order = 0

for i, order in enumerate(orders):
    if order % 10 < max_fp and order % 10 != 0:
        max_fp = order % 10
        last_order = i

for i, order in enumerate(orders):
    if i == last_order or order % 10 == 0:
        ans += order
    else:
        ans += (order // 10 + 1) * 10

print(ans)
S, T = input().split()
A, B = map(int, input().split())
U = input()
if U == S:    A -= 1
else: B -= 1
print(A, B)

### FIXED CODE ###

S, a = input(), ""
for x in range(len(S)):
    a += "x"
print(a)
n, m, *lst = map(int, input().split())
l = max(lst[::2])
r = min(lst[1::2])
if l > r:
  print(0)
else:
  print(r - l + 1)


### FIXED CODE ###

n, m = map(int, input().split())
left, right = 1, n
for _ in range(m):
  l, r = map(int, input().split())
  if l > left:
    left = l
  if r < right:
    right = r
  if left > right:
    print(0)
    quit()
print(right - left + 1)
N = input()

if N % 2 == 0:
    print((N/2)/N)
else:
    print(((N//2+1)/N))

### FIXED CODE ###

N = int(input())

if N % 2 == 0:	
    print((N/2)/N)
else:
    print(((N+1)/2)/N)
a,b=map(int,input().split())
if a%2==0:print("Even")
  elif b%2==0:print("Even")
    else:print("Odd")

### FIXED CODE ###

a,b=map(int,input().split())
if (a)%2 == 0:
  print("Even")
elif (b)%2 == 0:
	print("Even")
else:
  print("Odd")
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, X, D = map(int, raw_input().split())
if D < 0:
    X = X + D * (N - 1)
    D = -D
m1 = {}
m2 = {}
m1[0] = D
m2[0] = -D
ans = 1
for i in range(1, N + 1):
    p1 = (X + X + D * (i - 1)) * i / 2
    p2 = (X + D * (N - 1) + X + D * (N - i)) * i / 2
    rem = p1 % D
    if rem in m1:
        ans += max(0, (p2 - max(m1[rem], p1)) / D + 1)
        ans += max(0, (min(p2, m2[rem]) - p1) / D + 1)
    else:
        ans += (p2 - p1) / D + 1
    m1[rem] = p2 + D
    m2[rem] = p1 - D
print ans

### FIXED CODE ###

#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, X, D = map(int, raw_input().split())
if D == 0:
    if X == 0:
        print 1
    else:
        print N + 1
    exit()
if D < 0:
    X = X + D * (N - 1)
    D = -D
m1 = {}
m2 = {}
m1[0] = D
m2[0] = -D
ans = 1
for i in range(1, N + 1):
    p1 = (X + X + D * (i - 1)) * i / 2
    p2 = (X + D * (N - 1) + X + D * (N - i)) * i / 2
    rem = p1 % D
    if rem in m1:
        ans += max(0, (p2 - max(m1[rem], p1)) / D + 1)
        ans += max(0, (min(p2, m2[rem]) - p1) / D + 1)
    else:
        ans += (p2 - p1) / D + 1
    m1[rem] = p2 + D
    m2[rem] = p1 - D
print ans
n = int(input())
a_list = list(map(int, input().split())
              
a_sorted = sorted(a_list)
              
print(a_sorted[-1] - a_sorted[0])

### FIXED CODE ###

n = int(input())
a_list = list(map(int, input().split()))
              
a_sorted = sorted(a_list)
              
print(a_sorted[-1] - a_sorted[0])
a=int(input())
b=int(input())
x=int(input())

if (a > x):
	print("No")
elif(a+b)>x:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

a=input().strip().split()
b=[int(i) for i in a]

if (b[0] > b[2]):
	print("NO")
elif(b[0]+b[1])>b[2]:
	print("YES")
else:
	print("NO")
S = list(input())

#最後かどうかのチェック
final = 'zyxwvutsrqponmlkjihgfedcba'
flag = True
for i in range(len(S)):
    if S[i] == final[i]:
        pass
    else:
        flag = False
        break

if flag and len(S) == 26:
    print (-1)
    exit()

a = 'abcdefghijklmnopqrstuvwxyz'
if len(S) != 26:
    for i in range(26):
        if not a[i] in S:
            print (*S, a[i], sep = '')
            exit()

### FIXED CODE ###

S = list(input())

a = 'abcdefghijklmnopqrstuvwxyz'
if len(S) != 26:
    for i in range(26):
        if not a[i] in S:
            print (*S, sep = '', end = '')
            print (a[i])
            exit()

for i in range(25, -1, -1):
    if i == -1:
        break
    if ord(S[i]) < ord(S[i - 1]):
        continue
    else:
        break
# print (i)
if i == 0:
    print (-1)
    exit()

tmp_n = ord('z')
for j in S[i:]:
    if ord(j) > ord(S[i - 1]):
        tmp_n = min(tmp_n, ord(j))

print (*S[:i - 1], sep = '', end = '')
print (chr(tmp_n))
a,b = [int(i) for i in input.split()]
print(a * b , a * 2 + b * 2) 

### FIXED CODE ###

a,b = [int(i) for i in input().split()]
print(a * b , a * 2 + b * 2)
L, R = map(int, input().split())
if L < R:
    print('Right')
elif L == R:
    print('Balanced')
else:
    print('Left')

### FIXED CODE ###

A, B, C, D = map(int, input().split())
if A+B < C+D :
    print('Right')
elif A+B == C+D:
    print('Balanced')
else:
    print('Left')
print " ".join(map(str, sorted(map(int, raw_input().strip().sprit(" ")), lambda x , y: y - x)))

### FIXED CODE ###

l = map(int, raw_input().strip().split(" "));
print " ".join(map(str, sorted(l, lambda x, y: y - x)));
N = int(input())
H = [int(i) for i in input().split()]
m_max = 0
count = 0
for j in range(1, N):
  if H[j] <= H[j-1]:
  	count += 1
  	if j == N-1:
      if count > m_max:
      	m_max = count
  else:
    if count > m_max:
      m_max = count
    count = 0
print(m_max)

### FIXED CODE ###

N = int(input())
H = [int(i) for i in input().split()]
m_max = 0
count = 0
for j in range(1, N):
  if H[j] <= H[j-1]:
    count += 1
    if j == N-1:
      if count > m_max:
        m_max = count
  else:
    if count > m_max:
      m_max = count
    count = 0
print(m_max)
def min_diag(A,B,C):
  segments=[A,B,C]
  segments.sort()
  return (segments[0]**2+segments[1]**2)**(1/2)

while True:
  # input one dataset
  A,B,C = tuple(map(float,input().split()))
  if (A,B,C) == (0,0,0):
    break
  n = int(input())
  R = [None]*n
  for i in range(n):
    R[i] = float(input())

  # process
  min_diag = min_diag(A,B,C)

  # judge & output
  for r in R:
    if min_diag < 2*r:
      print("OK")
    else:
      print("NA")

### FIXED CODE ###

def min_diam(A,B,C): # returns a "diameter"
  segments=[A,B,C]
  segments.sort()
  return (segments[0]**2+segments[1]**2)**(1/2)

while True:
  # input one dataset
  A,B,C = tuple(map(float,input().split()))
  if (A,B,C) == (0,0,0):
    break
  n = int(input())
  R = [None]*n
  for i in range(n):
    R[i] = float(input())
  # process
  diam = min_diam(A,B,C)
  # judge & output
  for r in R:
    if diam < 2*r:
      print("OK")
    else:
      print("NA")
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
b = 0
#print(a)
for i in range(N):
    while a[i] %2 == 0:
        b += 1
        a[i] /= 2
print(b)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
b = 0
for i in range(N):
    while a[i] %2 == 0:
        b += 1
        a[i] /= 2
print(b)
N,A,B=map(int,input().split())
blue=[1]*A
red=[-1]*B
ball=(blue+red)*N
X=ball[0:N]
print(X)
print(X.count(1))

### FIXED CODE ###

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

r=N//(A+B)*A
s=N%(A+B)

x=r+min(A,s)
print(x)
N=int(input())
a=list(map(int,input().split()))

count = [0]*100002

for a in a_list:
    count[a] += 1
    count[a+1] += 1
    count[a+2] += 1
    
print(max(count))


### FIXED CODE ###

from collections import Counter

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

b=[x+1for x in a]
c=[x-1for x in a]

d=a+b+c

print(max(Counter(d).values()))
def main():
	N, K = map(int, input().split())
	DIV = 10**9+7
	ab = [[] for _ in range(N)]

	size = 10**5+1
	fact = [0]*size
	inverse = [0]*size
	inv_cal = [0]*size
	fact[:2] = [1, 1]
	inverse[:2] = [1, 1]
	inv_cal[:2] = [0, 1]

	for i in range(2, size):
		fact[i] = (fact[i-1]*i%DIV)
		inv_cal[i] = (-inv_cal[DIV%i]*(DIV//i))%DIV
		inverse[i] = inverse[i-1]*inv_cal[i]%DIV

	def C(n, r):
		ans = fact[n]*inverse[r]%DIV
		return ans*inverse[n-r]%DIV

	def P(n, r):
		if n < 0:
			return 0
		ans = C(n, r)
		return ans*fact[r]%DIV

	for _ in range(N-1):
		u, v = map(int, input().split())
		ab[u-1].append(v-1)
		ab[v-1].append(u-1)

	def dfs(v, ans=1, p=-1):
		for u in ab[v]:
			if u == p:
				continue
			ans = dfs(u, ans, v)
		c = 0
		nk = K
		if p == -1:
			c = len(ab[v])+1
		else:
			c = len(ab[v])-1
			nk = K-2
		ans *= P(nk, c)
		return ans%DIV
	ans = dfs(0)
	print(ans)


if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

def main():
	N, K = map(int, input().split())
	DIV = 10**9+7
	ab = [[] for _ in range(N)]

	def P(n, r):
		ans = 1
		for i in range(r):
			ans = (ans*(n-i)) % DIV
		return ans

	for _ in range(N-1):
		u, v = map(int, input().split())
		ab[u-1].append(v-1)
		ab[v-1].append(u-1)

	def dfs(v, p=-1):
		c = 0
		ans = 1
		for u in ab[v]:
			if u == p:
				continue
			c += 1
			ans = ans * dfs(u, v) % DIV
		nk = K-1
		if p != -1:
			nk = K-2
		ans *= P(nk, c)
		return ans%DIV
	ans = dfs(0)*K%DIV
	print(ans)


if __name__ == '__main__':
	main()
def main():
    N, K = map(int, input().split())
    h = [int(input()) for count in range(N)]
    h.sort()
    min_value = min(h[i + K - 1] - h[i] for i in range(N - K + 1))
    print(min_value)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    day = int(input())
    if day == 22:
        print('Christmas Eve Eve Eve')
    elif day == 23:
        print('Christmas Eve Eve')
    elif day == 24:
        print('Christmas Eve')
    elif day == 25:
        print('Christmas')


if __name__ == '__main__':
    main()
n=int(input())

def euc(a,b):
  if a==b:
    return a
  else:
    return euc(max(a,b)-min(a,b),min(a,b))
ans=0
mons=list(map(int,input().split()))
for i in range(n-1):
  p=euc(mons[i],mons[i+1])
  if p==1:
    ans=1
    break
    
  else:
    mons[i+1]=p

if ans==1:
  print(1)
else:
  print(mons[n-1])


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
def euc(x,y):
  x,y=max(x,y),min(x,y)
  if x%y==0:
    return y
  else:
    return euc(y,x%y)
k=a[0]
for i in range(1,n):
  k=euc(a[i],k)
print(k)
n = int(input())
p = list(map(int,input().split()))
ans = 0

class Node:
    def __init__(self, data): #コンストラクタ
        self.data = data #ノードがもつ数値
        self.left = None #左エッジ
        self.right = None #右エッジ


class BST:
    def __init__(self, number_list): #コンストラクタ
        self.root = None #ルートノード初期化
        for node in number_list: #数値を持つ配列から二分木を生成
            self.insert(node) #挿入メソッドを使ってノードを挿入する
    #挿入
    def insert(self, data):
        n = self.root
        if n == None:
            self.root = Node(data)
            return
        else:
            while True:
                entry = n.data
                if data < entry:
                    if n.left is None:
                        n.left = Node(data)
                        return
                    n = n.left
                elif data > entry:
                    if n.right is None:
                        n.right = Node(data)
                        return
                    n = n.right
                else:
                    n.data = data
                    return


	def count(self):
		ans = 0
		n = self.root
		while True:
		if n != None:
			ans += 1
			n = n.left
		return ans


tree = BST(p)
tree.count()
print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
ans = 0
list_a=[]
min = p[0]
for i in p:
  if min >= i:
    min = i
    ans += 1
print(ans)
ok = [{0,4,8}, {2,4,6}, {0,1,2}, {3,4,5}, {6,7,8}, {0,3,6}, {1,4,7}, {2,5,8}]
while True:
    s = input()
    if len(s) == 0:
        break
    maru = set()
    batu = set()
    for i in range(9):
        if s[i] == 'o':
            maru.add(i)
        elif s[i] == 'x':
            batu.add(i)
    flag = False
    for i in ok:
        if len(i - maru) == 0:
            print("o")
            flag = True
            break
        elif len(i - batu) == 0:
            print("x")
            flag = True
            break
    if flag:
        continue
    print("d")

### FIXED CODE ###

ok = [[0,4,8], [2,4,6], [0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8]]
while True:
    try:
        s = input()
    except EOFError:
        break
    flag = False
    for i in ok:
        if s[i[0]] == s[i[1]] == s[i[2]] and s[i[0]] != 's':
            print(s[i[0]])
            flag = True
            break
    if flag:
        continue
    print("d")
def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(input())
    # b = list(map(int, input().split()))
    b = [int(i) for i in input().split()] 
  else:
    # b = [1,2,1]
    # b = [2,2]
    b = [1,1,1,2,2,1,2,3,2]
    N = len(b)
    
  if check(b) != True:
    print(-1)
    
def check(B):
  # if 'get_ipython' in globals(): print(B)
  lenB = len(B)
  maxB = max(B)
  if lenB == 0 :
    return True
  # for i in reversed(range(lenB)):
  for i in reversed(range(0,maxB)):
    if B[i] == i+1:
      if check(B[:i]+B[(i+1):]) == True:
        print(B[i])
        return True
        break
    
main()

### FIXED CODE ###

import sys

def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(input())
    b = [int(i) for i in input().split()] 
  else:
    # b = [1,2,1]
    # b = [2,2]
    b = [1,1,1,2,2,1,2,3,2]
    N = len(b)

  ans = []
  while True:
    for i in range(N-1,-1,-1):
      if b[i] == i+1:
        ans.append(i+1)
        del b[i]
        N = N -1
        break
      if i == 0:
        print(-1)
        sys.exit()
    if N == 0:
      break

  for i in reversed(ans):
    print(i)
    
main()