n = int(input())
A = [int(input()) for i in range(n)]

b = list()
lenB = 0
for a in A:
    b.append(a)
    lenB += 1
    if len(set(b)) != lenB:
        b.pop(-1)
        b.remove(a)
        lenB -= 2
print(len(b))

n = int(input())
A = [int(input()) for i in range(n)]

b = set()
lenB = 0
for a in A:
    b.add(a)
    lenB += 1
    if len(b) != lenB:
        b.remove(a)
        lenB -= 2
print(len(b))


N = int(input())
A = list([int(input()) for _ in range(N)])
ans = []

for a in A:
    if a not in ans:
        ans.append(a)
    else:
        ans.remove(a)
print(len(ans))

import collections

N = int(input())
A = list([int(input()) for _ in range(N)])
A = collections.Counter(A).values()

ans = [x for x in A if x & 1]
print(len(ans))


n = int(input())
ans = []
for _ in range(n):
    a = int(input())
    if a in ans:
        ans.pop(ans.index(a))
    else:
        ans.append(a)
print(len(ans))

import collections

n = int(input())
a = [int(input()) for _ in range(n)]
c = collections.Counter(a)

print(len(list(filter(lambda x: x[1] % 2 == 1, c.items()))))


N = int(input())
A = [int(input()) for _ in range(N)]
counter = 0

while A:
    x = A[0]
    if A.count(x) % 2 == 1:
        counter += 1
    A = [i for i in A if i != x]

print(counter)

N = int(input())
maps = {}

for _ in range(N):
    A = int(input())
    if A in maps:
        maps.pop(A)
    else:
        maps[A] = 1

print(len(maps))


count = 0
N = int(input())
string = list(map(int, [input() for i in range(N)]))
for i in set(string):
    if string.count(i) % 2 != 0:
        count += 1
print(count)

N = int(input())
L = set()
for i in range(N):
    L ^= {input()}
print(len(L))


import sys

n = int(sys.stdin.readline())
a_list = [int(x) for x in sys.stdin.readlines()]
a_list_index = list(set(a_list))
count = 0
for i in a_list_index:
    if a_list.count(i) % 2 == 0:
        continue
    else:
        count += 1

print(count)

import sys
import collections

n = int(sys.stdin.readline())
a_list = [int(x) for x in sys.stdin.readlines()]
a_list_counter = collections.Counter(a_list)
count = 0
for i in a_list_counter:
    if a_list_counter[i] % 2 != 0:
        count += 1
    else:
        continue
print(count)


N = int(input())
A = [int(input()) for _ in range(N)]

p = []

for i in A:
    if i not in p:
        p.append(i)
    else:
        p.remove(i)

print(len(p))

from collections import Counter

N = int(input())
A = [int(input()) for _ in range(N)]

res = 0

c = Counter(A)

for i in c.values():
    if i % 2 != 0:
        res += 1

print(res)


import collections

N = int(input())
A = [int(input()) for i in range(N)]

Adic = collections.Counter(A)

B = [n % 2 for n in Adic.values()]

while 0 in B:
    B.remove(0)

print(len(B))

import collections

N = int(input())
A = [int(input()) for i in range(N)]

Adic = collections.Counter(A)

B = [n % 2 for n in Adic.values()]

print(B.count(1))


N = int(input())
A = [int(input()) for _ in range(N)]

paper = [0] * 100000

for a in A:
    paper[a - 1] += 1

ans = len(list(filter(lambda x: x % 2 == 1, paper)))
print(ans)

N = int(input())
A = [int(input()) for _ in range(N)]

paper = {}

for a in A:
    paper.setdefault(a - 1, 0)
    paper[a - 1] += 1

ans = len(list(filter(lambda x: x % 2 == 1, paper.values())))
print(ans)


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

c = [a.count(x) for x in set(a)]
print(len([x for x in c if x % 2 == 1]))

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

y = a[0]
c = 1
ans = 0
for i in range(1, n):
    if a[i] == y:
        c += 1
    else:
        if c % 2 == 1:
            ans += 1
        y = a[i]
        c = 1

if c % 2 == 1:
    ans += 1

print(ans)


N = int(input())
A = [int(input()) for _ in range(N)]
B = []
for a in A:
    if a in B:
        B.remove(a)
    else:
        B.append(a)

print(len(B))

N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
A.append(10**9 + 1)

now = 0
cnt = 0
ans = 0
for a in A:
    if a == now:
        cnt += 1
    else:
        now = a
        ans += cnt % 2
        cnt = 1

print(ans)


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

d = []
for i in range(n):
    if a[i] in d:
        d.remove(a[i])
    else:
        d.append(a[i])
print(len(d))

from collections import Counter

n = int(input())
a = Counter([int(input()) for _ in range(n)])

ans = 0
for key in a.keys():
    if a[key] % 2:
        ans += 1

print(ans)


loops = int(input())
paper = []

# 1 <= loops <= 10^6
for _ in range(loops):
    num = int(input())
    if num in paper:
        paper.remove(num)
    else:
        paper.append(num)
print(len(paper))

loops = int(input())
d = {}

# 10^6
for _ in range(loops):
    key = input()
    if key not in d:  # ?
        d[key] = 1
    else:
        d[key] += 1

# 10^6
ans = 0
for k, v in d.items():
    if v % 2 != 0:
        ans += 1
print(ans)


N = int(input())
W = []
for _ in range(N):
    n = input()
    if n in W:
        W.remove(n)
    else:
        W.append(n)
print(len(W))

import collections

N = int(input())
W = [int(input()) for _ in range(N)]
c = collections.Counter(W)
print(len([i for i in c.values() if i % 2 != 0]))


N = int(input())
A = [int(input()) for _ in range(N)]

paper = []
for i in range(N):
    if not A[i] in paper:
        paper.append(A[i])
    else:
        paper.remove(A[i])

print(len(paper))

import collections

N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
Acount = collections.Counter(A)

for i in Acount:
    if Acount[i] % 2 == 1:
        ans += 1

print(ans)


N = int(input())
ans = 0
nums = set([])
for _ in range(N):
    A = int(input())
    if A in nums:
        ans -= 1
        nums.clear(A)
    else:
        ans += 1
        nums.add(A)
print(ans)

N = int(input())
ans = 0
nums = set()
for _ in range(N):
    A = int(input())
    if A in nums:
        ans -= 1
        nums.remove(A)
    else:
        ans += 1
        nums.add(A)
print(ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03607/Python/s903001510.py", line 8, in <module>
    nums.clear(A)
TypeError: set.clear() takes no arguments (1 given)


#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
b = [0] * (10**5 + 1)
for i in a:
    b[i] += 1
print(sum(i % 2 > 0 for i in b))

#!/usr/bin/env python3
from collections import defaultdict

n, *a = map(int, open(0).read().split())
b = defaultdict(int)
for i in a:
    b[i] += 1
print(sum(i % 2 > 0 for i in b.values()))


# -*- coding: utf-8 -*-

import sys

def main():
    _ = sys.stdin.readline()
    arr = []
    for line in sys.stdin:
        num = line.rstrip()
        if num in arr:
            arr.remove(num)
        else:
            arr.append(num)
    print(len(arr))

if __name__ == "__main__":
    main()

# -*- coding: utf-8 -*-

import sys

def main():
    _ = sys.stdin.readline()
    arr = set()
    for line in sys.stdin:
        num = line.rstrip()
        if num in arr:
            arr.remove(num)
        else:
            arr.add(num)
    print(len(arr))

if __name__ == "__main__":
    main()


N = int(input())
A = [int(input()) for _ in range(N)]
result = []
for a in A:
    if a in result:
        result.remove(a)
    else:
        result.append(a)
print(len(result))

from collections import Counter

N = int(input())
A = Counter([int(input()) for _ in range(N)])
num = 0
for a, n in A.items():
    if n % 2 == 1:
        num += 1
print(num)


n = int(input())
a = [int(input()) for _ in range(n)]
cnt = 0
a_set = set(a)
for i in a_set:
    if a.count(i) % 2 != 0:
        cnt += 1
print(cnt)

n = int(input())
D = {}
cnt = 0
for _ in range(n):
    a = int(input())
    if a not in D:
        D[a] = 1
    else:
        D[a] += 1
for i in D:
    if D[i] % 2 != 0:
        cnt += 1
print(cnt)


N = int(input())
A = [input() for _ in range(N)]

d = []
for i in A:
    if i in d:
        d.remove(i)
    else:
        d.append(i)
print(len(d))

from collections import Counter

N = int(input())
A = [input() for _ in range(N)]

res = 0
# print(Counter(A))

c = Counter(A)
for i in c.values():
    res += i % 2
print(res)


import itertools

n, m, R = map(int, input().split())
r = list(map(int, input().split()))
dis = [[float("inf") for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    dis[a - 1][b - 1] = c
    dis[b - 1][a - 1] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            if dis[i][j] > dis[i][k] + dis[k][j]:
                dis[i][j] = dis[i][k] + dis[k][j]

_min = float("inf")
it = itertools.permutations(r)
for iterR in it:
    _dis = 0
    start = iterR[0] - 1
    for end in iterR[1:]:
        _dis += dis[start][end - 1]
        start = end - 1
    _min = min(_min, _dis)
print(_min)

import itertools

n, m, R = map(int, input().split())
r = list(map(int, input().split()))
dis = [[float("inf") for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    dis[a - 1][b - 1] = c
    dis[b - 1][a - 1] = c

def war(dis):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if dis[i][j] > dis[i][k] + dis[k][j]:
                    dis[i][j] = dis[i][k] + dis[k][j]
    return dis

dis = war(dis)
_min = float("inf")
it = itertools.permutations(r)
for iterR in it:
    _dis = 0
    start = iterR[0] - 1
    for end in iterR[1:]:
        _dis += dis[start][end - 1]
        start = end - 1
    _min = min(_min, _dis)
print(_min)


x, t = list(map(int, input().split()))
print(max((x - t), 0))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03609/Python/s297739432.py", line 1, in <module>
    print(max(int(input()) - int(input()), 0))
ValueError: invalid literal for int() with base 10: '100 17'


s = input()
snum = len(s)
harf_snum = snum // 2

s_odd = []
for i in range(harf_snum + 1):
    s_odd.append(s[i * 2])
print("".join(s_odd))

s = input()

s_odd = []
for i in range(0, len(s)):
    if i % 2 == 0:
        s_odd.append(s[i])

print("".join(s_odd))


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03610/Python/s676268610.py", line 1, in <module>
    s = list(int(input()))
ValueError: invalid literal for int() with base 10: 'atcoder'


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

# 先にxを選んでおく！
ans = 0
m = max(L) + 1
for i in range(m):
    cm = L.count(i - 1)
    ce = L.count(i)
    cl = L.count(i + 1)
    ans = max(ans, cm + ce + cl)

print(ans)

from collections import Counter

N = int(input())
L = list(map(int, input().split()))
c = Counter(L)
# print(c)
# 先にxを選んでおく！
ans = 0
m = max(L) + 1
for i in range(m):
    ans = max(ans, c[i - 1] + c[i] + c[i + 1])

print(ans)


N = int(input())
a_lst = [int(x) for x in input().split()]

max_a = -1
max_cnt = -1

for a in a_lst:
    if max_a < a:
        max_a = a
for x in range(max_a + 1):
    cnt = 0
    for a in a_lst:
        if x - 1 <= a and a <= x + 1:
            cnt += 1
    if max_cnt < cnt:
        max_cnt = cnt
print(max_cnt)

N = int(input())
a_lst = [int(x) for x in input().split()]

dict = {}

for a in a_lst:
    if not a - 1 in dict.keys():
        dict[a - 1] = 1
    else:
        dict[a - 1] += 1
    if not a in dict.keys():
        dict[a] = 1
    else:
        dict[a] += 1
    if not a + 1 in dict.keys():
        dict[a + 1] = 1
    else:
        dict[a + 1] += 1
val_lst = list(dict.values())
val_lst.sort(reverse=True)
print(val_lst[0])


import statistics

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

b = []
c = []
for i in range(N):
    b.append(a[i] - 1)
    c.append(a[i] + 1)

x = a + b + c
y = statistics.mode(x)

print(x.count(y))

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

b = []
c = []
for i in range(N):
    if a[i] > 0:
        b.append(a[i] - 1)
        c.append(a[i] + 1)
    else:
        c.append(a[i] + 1)

abc = a + b + c
count = [0] * (max(abc) + 1)

for x in abc:
    count[x] += 1

print(max(count))


from collections import Counter

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

if N >= 3:
    counter = Counter(A)
    m = min(A)
    M = max(A)
    cnt = []
    for i in range(m, M - 1):
        ans = counter[i] + counter[i + 1] + counter[i + 2]
        if ans:
            cnt.append(ans)
        print(cnt)
    print(max(cnt))

elif N == 2:
    if abs(A[0] - A[1]) <= 2:
        print(2)
    else:
        print(1)

elif N == 1:
    print(1)

import numpy as np

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

B = A.copy()
B[1:] += A[:-1]
B[:-1] += A[1:]

answer = B.max()
print(answer)


from collections import Counter

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

ans = 0
c = Counter(a).most_common()
for i in range(min(a), max(a) + 1):
    temp = [value if abs(i - key) <= 1 else 0 for key, value in c]
    ans = max(ans, sum(temp))

print(ans)

from collections import Counter

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

x = []
for i in a:
    x.append(i)
    x.append(i + 1)
    x.append(i - 1)

ans = max(Counter(x).values())
print(ans)


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

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

a.extend(b)
a.extend(c)
f = set(a)
ans = 0
for i in f:
    ans = max(ans, a.count(i))

print(ans)

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

N = 10**5
cnt = [0 for i in range(N + 2)]
# index 0 == -1
for i in a:
    cnt[i] += 1
    cnt[i + 1] += 1
    cnt[i + 2] += 1

print(max(cnt))


# ハッシュで数えてキーでソートして+-1を全探索
n = int(input())
arr = list(map(int, input().split()))
hash = dict()
for a in arr:
    if a in hash:
        hash[a] += 1
    else:
        hash[a] = 1

lis = list(sorted(hash.items(), key=lambda x: x[0]))

ans = 0
for i in range(1, n - 2):
    temp = lis[i][1]
    if lis[i - 1][0] + 1 == lis[i][0]:
        temp += lis[i - 1][1]
    if lis[i + 1][0] - 1 == lis[i][0]:
        temp += lis[i + 1][1]
    ans = max(ans, temp)

print(ans)

# ハッシュで数えてキーでソートして+-1を全探索
# と思ったけど登場してないやつでもいける 3 5 なら4が2個になるのでN個から全探索

n = int(input())
arr = list(map(int, input().split()))
lis = [0 for _ in range(10**5 + 1)]
hash = dict()
for a in arr:
    lis[a] += 1

ans = 1
for i in range(1, 10**5):
    ans = max(ans, lis[i - 1] + lis[i] + lis[i + 1])

print(ans)


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

A = set(a)

ans = 0
for i in A:
    cnt = 0
    J = [i, i - 1, i + 1]
    for j in J:
        if j in a:
            cnt += a.count(j)
    ans = max(ans, cnt)
print(ans)

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

cnt = [0] * (10**5 + 2)

for i in a:
    cnt[i] += 1
    cnt[i + 1] += 1
    cnt[i + 2] += 1

print(max(cnt))


N = int(input())

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

# max_x = max(numbers) + 1
# max_x = int(sum(numbers) / len(numbers))
res = 0
test = set()
for n in numbers:
    test.add(n)
    test.add(n - 1)
    test.add(n + 1)

# for i in range(max_x + 1):
for i in test:
    c = 0
    for n in numbers:
        if n - 1 == i or n == i or n + 1 == i:
            c += 1
    if res < c:
        res = c

print(res)

N = int(input())

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

# max_x = max(numbers) + 1
# max_x = int(sum(numbers) / len(numbers))
# res = 0
test = set()
for n in numbers:
    test.add(n)
    test.add(n - 1)
    test.add(n + 1)
length = len(test)
res = {}
# print(test)
# for i in range(max_x + 1):
for n in numbers:
    c = 0
    sub = set([n - 1, n, n + 1]) & test
    # print(sub)
    for s in sub:
        if res.get(s) is None:
            res[s] = 1
        else:
            res[s] += 1
# for i in test:
#     c = 0
#     for n in numbers:
#         if n - 1 == i or n == i or n + 1 == i:
#             c += 1
#     if res < c:
#         res = c

# print(res)
res = max(res.values())
print(res)


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

num = [0 for i in range(3)]
num[0] = a.count(0)
num[1] = a.count(1)

ans = 0
for X in range(1, 100000):
    num[(X % 3) - 2] = a.count(X + 1)
    ans = max(ans, sum(num))

print(ans)

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

num = [0 for i in range(100000)]
for aa in a:
    num[aa] += 1

ans = 0
for X in range(1, 99999):
    ans = max(ans, sum(num[X - 1 : X + 2]))

print(ans)


N = int(input())
plist = list(map(int, input().split()))
ans = 0
for i in range(N):
    if plist[i] == i + 1:
        plist[i], plist[i + 1] = plist[i + 1], plist[i]
        ans += 1
if plist[-1] == N:
    ans += 1
print(ans)

N = int(input())
plist = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
    if plist[i] == i + 1:
        plist[i], plist[i + 1] = plist[i + 1], plist[i]
        ans += 1
if plist[-1] == N:
    ans += 1
print(ans)


N = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(N):
    if p[i] == i + 1:
        ans += 1
        p[i], p[i + 1] = p[i + 1], p[i]
if p[-1] == N:
    ans += 1
print(ans)

N = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
    if p[i] == i + 1:
        ans += 1
        p[i], p[i + 1] = p[i + 1], p[i]
if p[-1] == N:
    ans += 1
print(ans)


N = int(input())
p = list(map(int, input().split()))
# print(p)
count = 0
for i in range(len(p)):
    # print(p[i])
    if i + 1 == p[i]:
        tmp = p[i]
        p[i] = p[i + 1]
        p[i + 1] = tmp
        count += 1
print(count)

N = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(len(p)):
    if i + 1 == p[i]:
        if i + 1 != len(p):
            tmp = p[i]
            p[i] = p[i + 1]
            p[i + 1] = tmp
            count += 1
        else:
            tmp = p[i]
            p[i] = p[i - 1]
            p[i - 1] = tmp
            count += 1

print(count)


def resolve():
    n = int(input())
    p = list(map(int, input().split()))
    ans = 0
    while any(i + 1 == p[i] for i in range(n)):
        for i in range(n - 1):
            if i + 1 == p[i]:
                p[i], p[i + 1] = p[i + 1], p[i]
                ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()

def resolve():
    n = int(input())
    p = list(map(int, input().split()))
    ans = 0
    if p[0] == 1:
        p[0], p[1] = p[1], p[0]
        ans += 1
    if p[n - 1] == n:
        p[n - 2], p[n - 1] = p[n - 1], p[n - 2]
        ans += 1
    for i in range(n - 1):
        if p[i] == i + 1:
            p[i], p[i + 1] = p[i + 1], p[i]
            ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()


n = int(input())
b = list(range(n**2))
a = list(map(int, input().split()))
flg = False
cnt = 0
for i, v in enumerate(a, 1):
    if flg:
        flg = False
        continue

    if i is v:
        cnt += 1
        flg = True
print(cnt)

n = int(input())
a = list(map(int, input().split()))
flg = False
cnt = 0
for i, v in enumerate(a, 1):
    if flg:
        flg = False
        continue

    if i == v:
        cnt += 1
        flg = True
print(cnt)


#!/usr/bin/env python3

N = int(input().split()[0])
p_list = list(map(int, input().split()))
count = 0
for i in range(N):
    index = i + 1
    if index == p_list[i]:
        if i != 0 and i != 1:
            if p_list[i + 1] == index + 1:
                p_list[i] = p_list[i + 1]
                p_list[i + 1] = index
            else:
                p_list[i] = p_list[i - 1]
                p_list[i - 1] = index
        elif i != 0:
            p_list[i] = p_list[i - 1]
            p_list[i - 1] = index
        elif i != 1:
            p_list[i] = p_list[i + 1]
            p_list[i + 1] = index

        count += 1

ans = count
print(ans)

#!/usr/bin/env python3

N = int(input().split()[0])
p_list = list(map(int, input().split()))
count = 0
for i in range(N):
    index = i + 1
    if index == p_list[i]:
        if i != 0 and i != N - 1:
            if p_list[i + 1] == index + 1:
                p_list[i] = p_list[i + 1]
                p_list[i + 1] = index
            else:
                p_list[i] = p_list[i - 1]
                p_list[i - 1] = index
        elif i != 0:
            p_list[i] = p_list[i - 1]
            p_list[i - 1] = index
        elif i != N - 1:
            p_list[i] = p_list[i + 1]
            p_list[i + 1] = index

        count += 1

ans = count
print(ans)


def main():
    N = int(input())
    P = map(int, input().split())
    cnt = 0
    for i in range(N):
        if P[i] == i + 1:
            cnt += 1
        ans = (cnt + 1) // 2
    print(ans)

if __name__ == "__main__":
    main()

def main():
    N = int(input())
    P = list(map(int, input().split()))
    cnt = 0
    for i in range(N - 1):
        if P[i] == i + 1:
            cnt += 1
            P[i + 1], P[i] = P[i], P[i + 1]
    if P[N - 1] == N:
        cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03612/Python/s310758336.py", line 13, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03612/Python/s310758336.py", line 6, in main
    if P[i] == i + 1:
TypeError: 'map' object is not subscriptable


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

ans = 0
for i in range(N):
    if P[i] == i + 1:
        P[i], P[i + 1] = P[i + 1], P[i]
        ans += 1
print(ans)

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

ans = 0

for i in range(N):
    if P[i] == i + 1:
        if i + 1 < N:
            P[i], P[i + 1] = P[i + 1], P[i]
        ans += 1
print(ans)


n = int(input())
p = [0] + list(map(int, input().split()))
num = 0
for i in range(1, n + 1):
    if i == p[i]:
        num += 1
        p[i], p[i + 1] = p[i + 1], p[i]

print(num)

n = int(input())
p = [0] + list(map(int, input().split()))
num = 0
for i in range(1, n + 1):
    if i == n:
        if i == p[i]:
            num += 1
            break
    if i == p[i]:
        num += 1
        p[i], p[i + 1] = p[i + 1], p[i]

print(num)


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

res = 0
for i in range(N):
    if P[i] == i + 1:
        res += 1
        if i < N:
            P[i], P[i + 1] = P[i + 1], P[i]

print(res)

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

res = 0
for i in range(N):
    if P[i] == i + 1:
        res += 1
        if i < N - 1:
            P[i], P[i + 1] = P[i + 1], P[i]

print(res)


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

ans = 0
# print(P)

for i in range(N):
    if P[i] != int(i + 1):
        continue
    else:
        P[i], P[i + 1] = P[i + 1], P[i]
        # print(i + 1, P)
        ans += 1

print(ans)

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

ans = 0
# print(P)

for i in range(N - 1):
    if P[i] != int(i + 1):
        continue
    else:
        P[i], P[i + 1] = P[i + 1], P[i]
        # print(i + 1, P)
        ans += 1

# 最後を見てなかった！！！！
if P[-1] == N:
    ans += 1

print(ans)


n = int(input())
a = list(map(int, input().split()))
b = [i + 1 for i in a]
c = [i - 1 for i in a]
use_set = set(a) | set(b) | set(c)
ans = 0
for i in use_set:
    ans = max(ans, a.count(i) + b.count(i) + c.count(i))
print(ans)

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

"""
b = [i + 1 for i in a]
c = [i - 1 for i in a]
use_set = set(a) | set(b) | set(c)
ans = 0
for i in use_set:
    ans = max(ans, a.count(i) + b.count(i) + c.count(i))
print(ans)
"""
# これだと最後でTLE
# inの段階でhash?

ans = {}
for i in a:
    for j in range(3):
        if i + j - 1 not in ans:
            ans[i + j - 1] = 1
        else:
            ans[i + j - 1] += 1

print(max(ans.values()))


def main(q: int, h: int, s: int, d: int, n: int):
    print((n // 2) * min(q * 8, h * 4, s * 2, d) + (n % 2) * min(q * 4, h * 2, s))

if __name__ == "__main__":
    q, h, s, d = map(int, input().split())
    n = int(input)

    main(q, h, s, d, n)

def main(q: int, h: int, s: int, d: int, n: int):
    print((n // 2) * min(q * 8, h * 4, s * 2, d) + (n % 2) * min(q * 4, h * 2, s))

if __name__ == "__main__":
    q, h, s, d = map(int, input().split())
    n = int(input())

    main(q, h, s, d, n)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03617/Python/s356966481.py", line 7, in <module>
    n = int(input)
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'builtin_function_or_method'


Q, H, S, D = map(int, input().split())
N = int(input())

p025 = Q
p05 = min(H, p025 * 2)
p1 = min(S, p05 * 2)
p2 = min(D, p1 * 2)

ans = 0
while N > 0:
    if N >= 2:
        N -= 2
        ans += p2
    elif N >= 1:
        N -= 1
        ans += p1

print(ans)


s = input()

count = 1

alphabets = {}

alphabets[s[0]] = 1

for i in range(1, len(s)):
    ss = s[0:i]
    for char, char_count in alphabets.items():
        if char != s[i]:
            count += char_count

    if s[i] in alphabets:
        alphabets[s[i]] += 1
    else:
        alphabets[s[i]] = 1

print(count)

s = input()

count = 1

alphabets = {}

alphabets[s[0]] = 1

for i in range(1, len(s)):
    for char, char_count in alphabets.items():
        if char != s[i]:
            count += char_count

    if s[i] in alphabets:
        alphabets[s[i]] += 1
    else:
        alphabets[s[i]] = 1

print(count)


import operator
from bisect import bisect_left
from math import pi
import decimal

def lis(A):
    L = [A[0]]
    for a in A[1:]:
        if a > L[-1]:
            L.append(a)
        else:
            L[bisect_left(L, a)] = a
    return len(L)

def solve():
    x1, y1, x2, y2 = map(int, input().split())
    if x1 > x2:
        x1, y1, x2, y2 = x2, y2, x1, y1
    is_down = y1 > y2
    if is_down:
        y1, y2 = -y1, -y2

    n = int(input())
    fountains = []
    for _ in range(n):
        x, y = map(int, input().split())
        if is_down:
            y = -y
        if x < x1 or x2 < x or y < y1 or y2 < y:
            continue
        fountains.append((x, y))
    fountains.sort()

    if x1 == x2:
        base = (y2 - y1) * 100
        for x, y in fountains:
            if x == x1:
                if y1 < y < y2:
                    return base + 10 * pi - 20
                else:
                    break
        return base
    if y1 == y2:
        base = (x2 - x1) * 100
        for x, y in fountains:
            if y == y1:
                if x1 < x < x2:
                    return base + 10 * pi - 20
                else:
                    break
        return base

    fountains_y = list(map(operator.itemgetter(1), fountains))
    mc = lis(fountains_y)
    dpi = decimal.Decimal(pi)
    base = decimal.Decimal((x2 - x1 + y2 - y1) * 100 - mc * 20)

    return str(base + mc * 5 * dpi)

print(solve())

import operator
from bisect import bisect_left
from math import pi
import decimal

def lis(A):
    L = [A[0]]
    for a in A[1:]:
        if a > L[-1]:
            L.append(a)
        else:
            L[bisect_left(L, a)] = a
    return len(L)

def solve():
    x1, y1, x2, y2 = map(int, input().split())
    if x1 > x2:
        x1, y1, x2, y2 = x2, y2, x1, y1
    is_down = y1 > y2
    if is_down:
        y1, y2 = -y1, -y2
    base = decimal.Decimal(100) * (x2 - x1 + y2 - y1)

    n = int(input())
    fountains = []
    for _ in range(n):
        x, y = map(int, input().split())
        if is_down:
            y = -y
        if x < x1 or x2 < x or y < y1 or y2 < y:
            continue
        fountains.append((x, y))

    if not fountains:
        return str(base)

    dpi = decimal.Decimal(pi)

    fountains.sort()
    fountains_y = list(map(operator.itemgetter(1), fountains))
    mc = lis(fountains_y)
    if mc == min(x2 - x1, y2 - y1) + 1:
        dist = base + (dpi * 5 - 20) * (mc - 1) + dpi * 10 - 20
    else:
        dist = base + (dpi * 5 - 20) * mc
    return str(dist)

print(solve())


import string

S = list(map(str, input()))
s = sorted(set(S))

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")

else:
    for i in range(30):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break

import string

S = list(map(str, input()))
s = sorted(set(S))
count = 0

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")

else:
    for i in range(len(s)):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break
        else:
            count += 1

if count == len(s):
    print(alphabet[len(s)])


s = sorted(set(input()))

ans = "None"
for i in range(26):
    a = chr(ord("a") + i)
    if s[i] != a:
        ans = a
        break
print(ans)

s = sorted(set(input()))

alphabet = [chr(ord("a") + i) for i in range(26)]
ans = "None"
for actual, expected in zip(s, alphabet):
    if actual != expected:
        ans = expected
        break

if ans == "None" and s[len(s) - 1] != "z":
    ans = alphabet[len(s)]
print(ans)


S = list(input())
L = len(S)
Slist = set()
for i in range(L):
    Slist.add(ord(S[i]))
Slist = list(Slist)
Slist.sort()
j = 97
ok = 0
for i in range(L):
    if Slist[i] == j:
        j += 1
        continue
    ans = chr(j)
    ok = 1
    break
if len(Slist) == 26:
    ans = "None"
elif ok == 0:
    ans = chr(j)
print(ans)

S = list(input())
L = len(S)
Slist = set()
for i in range(L):
    Slist.add(ord(S[i]))
Slist = list(Slist)
Slist.sort()
ans = "None"
j = 0
L = len(Slist)
for i in range(97, 123):
    if Slist[j] == i:
        j += 1
        if j >= L and i + 1 < 123:
            ans = chr(i + 1)
            break
        continue
    ans = chr(i)
    break
print(ans)


alpha = list("abcdefghijklmnopqrstuvwxyz")
s = input()

found = False
for chr in s:
    del alpha[alpha.index(chr)]

if len(alpha) == 0:
    print("None")
else:
    print(alpha[0])

alpha = list("abcdefghijklmnopqrstuvwxyz")
s = input()

found = False
for chr in s:
    if chr in alpha:
        del alpha[alpha.index(chr)]

if len(alpha) == 0:
    print("None")
else:
    print(alpha[0])

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03624/Python/s990496018.py", line 6, in <module>
    del alpha[alpha.index(chr)]
ValueError: 'r' is not in list


N = int(input())

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

A.sort()

s1 = 0
s2 = 0

t = -1
for a in A:
    if a != t:
        ac = A.count(a)
        if ac >= 4:
            s1 = a
            s2 = a
        elif ac >= 2:
            s2 = s1
            s1 = a

    t = a

print(s1 * s2)

N = int(input())

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

A.sort()

s1 = 0
s2 = 0

at = -1
atc = 0

for a in A:
    if at == a:
        atc += 1

    else:
        if atc >= 4:
            s1 = at
            s2 = at
        elif atc >= 2:
            s2 = s1
            s1 = at

        at = a
        atc = 1

if atc >= 4:
    s1 = at
    s2 = at
elif atc >= 2:
    s2 = s1
    s1 = at

print(s1 * s2)


n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
swi = 0
s = [0, 0]
i = 0
while i < len(a):
    if a[i] == a[i + 1]:
        s[swi] = a[i]
        i += 1
        swi += 1
        if swi == 2:
            break
    i += 1

print(s[0] * s[1])

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
swi = 0
s = [0, 0]
i = 0
while i < len(a) - 1:
    if a[i] == a[i + 1]:
        s[swi] = a[i]
        i += 1
        swi += 1
        if swi == 2:
            break
    i += 1

print(s[0] * s[1])


N = int(input())
A = sorted(list(map(int, input().split())))[::-1]
l1, l2 = 0, 0
flag = True
for i in range(N - 1):
    if A[i] > A[i + 1]:
        flag = True
        pass
    elif l1 == 0:
        l1 = A[i]
        flag = False
    elif l2 == 0 and flag:
        l2 = A[i]
        break
    else:
        flag = True

print(l1 * l2)


def main():
    N = int(input())
    A = sorted(list(map(int, input().split())), reverse=True)
    i = 0
    d = []
    while N - 1 > i:
        if len(d) == 2:
            break
        if A[i] == A[i + 1]:
            d.append(A[i])
            i += 1
        i += 1
    print(d[0] * d[1])

main()

def main():
    N = int(input())
    A = sorted(list(map(int, input().split())), reverse=True)
    i = 0
    d = []
    while N - 1 > i:
        if len(d) == 2:
            break
        if A[i] == A[i + 1]:
            d.append(A[i])
            i += 1
        i += 1
    if len(d) == 2:
        print(d[0] * d[1])
    else:
        print(0)

main()


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

b = 0
c = 0
while a:
    if a.pop() in a:
        if b == 0:
            b = a.pop()
        elif c == 0:
            c = a.pop()
        else:
            break
print(b * c)

from collections import Counter

n = int(input())
c = Counter(map(int, input().split()))
h = w = 0
for k, v in c.items():
    if v >= 2 and k > w:
        if k > h:
            if v >= 4:
                h = k
                w = k
            else:
                w = h
                h = k
        else:
            w = k
print(h * w)


n = int(input())
a = list(map(int, input().split()))
uniq_a = sorted(list(set(a)), reverse=True)
c = 0
ans = 1
for num in uniq_a:
    if c == 0 and a.count(num) >= 4:
        print(num**2)
        exit()
    if a.count(num) >= 2:
        c += 1
        ans *= num
        if c == 2:
            print(ans)
            exit()
print(0)

n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)

flag = True
pairs = []
for i in range(1, len(a)):
    if flag:
        if a[i] == a[i - 1]:
            pairs.append(a[i])
            if len(pairs) == 2:
                print(pairs[0] * pairs[1])
                exit()
            flag = False
    else:
        flag = True
print(0)


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

a_list = sorted(a_list, reverse=True)
a_set = set(a_list)
a_dict = {}
sorted_dict = {}

ans_big = 0
ans_small = 0

for i in a_set:
    a_dict[i] = a_list.count(i)

for k, v in sorted(a_dict.items(), key=lambda x: -x[0]):
    if v >= 4:
        if ans_big < k:
            ans_big = k
        if ans_small < k:
            ans_small = k
    elif v >= 2:
        if ans_big < k:
            ans_big = k
        elif ans_small < k:
            ans_small = k
print(ans_small * ans_big)

from collections import Counter

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

# 要素数の数え上げと取り出し
num_counter = Counter(a_list)
num_keys = sorted(num_counter.keys(), reverse=True)

big = 0
small = 0

for i in num_keys:
    x = num_counter[i]
    if x >= 4:
        if big == 0:
            big = small = i
        elif big != 0 and small == 0:
            small = i
    elif x == 3 or x == 2:
        if big == 0:
            big = i
        elif big != 0 and small == 0:
            small = i
    if big != 0 and small != 0:
        break
print(big * small)


cou = int(input())
bars = input().split()
two = [0, 0]
i = 0
ca = len(bars)
while i < ca:
    if bars[i] in two:
        pass
    else:
        if bars.count(bars[i]) > 3:
            two.extend(bars[i])
            two.extend(bars[i])
        elif bars.count(bars[i]) > 1:
            two.extend(bars[i])
        else:
            pass
    i += 1
two.sort(key=int)
print(int(two[-1]) * int(two[-2]))

n = input()
a = list(map(int, input().split()))
a.sort()
h, w = 0, 0
while True:
    try:
        if a[-1] == a[-2]:
            h = a[-1]
            a.pop()
            a.pop()
            break
        else:
            a.pop()
    except:
        break

while True:
    try:
        if a[-1] == a[-2]:
            w = a[-1]
            a.pop()
            a.pop()
            break
        else:
            a.pop()
    except:
        break
print(h * w)


N = int(input())
S1 = list(input())
S2 = list(input())

if len(S1) == 1:
    print(3)
else:
    if S1[0] != S2[0]:
        t = 2
        i = 2
        a = 6
    else:
        t = 1
        i = 1
        a = 3
    while True:
        if S1[i] != S2[i]:
            if t == 2:
                a *= 3
            else:
                a *= 2
            i += 2
            t = 2
        else:
            if t == 2:
                a *= 1
            else:
                a *= 2
            i += 1
            t = 1
        a %= 1000000007
        if i == len(S1):
            print(a)
            break

N = int(input())
S1 = list(input())
S2 = list(input())

if len(S1) == 1:
    print(3)
elif len(S1) == 2:
    print(6)
else:
    if S1[0] != S2[0]:
        t = 2
        i = 2
        a = 6
    else:
        t = 1
        i = 1
        a = 3
    while True:
        if S1[i] != S2[i]:
            if t == 2:
                a *= 3
            else:
                a *= 2
            i += 2
            t = 2
        else:
            if t == 2:
                a *= 1
            else:
                a *= 2
            i += 1
            t = 1
        a %= 1000000007
        if i == len(S1):
            print(a)
            break


from collections import Counter

N = int(input())
c = Counter(map(int, input().split()))
usables = sorted([(k, v) for k, v in c.items() if v >= 2])
if len(usables) <= 1:
    print(0)
else:
    if usables[-1][2] >= 4:
        print(usables[-1][1] ** 2)
    else:
        print(usables[-1][1] * usables[-2][1])

from collections import Counter

N = int(input())
c = Counter(map(int, input().split()))
usables = sorted([(k, v) for k, v in c.items() if v >= 2])
if len(usables) <= 1:
    print(0)
else:
    if usables[-1][1] >= 4:
        print(usables[-1][0] ** 2)
    else:
        print(usables[-1][0] * usables[-2][0])

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03627/Python/s435712312.py", line 10, in <module>
    if usables[-1][2] >= 4:
IndexError: tuple index out of range


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

res = [0]
tmp = -1
for a in A:
    if a == tmp:
        res.append(a)
        tmp = -1
    else:
        tmp = a
    if len(res) > 2:
        break

res = sorted(res, reverse=True)

result = 1
for i in range(2):
    result *= res[i]

print(result)

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

res = [0, 0]
tmp = -1
for a in A:
    if a == tmp:
        res.append(a)
        tmp = -1
    else:
        tmp = a
    if len(res) >= 4:
        break

res = sorted(res, reverse=True)

result = 1
for i in range(2):
    result *= res[i]

print(result)


import collections
import sys

N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
two = [k for k, v in c.items() if v > 1]
four = [k for k, v in c.items() if v > 3]
if len(two) < 2 and not four:
    print(0)
    sys.exit(0)
two.sort(reverse=True)
four.sort(reverse=True)
tmp = 1
for i in range(2):
    tmp *= two[i]
max_four = max(four)
print(tmp if tmp > max_four else max_four)

import collections
import sys

N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
two = [k for k, v in c.items() if v > 1]
four = [k for k, v in c.items() if v > 3]
if len(two) < 2 and not four:
    print(0)
    sys.exit(0)

St = 0
Sf = 0
if two:
    two.sort(reverse=True)
    St = 1
    for i in range(2):
        St *= two[i]
if four:
    Sf = max(four) ** 2
print(St if St > Sf else Sf)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03627/Python/s133994662.py", line 17, in <module>
    max_four = max(four)
ValueError: max() arg is an empty sequence


n = input()
if n(0) == n(2):
    print("Yes")
else:
    print("No")

n = input()
if n[0] == n[2]:
    print("Yes")
else:
    print("No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03631/Python/s893236770.py", line 2, in <module>
    if n(0) == n(2):
TypeError: 'str' object is not callable


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

print(max(min(b, d) - max(a, c)), 0)

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

print(max(min(b, d) - max(a, c), 0))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03632/Python/s806396854.py", line 3, in <module>
    print(max(min(b, d) - max(a, c)), 0)
TypeError: 'int' object is not iterable


A, B, C, D = map(int, input().split())

if A <= C:
    print(max(min(B, D) - C), 0)
else:
    print(max(min(B, D) - A), 0)

A, B, C, D = map(int, input().split())

if A <= C:
    print(max(min(B, D) - C, 0))
else:
    print(max(min(B, D) - A, 0))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03632/Python/s956331170.py", line 4, in <module>
    print(max(min(B, D) - C), 0)
TypeError: 'int' object is not iterable


import math

def lcm(a, b):
    return a * b // math.gcd(a, b)

N = int(input())
T = [int(input()) for _ in range(N)]
tmp = 1
for i in range(N):
    tmp = lcm(tmp, T[i])
print(tmp)

import fractions

def lcm(a, b):
    n = fractions.gcd(a, b)
    return a * b // n if n > 0 else 0

N = int(input())
T = [int(input()) for _ in range(N)]
tmp = 1
for i in range(N):
    tmp = lcm(tmp, T[i])
print(tmp)


from math import gcd
from functools import reduce

def lcm_base(a, b):
    return (a * b) // gcd(a, b)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
T = []

for _ in range(n):
    T.append(int(input()))

print(lcm(*T))

from functools import reduce

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

def lcm_base(a, b):
    return a * b // gcd(a, b)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
T = []

for _ in range(n):
    T.append(int(input()))

print(lcm(*T))


N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a, b):
    if a > b:
        g = gcd(a, b)
        return int(a / g * b)
    else:
        g = gcd(b, a)
        return int(b / g * a)

x = T[0]
for i in range(1, N):
    x = lcm(x, T[i])

print(x)

from functools import reduce

N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a, b):
    if b > a:
        b, a = a, b
    return a * b // gcd(a, b)

x = reduce(lcm, T)
print(x)


from math import gcd

n = int(input())

def lcm(a, b):
    return a * b // gcd(a, b)

ans = 1
for _ in range(n):
    t = int(input())
    ans = lcm(ans, t)

print(ans)

from fractions import gcd

n = int(input())

def lcm(a, b):
    return a * b // gcd(a, b)

ans = 1
for _ in range(n):
    t = int(input())
    ans = lcm(ans, t)

print(ans)


import math
from functools import reduce

n = int(input())
t = [int(input()) for _ in range(n)]

ans = reduce(lambda x, y: x * y // math.gcd(x, y), t)
print(ans)

import fractions
from functools import reduce

n = int(input())
t = [int(input()) for _ in range(n)]

ans = reduce(lambda x, y: x * y // fractions.gcd(x, y), t)
print(ans)


from functools import reduce
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

N = int(input())
T = [int(input()) for _ in range(N)]
print(reduce(lcm, T, 1))

from functools import reduce
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

N = int(input())
T = [int(input()) for _ in range(N)]
print(reduce(lcm, T, 1))


N = int(input())
lst = [int(input()) for _ in range(N)]

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

def lcm(x, y):
    return x * y // gcd(max(x, y), min(x, y))

ret = lcm(lst[0], lst[1])
for x in lst[2:]:
    ret = lcm(ret, x)
print(ret)

N = int(input())
lst = [1] + [int(input()) for _ in range(N)]

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

def lcm(x, y):
    return x * y // gcd(max(x, y), min(x, y))

ret = lcm(lst[0], lst[1])
for x in lst[2:]:
    ret = lcm(ret, x)
print(ret)


import math

N = int(input())
T = [int(input()) for n in range(N)]

def lcm(a, b):
    return a * b // math.gcd(a, b)

res = T[0]
for t in T:
    res = lcm(res, t)

print(res)

N = int(input())
T = [int(input()) for n in range(N)]

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

def lcm(a, b):
    return a * b // gcd(a, b)

res = T[0]
for t in T:
    res = lcm(res, t)

print(res)


import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

N = int(input())
t_li = []
for _ in range(N):
    t_li.append(int(input()))
ans = lcm(t_li[0], t_li[1])
for i in range(2, N):
    ans = lcm(ans, t_li[i])
print(ans)

import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

N = int(input())
t_li = []
for _ in range(N):
    t_li.append(int(input()))
if N > 1:
    ans = lcm(t_li[0], t_li[1])
    for i in range(2, N):
        ans = lcm(ans, t_li[i])
else:
    ans = t_li[0]
print(ans)


# -*- coding: utf-8 -*-

from numpy import lcm

n = int(input())
t = [int(input()) for _ in range(n)]

ans = 1
for ele in t:
    ans = lcm(ans, ele)

print(ans)

# -*- coding: utf-8 -*-

def gcd(x, y):
    while x % y:
        x, y = y, x % y
    return y

def lcm(x, y):
    return x * y // gcd(x, y)

n = int(input())
t = [int(input()) for _ in range(n)]

ans = 1
for ele in t:
    ans = lcm(ans, ele)

print(ans)


import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N = int(input())
t1 = int(input())
t2 = int(input())
t = lcm(t1, t2)
for _ in range(2, N):
    t = lcm(t, int(input()))
print(t)

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N = int(input())
if N == 1:
    print(input())
else:
    t1 = int(input())
    t2 = int(input())
    t = lcm(t1, t2)
    for _ in range(2, N):
        t = lcm(t, int(input()))
    print(t)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03633/Python/s647754029.py", line 11, in <module>
    t = lcm(t1, t2)
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03633/Python/s647754029.py", line 5, in lcm
    return (x * y) // fractions.gcd(x, y)
AttributeError: module 'fractions' has no attribute 'gcd'


import numpy as np

n = int(input())

t = [int(input()) for _ in range(n)]

print(np.lcm.reduce(np.array(t)))

from fractions import gcd

n = int(input())

t = [int(input()) for _ in range(n)]

ans = t[0]
for i in range(1, n):
    ans = ans * t[i] // gcd(ans, t[i])
print(ans)


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a, b):
    return int(a * b / gcd(max(a, b), min(a, b)))

N = int(input())
T = [int(input()) for i in range(N)]

A = T[0]
for i in range(N):
    A = lcm(A, T[i])
print(A)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(max(a, b), min(a, b))

N = int(input())
T = [int(input()) for i in range(N)]

A = T[0]
for i in range(N):
    A = lcm(A, T[i])
print(A)


N = int(input())
T = [int(input()) for i in range(N)]
T.sort()
T.reverse()
result = T[0]

for i in range(1, N):
    a = 1
    while True:
        if (result * a) % T[i] == 0:
            result *= a
            break
        a += 1

print(result)

N = int(input())
T = [int(input()) for i in range(N)]
result = T[0]

for i in range(1, N):
    n = T[i]
    m = result
    while n % m != 0:
        m, n = n % m, m
    result = (result * T[i]) // m

print(result)


import math

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

ans = t[0]
for ti in t:
    ans = ans * ti // math.gcd(ans, ti)

print(ans)

import fractions

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

ans = t[0]
for ti in t:
    ans = ans * ti // fractions.gcd(ans, ti)

print(ans)


N = int(input())
cycles = [int(input()) for i in range(N)]

x = 1
M = max(cycles)
while 1:
    for num in cycles:
        if (M * x) % num != 0:
            x += 1
            break
    else:
        print(M * x)
        quit()

def GCD(x: int, y: int):
    if x < y:
        x, y = y, x

    if x % y == 0:
        return y
    else:
        return GCD(y, x % y)

def LCM(x: int, y: int):
    return x * y // GCD(x, y)

N = int(input())
Tlist = [int(input()) for i in range(N)]
ans = 1
for num in Tlist:
    ans = LCM(ans, num)
print(ans)


import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
t = list(set([int(input()) for _ in range(n)]))

print(lcm(*t))

import fractions

n = int(input())
a = 1

for b in range(n):
    b = int(input())
    a = a * b // fractions.gcd(a, b)
print(a)


from math import gcd
from functools import reduce

def lcm(a, b):
    return (a * b) // gcd(a, b)

N = int(input())
T = list(int(input()) for _ in range(N))

print(reduce(lcm, T))

from fractions import gcd
from functools import reduce

def lcm(a, b):
    return (a * b) // gcd(a, b)

N = int(input())
T = list(int(input()) for _ in range(N))

print(reduce(lcm, T))


from math import gcd
from functools import reduce

def resolve():
    n = int(input())
    t = list(int(input()) for _ in range(n))
    res = 1
    for ti in t:
        res = lcm_base(res, ti)
    print(res)

def lcm_base(x, y):
    return x * y // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

if __name__ == "__main__":
    resolve()

from fractions import gcd
from functools import reduce

def resolve():
    n = int(input())
    t = list(int(input()) for _ in range(n))
    res = 1
    for ti in t:
        res = lcm_base(res, ti)
    print(res)

def lcm_base(x, y):
    return x * y // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

if __name__ == "__main__":
    resolve()


import sys

sys.setrecursionlimit(1000001)

N = int(input())
D = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    D[a].append((b, c))
    D[b].append((a, c))
Q, K = map(int, input().split())
DS = [-1] * (N + 2)

def dfs(c, p, d):
    DS[c] = d
    for r in D[c]:
        if r[0] == p:
            continue
        dfs(r[0], c, d + r[1])

def main():
    dfs(K - 1, -1, 0)
    for _ in range(Q):
        x, y = map(int, input().split())
        print(DS[x - 1] + DS[y - 1])

main()


n, m = map(int, input())
print((n - 1) * (m - 1))

n, m = map(int, input().split())
print((n - 1) * (m - 1))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03635/Python/s631153988.py", line 1, in <module>
    n, m = map(int, input())
ValueError: invalid literal for int() with base 10: ' '


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03636/Python/s904035793.py", line 3, in <module>
    print(s[0] + len(s[1:-1]) + s[-1])
TypeError: can only concatenate str (not "int") to str


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

result = [[None] * W for _ in range(H)]
d = 1
x, y = 0, 0
for i in range(N):
    t = a[i]
    while t > 0:
        result[y][x] = i + 1
        if x == 0 or x == W - 1:
            d = -d
            y += 1
        else:
            x += d
        t -= 1

for i in range(H):
    print(*result[i])

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

result = [[None] * W for _ in range(H)]
d = 1
x, y = 0, 0
for i in range(N):
    t = a[i]
    while t > 0:
        result[y][x] = i + 1
        x += d
        if x == -1 or x == W:
            x -= d
            d = -d
            y += 1
        t -= 1

for i in range(H):
    print(*result[i])

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03638/Python/s838608670.py", line 11, in <module>
    result[y][x] = i + 1
IndexError: list index out of range


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

L = sorted(L, reverse=True)

print(sum(L[:K]))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03643/Python/s548681311.py", line 1, in <module>
    N, K = map(int, input().split())
ValueError: not enough values to unpack (expected 2, got 1)


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03643/Python/s236213679.py", line 3, in <module>
    print("ABC" + n)
TypeError: can only concatenate str (not "int") to str


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03643/Python/s594169915.py", line 2, in <module>
    print(int(n[3:]))
ValueError: invalid literal for int() with base 10: ''


n = int(input())
cnt_list = []
for i in range(1, n):
    cnt = 0
    while i % 2 == 0:
        i = i / 2
        cnt += 1
    cnt_list.append(cnt)
print(max(cnt_list))

n = int(input())
cnt_list = []
for i in range(1, n + 1):
    cnt = 0
    while i % 2 == 0:
        i = i / 2
        cnt += 1
    cnt_list.append(cnt)
print(2 ** max(cnt_list))


""" AtCoder """

N = int(input())
ans_list = [2, 4, 8, 16, 32, 64]
ans_list = ans_list[::-1]

if N == 1:
    print(1)

for i in range(7):
    if N > ans_list[i]:
        print(ans_list[i])
        break

""" AtCoder """

N = int(input())
ans_list = [2, 4, 8, 16, 32, 64]
ans_list = ans_list[::-1]

if N == 1:
    print(1)
    exit()

for i in range(7):
    if N >= ans_list[i]:
        print(ans_list[i])
        break


import sys

N = int(sys.stdin.readline())

sorted_list = [1, 2, 4, 8, 16, 32, 64, N][::1]
min_index = sorted_list[sorted_list.index(N) + 1]
print(min_index)

import sys

N = int(sys.stdin.readline())

if N in [1, 2, 4, 8, 16, 32, 64]:
    print(N)
else:
    sorted_list = sorted([1, 2, 4, 8, 16, 32, 64, N])[::-1]
    min_index = sorted_list[sorted_list.index(N) + 1]
    print(min_index)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03644/Python/s340201772.py", line 6, in <module>
    min_index = sorted_list[sorted_list.index(N) + 1]
IndexError: list index out of range


# https://atcoder.jp/contests/abc068/tasks/abc068_b

def two_factor(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x //= 2
    return cnt

N = int(input())
a = map(two_factor, range(1, N + 1))
max_cnt = max(a)
print(a.index(max_cnt) + 1)

# https://atcoder.jp/contests/abc068/tasks/abc068_b

def two_factor(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x //= 2
    return cnt

N = int(input())
a = list(map(two_factor, range(1, N + 1)))
max_cnt = max(a)
print(a.index(max_cnt) + 1)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03644/Python/s895004544.py", line 15, in <module>
    print(a.index(max_cnt) + 1)
AttributeError: 'map' object has no attribute 'index'


N = int(input())

if N == 1:
    print(0)
else:
    ans = 2
    while ans * 2 <= N:
        ans *= 2
print(ans)

N = int(input())

if N == 1:
    print(1)
else:
    ans = 2
    while ans * 2 <= N:
        ans *= 2
    print(ans)


import math

def resolve():
    n = int(input())
    print(2 ** int(math.log2(n)))

if __name__ == "__main__":
    resolve()

def resolve():
    n = int(input())
    ans = 0
    for i in range(2, n + 1, 2):
        c = 0
        while i % 2 == 0:
            i //= 2
            c += 1
        if c > ans:
            ans = c
    print(2**ans)

if __name__ == "__main__":
    resolve()


def main():
    n, m = map(int, input().split())

    islands_to_1 = []
    islands_to_n = []
    for _ in range(m):
        boat = list(map(int, input().split()))
        if 1 in boat:
            islands_to_1.append(max(boat))

        if n in boat:
            islands_to_n.append(min(boat))

    for island_to_1 in islands_to_1:
        if island_to_1 in islands_to_n:
            print("POSSIBLE")
            return

    print("IMPOSSIBLE")
    return

if __name__ == "__main__":
    main()

def main():
    n, m = map(int, input().split())

    islands_to_1 = [0 for _ in range(n + 1)]
    islands_to_n = []
    for _ in range(m):
        boat = list(map(int, input().split()))
        if 1 in boat:
            islands_to_1[boat[1]] = 1

        if n in boat:
            islands_to_n.append(min(boat))

    for island_to_n in islands_to_n:
        if islands_to_1[island_to_n] == 1:
            print("POSSIBLE")
            return

    print("IMPOSSIBLE")
    return

if __name__ == "__main__":
    main()


N, M = map(int, input().split())
ab_list = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

lis = [[] for i in range(N)]

for i in range(M):
    lis[ab_list[i][0]].append(ab_list[i][1])

que = [[0, 0, lis[0], []]]
ends = []
res = False

while que:
    count, now, next_nodes, visited = que.pop()
    ends.append(visited)
    visited.append(now)
    for node in next_nodes:
        if node in visited or count == 2:
            continue
        que.append([count + 1, node, lis[node], visited[:]])

print()

if N - 1 in set(sum(ends, [])):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

N, M = map(int, input().split())
ab_list = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

lis = [[] for i in range(N)]

for i in range(M):
    lis[ab_list[i][0]].append(ab_list[i][1])

que = [[0, 0, lis[0], []]]
ends = []
res = False

while que:
    count, now, next_nodes, visited = que.pop()
    visited.append(now)
    if now == N - 1:
        ends = visited[:]
    for node in next_nodes:
        if node in visited or count == 2:
            continue
        que.append([count + 1, node, lis[node], visited[:]])

if N - 1 in ends:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


N, M = map(int, input().split())
a = [0 for i in range(M)]
b = [0 for i in range(M)]
c = []
for i in range(M):
    a[i], b[i] = map(int, input().split())
    if a[i] == 1:
        c.append(b[i])

flag = 0
for k in c:
    if k == N:
        flag = 1
        break
    else:
        for i in range(M):
            if a[i] == k and b[i] == N:
                flag = 1
                break
    if flag == 1:
        break

if flag == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

N, M = map(int, input().split())
a = [0 for i in range(M)]
b = [0 for i in range(M)]
c = []
d = []
flag = 0
for i in range(M):
    a[i], b[i] = map(int, input().split())
    if a[i] == 1:
        c.append(b[i])
        if b[i] == N:
            flag = 1
    if b[i] == N:
        d.append(a[i])
        if a[i] == 1:
            flag = 1
e = set(c) | set(d)
if len(c) + len(d) == len(e):
    flag = 0
else:
    flag = 1

if flag == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]
second = []
flag = False
for x in range(M):
    if ab[x][0] == 1:
        second.append(ab[x][1])

for y in range(len(second)):
    for z in range(M):
        if ab[z][0] == second[y] and ab[z][1] == N:
            flag = True
if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]
start = []
goal = []
flag = False
for x in range(M):
    if ab[x][0] == 1:
        start.append(ab[x][1])

    if ab[x][1] == N:
        goal.append(ab[x][0])

start_goal = set(start) & set(goal)

if start_goal:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


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

one2 = []
toN = []

for _ in range(M):
    a, b = map(int, input().split())

    if a == 1:
        one2.append(b)

    if b == N:
        toN.append(a)

flag = False
for a in one2:
    if a in toN:
        flag = True
        break

if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

one2 = set()
toN = set()

for _ in range(M):
    a, b = map(int, input().split())

    if a == 1:
        one2.add(b)

    if b == N:
        toN.add(a)

inter = one2 & toN

if len(inter) > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


# グラフわからんのでグラフアルゴリズム忘れた
# dfsでやる 限度2回

n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

def dfs(t, c, used):
    if c != 0 and t == n - 1:
        return True
    if c == 0:
        return False
    flag = False
    for g in graph[t]:
        if g in used:
            continue
        next_used = used[:]
        next_used.append(g)
        flag = dfs(g, c - 1, next_used)
        if flag:
            break
    return flag

for x in graph[0]:
    if dfs(x, 2, [x]):
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

# グラフわからんのでグラフアルゴリズム忘れた
# dfsでやる 限度2回c
# なんかしらんけどdfsが2TLEになるので諦めた それぞれの島について1とNがあれば良い

n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

for g in graph[1 : n - 1]:
    c = 0
    for v in g:
        if c >= 2:
            break
        if v == 0 or v == n - 1:
            c += 1
    if c == 2:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


n, m = map(int, input().split())
r = [[0, 0] for _ in range(m)]
ln = []
l1 = []
for i in range(m):
    r[i][0], r[i][1] = map(int, input().split())
    if r[i][1] == n:
        ln.append(i)
    if r[i][0] == 1:
        l1.append(i)
ans = "IMPOSSIBLE"
for i in l1:
    for j in ln:
        if r[i][1] == r[j][0]:
            ans = "POSSIBLE"
            break
print(ans)

n, m = map(int, input().split())
l = [0] * n
r = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        r.append(b)
    if b == n:
        l[a - 1] = 1
ans = "IMPOSSIBLE"
for i in r:
    if l[i - 1] == 1:
        ans = "POSSIBLE"
print(ans)


N, M = map(int, input().split())
s1 = set()
s2 = set()

for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        s1.add(b)
    if b == N:
        s2.add(a)

for x in s1:
    if s2.count(x) >= 1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

N, M = map(int, input().split())
s1 = set()
s2 = set()

for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        s1.add(b)
    if b == N:
        s2.add(a)

if len(s1.intersection(s2)) > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03645/Python/s877436493.py", line 13, in <module>
    if s2.count(x) >= 1:
AttributeError: 'set' object has no attribute 'count'


n, m = map(int, input().split())
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = map(int, input().split())

check = 0

for i in range(m):
    if a[i] == 1:
        check = b[i]
        for j in range(m):
            if a[j] == check and b[j] == n:
                print("POSSIBLE")
                exit()

print("IMPOSSIBLE")

n, m = map(int, input().split())
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = map(int, input().split())
"""
check = 0

for i in range(m):
    if a[i] == 1:
        check = b[i]
        for j in range(m):
            if a[j] == check and b[j] == n:
                print("POSSIBLE")
                exit()

print("IMPOSSIBLE")

"""
start = []
leave = []
for i in range(m):
    if a[i] == 1:
        start.append(b[i])
    elif b[i] == n:
        leave.append(a[i])

if set(start) & set(leave):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]

pot_starts = []
pot_ends = []

for i in a:
    if i[0] == 1:
        pot_starts.append(i[1])
    elif i[1] == n:
        pot_ends.append(i[0])

for i in set(pot_starts):
    if i in pot_ends:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]

# n, m = 3, 2
# a = [[1, 2], [2, 3]]

pot_starts = []
pot_ends = []

for i in a:
    if i[0] == 1:
        pot_starts.append(i[1])
    elif i[1] == n:
        pot_ends.append(i[0])

if set(pot_starts).intersection(pot_ends):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


n, m = map(int, input().split())
a = [input().split() for _ in range(m)]
A = set()
B = set()

for i in range(m):
    if a[i][0] == "1":
        A.add(a[i][1])
    if a[i][1] == str(n):
        B.add(a[i][0])
    if A & B:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

n, m = map(int, input().split())
a = [input().split() for _ in range(m)]
A = []
B = []

for i in range(m):
    if a[i][0] == "1":
        A.append(a[i][1])
    if a[i][1] == str(n):
        B.append(a[i][0])
print("POSSIBLE" if set(A) & set(B) else "IMPOSSIBLE")


N = int(input())
A = list(map(int, input().split()))
ans = 0
flag = True
while flag:
    flag = False
    for i in range(N):
        if A[i] >= N:
            count = A[i] // N
            ans += count
            for j in range(N):
                A[j] += count
            A[i] -= count
            A[i] %= N
            flag = True
            break

print(ans)

N = int(input())
A = list(map(int, input().split()))
ans = 0
flag = True
while flag:
    flag = False
    for i in range(N):
        if A[i] >= N:
            count = A[i] // N
            ans += count
            for j in range(N):
                A[j] += count
            A[i] -= count
            A[i] %= N
            flag = True

print(ans)


import functools
import math

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

if k > m:
    print("IMPOSSIBLE")
else:
    gcd = functools.reduce(math.gcd, a)
    if k % gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

import functools
import fractions

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

if k > m:
    print("IMPOSSIBLE")
else:
    gcd = functools.reduce(fractions.gcd, a)
    if k % gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


a, b = map(int, input().split())
array = list(map(int, input().split()))
impossible = "IMPOSSIBLE"
possible = "POSSIBLE"

if a == 1:
    if b == array[0]:
        print(possible)
    else:
        print(impossible)
    exit(0)

array = list(set(array))
array.sort()

btw = [v1 - v2 for v1, v2 in zip(array[1:], array[0:])]
n = sorted(btw)[0]

same = len(set(btw)) == 1 or all([v % n == 0 for v in btw])

if b in array:
    print(possible)
elif array[-1] < b:
    print(impossible)
elif same and (b - array[0]) % n == 0:
    print(possible)
else:
    print(impossible)

a, b = map(int, input().split())
array = list(map(int, input().split()))
impossible = "IMPOSSIBLE"
possible = "POSSIBLE"

array = list(set(array))

if len(array) == 1:
    if b == array[0]:
        print(possible)
    else:
        print(impossible)
    exit(0)

array.sort()

btw = [v1 - v2 for v1, v2 in zip(array[1:], array[0:])]
n = sorted(btw)[0]

same = len(set(btw)) == 1 or all([v % n == 0 for v in btw])

if b in array:
    print(possible)
elif array[-1] < b:
    print(impossible)
elif same and (b - array[0]) % n == 0:
    print(possible)
else:
    print(impossible)


#!/usr/bin/env python3
import copy

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

a_list = sorted(a_list)

def judge(w_list, k):
    w_list = sorted(w_list)

    for i in range(len(w_list) - 1):
        w_list += [abs(w_list[i] - w_list[i + 1])]

    w_list = sorted(list(set(w_list)))

    if k in w_list:
        return True, w_list
    elif 1 in w_list:
        return True, w_list
    elif abs(w_list[0] - w_list[-1]) < K:
        return False, w_list
    elif k % 2 == 0 and 2 in w_list:
        return True, w_list
    else:
        for w in w_list:
            if w + K in w_list:
                return True, w_list

        return False, w_list

w_list = a_list

while True:
    org_w_list = copy.copy(w_list)
    is_ok, w_list = judge(w_list, K)
    if is_ok:
        break
    else:
        if abs(w_list[0] - w_list[-1]) < K:
            break
        if w_list == org_w_list:
            break

ans = "POSSIBLE" if is_ok else "IMPOSSIBLE"

print(ans)

#!/usr/bin/env python3
import copy

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

a_list = sorted(a_list)

def judge(w_list, k):
    w_list = sorted(w_list)

    for i in range(len(w_list) - 1):
        w_list += [abs(w_list[i] - w_list[i + 1])]

    w_list = sorted(list(set(w_list)))

    if k in w_list:
        return True, w_list
    elif 1 in w_list:
        return True, w_list
    elif abs(w_list[0] - w_list[-1]) < K:
        return False, w_list
    elif k % 2 == 0 and 2 in w_list:
        return True, w_list
    else:
        ww_list = set([w + K for w in w_list])
        if ww_list & set(w_list):
            return True, w_list
        else:
            return False, w_list

w_list = a_list

while True:
    org_w_list = copy.copy(w_list)
    is_ok, w_list = judge(w_list, K)
    if is_ok:
        break
    else:
        if abs(w_list[0] - w_list[-1]) < K:
            break
        if w_list == org_w_list:
            break

ans = "POSSIBLE" if is_ok else "IMPOSSIBLE"

print(ans)


import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M, *A = map(int, read().split())
A = list(map(list, map(reversed, zip(*[iter(A)] * M))))

# 各スポーツに参加している人数
p = [0] * (M + 1)
canceled = set()
answer = []

def solve(s, n):
    # nは開催しているスポーツの数
    # sは新たに開催をやめるスポーツ
    p[s] = 0
    canceled.add(s)
    if n == M:
        for i in A:
            p[i[-1]] += 1
        p_max = max(p)
        answer.append(p_max)
        cancel = p.index(p_max)
        solve(cancel, n - 1)
    elif n == 1:
        answer.append(N)
    else:
        for i in range(N):
            if A[i][-1] in canceled:
                while A[i][-1] in canceled:
                    A[i].pop()
                p[A[i][-1]] += 1
        p_max = max(p)
        answer.append(p_max)
        cancel = p.index(p_max)
        solve(cancel, n - 1)

solve(0, M)
print(min(answer))

import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M, *A = map(int, read().split())
A = list(map(list, map(reversed, zip(*[iter(A)] * M))))

# 各スポーツに参加している人数
p = [0] * (M + 1)
canceled = set()
answer = []

def solve(s, n):
    # nは開催しているスポーツの数
    # sは新たに開催をやめるスポーツ
    if n == 1:
        answer.append(N)
    elif n == M:
        for i in A:
            p[i[-1]] += 1
        p_max = max(p)
        answer.append(p_max)
        cancel = p.index(p_max)
        solve(cancel, n - 1)
    else:
        canceled.add(s)
        p[s] = 0
        for i in range(N):
            if A[i][-1] in canceled:
                while A[i][-1] in canceled:
                    A[i].pop()
                p[A[i][-1]] += 1
        p_max = max(p)
        answer.append(p_max)
        cancel = p.index(p_max)
        solve(cancel, n - 1)

solve(0, M)
print(min(answer))


A, B = map(int, input().split())
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03657/Python/s777334457.py", line 1, in <module>
    print("Impossible" if sum(map(int, input.split())) % 3 else "Possible")
AttributeError: 'builtin_function_or_method' object has no attribute 'split'


K, N = map(int, input().split())
L = list(map(int, input().split())).sort(reverse=True)
print(sum(L[:K]))

N, K = map(int, input().split())
L = list(map(int, input().split()))
L.sort(reverse=True)
print(sum(L[:K]))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03658/Python/s266603109.py", line 3, in <module>
    print(sum(L[:K]))
TypeError: 'NoneType' object is not subscriptable


from itertools import combinations

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

ans = max([sum(combi) for combi in combinations(L, K)])
print(ans)

from itertools import combinations

N, K = map(int, input().split())
L = sorted(list(map(int, input().split())), reverse=True)
ans = sum(L[:K])
print(ans)


l1 = input().split()
a, b = list(map(int, l1))

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

l3 = sorted(l2)
sum = l3[-1] + l3[-2] + l3[-3]
print(sum)

l1 = input().split()
N, K = map(int, l1)
max = K + 1
l2 = input().split()
l2 = list(map(int, l2))

l3 = sorted(l2)
sum = 0

for i in range(1, max):
    sum += l3[-i]

print(sum)


N, K = [int(x) for x in input().split()]
lens = [int(x) for x in input().split()]

lens = sorted(lens).reverse()

if len(lens) >= K:
    print(sum(lens))
else:
    print(sum(lens[:K]))

N, K = [int(x) for x in input().split()]
lens = [int(x) for x in input().split()]

lens = sorted(lens)[::-1]

if len(lens) <= K:
    print(sum(lens))
else:
    print(sum(lens[:K]))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03658/Python/s815774463.py", line 6, in <module>
    if len(lens) >= K:
TypeError: object of type 'NoneType' has no len()


N = int(input())
A = list(map(int, input().split()))
tmp = 0
diffs = []
for i in range(N - 1):
    tmp += A[i]
    diffs.append(abs(sum(A) - tmp - tmp))
print(min(diffs))

N = int(input())
A = list(map(int, input().split()))
tmp = 0
ans = 10**10
Asum = sum(A)
for i in range(N - 1):
    tmp += A[i]
    a = abs((Asum - tmp) - tmp)
    if ans > a:
        ans = a
print(ans)


def test(L):
    T = abs(sum(A[:L]) - sum(A[L:]))
    return T < answer

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

left = 0
right = N
answer = float("inf")

for i in range(1, N):
    if test(i):
        answer = abs(sum(A[:i]) - sum(A[i:]))

print(answer)

from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
A = list(accumulate(A))
answer = abs((A[-1] - A[0]) - A[0])
for i in range(N - 1):
    L = A[-1] - A[i]
    K = abs(L - A[i])
    if K < answer:
        answer = K

print(answer)


def main():
    N, *a = map(int, open(0).read().split())
    print(min(abs(2 * sum(a[:i]) - sum(a)) for i in range(1, N)))
    return

main()

INF = float("inf")

def main():
    N, *a = map(int, open(0).read().split())
    ans = INF
    tmp = 0
    total = sum(a)
    for i in range(N - 1):
        tmp += a[i]
        ans = min(ans, abs(2 * tmp - total))
    print(ans)
    return

main()


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

min_diff = abs(sum(a_list[:1]) - sum(a_list[1:]))
for i in range(2, N):
    diff = abs(sum(a_list[:i]) - sum(a_list[i:]))
    min_diff = min(min_diff, diff)
print(min_diff)

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

a_sum = sum(a_list)
l_a_sum = a_list[0]
min_diff = abs(a_sum - 2 * l_a_sum)
for i in range(1, N - 1):
    l_a_sum += a_list[i]
    min_diff = min(min_diff, abs(a_sum - 2 * l_a_sum))
print(min_diff)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    ans = 10**10
    for i in range(1, n):
        g1 = a[0:i]
        g2 = a[i:n]
        tmp = abs(sum(g1) - sum(g2))
        if tmp < ans:
            ans = tmp

    print(ans)

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    g1 = a[0]
    g2 = sum(a[1:n])
    ans = abs(g1 - g2)
    if n > 2:
        for i in range(1, n - 1):
            g1 += a[i]
            g2 -= a[i]
            tmp = abs(g1 - g2)
            if tmp < ans:
                ans = tmp

    print(ans)


N = int(input())
a = list(map(int, input().split()))
ans = 10000000000
total = sum(a)
for i in range(1, N):
    sunuke = a[:i]
    Sum = sum(sunuke)
    if abs(Sum - (total - Sum)) <= ans:
        ans = abs(Sum - (total - Sum))
print(ans)

N = int(input())
a = list(map(int, input().split()))
ans = 10000000000
total = sum(a)
sunuke = 0
for i in range(N - 1):
    sunuke += a[i]
    dif = abs(2 * sunuke - total)
    if dif <= ans:
        ans = dif
print(ans)


n = int(input())
a = [int(x) for x in input().split()]

d = []

for i in range(1, n):
    d.append(abs(sum(a[:i]) - sum(a[i:])))

print(min(d))

n = int(input())
a = [int(x) for x in input().split()]

b = sum(a)
c = a[0]
d = a[0]

for i in range(1, n - 1):
    c += a[i]
    if abs(b - 2 * d) > abs(b - 2 * c):
        d = c

print(abs(b - 2 * d))


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

    result = []

    for i in range(1, N):
        result.append(abs(sum(A[:i]) - sum(A[i:])))
    print(min(result))

if __name__ == "__main__":
    main()

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

    A_sum = sum(A)
    tmp = 0

    result = []

    for a in A:
        tmp += a
        result.append(abs(A_sum - tmp * 2))
    print(min(result[:-1]))

if __name__ == "__main__":
    main()


from collections import Counter

n, m = map(int, input().split())
an = list(map(int, input().split()))
ac_ = Counter(an)
ac = {i: ac_[i] if i in ac_ else 0 for i in range(1, n + 1)}
ad = [0] * n
for a, c in ac.items():
    for i in range(max(0, a - c), a):
        ad[i] += 1
ans = ad.count(0)

for _ in range(m):
    x, y = map(int, input().split())
    ax = an[x - 1]
    xdi = ax - ac[ax]
    if xdi >= 0:
        ad[xdi] -= 1
        if ad[xdi] == 0:
            ans += 1
    ac[ax] -= 1
    ac[y] += 1
    ydi = y - ac[y]
    if ydi >= 0:
        ad[ydi] += 1
        if ad[ydi] == 1:
            ans -= 1
    an[x - 1] = y
    print(ans)

from collections import Counter

n, m = map(int, input().split())
an = list(map(int, input().split()))
ac_ = Counter(an)
ac = {i: ac_[i] if i in ac_ else 0 for i in range(1, n + 1)}
ad = [0] * n
for a, c in ac.items():
    for i in range(max(0, a - c), a):
        ad[i] += 1
ans = ad.count(0)
anss = []

for x, y in (map(int, input().split()) for _ in range(m)):
    ax = an[x - 1]
    xdi = ax - ac[ax]
    if xdi >= 0:
        ad[xdi] -= 1
        if ad[xdi] == 0:
            ans += 1
    ac[ax] -= 1
    ac[y] += 1
    ydi = y - ac[y]
    if ydi >= 0:
        ad[ydi] += 1
        if ad[ydi] == 1:
            ans -= 1
    an[x - 1] = y
    anss.append(ans)
print("\\n".join(map(str, anss)))


a = list(int(input().split()))
print(sorted(a)[-1] + sorted(a)[-2])

a = list(map(int, input().split()))
print(sorted(a)[0] + sorted(a)[1])

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03671/Python/s485399330.py", line 1, in <module>
    a = list(int(input().split()))
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'


a, b, c = list(map(int, input().split()))
values = sorted(list(set([a, b, c])))
ans = values[0] + values[1]
print(ans)

a, b, c = list(map(int, input().split()))
values = sorted([a, b, c])
ans = values[0] + values[1]
print(ans)


abc = [map(int, input().split())]
print(sum(abc) - max(abc))

abc = list(map(int, input().split()))
print(sum(abc) - max(abc))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03671/Python/s477518016.py", line 2, in <module>
    print(sum(abc) - max(abc))
TypeError: unsupported operand type(s) for +: 'int' and 'map'


n = int(input())
a = tuple(map(int, input().split()))

b = []
for i in range(len(a)):
    b.append(a[i])
    b = b[::-1]

print(*b)

n = int(input())
a = tuple(map(int, input().split()))
reverse_a = a[::-1]

if n % 2 == 0:
    first = first = reverse_a[::2]
    second = a[::2]
else:
    first = reverse_a[::2]
    second = a[1:n:2]

print(*first + second)


n = int(input())
a = [int(i) for i in input().split()]
b = []
is_even = len(a) % 2 == 0

if is_even:
    for i in range(n):
        if i % 2 == 0:
            b.append(str(a[i]))
        else:
            b.insert(0, str(a[i]))
else:
    for i in range(n):
        if i % 2 == 0:
            b.insert(0, str(a[i]))
        else:
            b.append(str(a[i]))
print(" ".join(b))


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

b = []
for t in a:
    b.append(t)
    b.reverse()

print(" ".join(map(str, b)))

from collections import deque

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

b = deque()
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n % 2 == 1:
    b.reverse()

print(" ".join(map(str, b)))


# -*- coding: utf-8 -*-

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

b = []
for ele in a:
    b.append(ele)
    b = b[::-1]

print(*b)

# -*- coding: utf-8 -*-

from collections import deque

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

b = deque()
for i, ele in enumerate(a):
    if i % 2:
        b.appendleft(ele)
    else:
        b.append(ele)

if n % 2:
    b.reverse()

print(*b)


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

for i in range(N):
    if i % 2 == 0:
        ret.append(A[i])
    else:
        ret.insert(0, A[i])

if N % 2 == 1:
    ret.reverse()

print(*ret)

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

for i in range(N):
    if i % 2 == 0:
        ret.append(A[i])
ret.reverse()
for i in range(N):
    if i % 2 == 1:
        ret.append(A[i])

if N % 2 == 0:
    ret.reverse()

print(*ret)


from collections import deque

n = int(input())
a = deque(map(int, input().split()))
b = deque()

for _ in range(n):
    b.append(a.popleft())
    b.reverse()

print(*b)

from collections import deque

n = int(input())
a = deque(map(int, input().split()))
b = deque()

if n % 2 == 1:
    for i in range(n):
        if i % 2 == 0:
            b.appendleft(a.popleft())
        else:
            b.append(a.popleft())
else:
    for i in range(n):
        if i % 2 == 0:
            b.append(a.popleft())
        else:
            b.appendleft(a.popleft())

print(*b)


n = int(input())
alist = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(alist[i])
    b = b[::-1]

for _ in b:
    print(_, end=" ")

n = int(input())
alist = list(map(int, input().split()))
b = alist[::-2] + alist[n % 2 :: 2]
print(" ".join(list(map(str, b))))


int_n = int(input())
ar_int_a = list(map(int, input().split()))
ar_int_b = list()
for i in ar_int_a:
    ar_int_b.append(i)
    ar_int_b = ar_int_b[::-1]

print(" ".join(map(str, ar_int_b)))

int_n = int(input())
ar_int_a = list(map(int, input().split()))
ar_int_b = [-1] * int_n

idx = int_n // 2
ar_int_b[idx] = ar_int_a[0]

if int_n % 2 == 0:
    # 偶数
    for i in range(1, int_n):
        if i % 2 == 0:
            idx = idx + i
        else:
            idx = idx + (-1 * i)
        ar_int_b[idx] = ar_int_a[i]
else:
    # 奇数
    for i in range(1, int_n):
        if i % 2 == 0:
            idx = idx + (-1 * i)
        else:
            idx = idx + i
        ar_int_b[idx] = ar_int_a[i]

print(" ".join(map(str, ar_int_b)))


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    A = list(map(int, input().split()))
    result = []

    for i in range(N):
        if i % 2:
            result.append(A[i])
        else:
            result.insert(0, A[i])

    if N % 2:
        print(*result)
    else:
        print(*result[::-1])

if __name__ == "__main__":
    main()

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import collections

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

    result = collections.deque()

    for i in range(N):
        if i % 2 == N % 2:
            result.append(A[i])
        else:
            result.appendleft(A[i])
    print(*result)

if __name__ == "__main__":
    main()


def main():
    N = int(input())
    A = input().split()
    ans = A[0]
    for i in range(1, N):
        ans = (ans + " " + A[i])[::-1]
    print(ans)

if __name__ == "__main__":
    main()

from collections import deque

def main():
    N = int(input())
    A = list(map(int, input().split()))
    q = deque()
    for i in range(N):
        if (N - i) % 2 == 1:
            q.appendleft(A[i])
        else:
            q.append(A[i])
    print(" ".join(map(str, q)))

if __name__ == "__main__":
    main()


num = int(input())
array = [int(x) for x in input().split()]

res = []
for i in range(0, num):
    if i % 2 == 0:
        res.append(array[i])
    else:
        res.insert(0, array[i])

if num % 2 == 0:
    res = map(str, res)
    print(" ".join(res))
else:
    res = map(str, res[::-1])
    print(" ".join(res))

import math

num = int(input())
array = [int(x) for x in input().split()]

zero_array = array[0::2]
one_array = array[1::2]

if num % 2 == 0:
    one_array = one_array[: int(num / 2)]
    pick = one_array[::-1] + zero_array[: int(num / 2)]
else:
    one_array = one_array[: int(num / 2)]
    pick = one_array[::-1] + zero_array[: math.ceil(num / 2)]

if num % 2 == 0:
    print(" ".join(map(str, pick)))
else:
    print(" ".join(map(str, pick[::-1])))


n = int(input())
A = list(map(int, input().split()))
X = [str(A[0])]
append_ = True if n % 2 != 0 else False
for a in A[1:]:
    if append_:
        X.append(str(a))
    else:
        X.insert(0, str(a))
    append_ = not append_
print(" ".join(X))

from collections import deque

n = int(input())
A = list(map(int, input().split()))
X = deque([str(A[0])])
append_ = True if n % 2 != 0 else False
for a in A[1:]:
    if append_:
        X.append(str(a))
    else:
        X.appendleft(str(a))
    append_ = not append_
print(" ".join(X))


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.insert(0, a[i])

if n % 2 != 0:
    b.reverse()
for i in b:
    print(i, end=" ")

from collections import deque

n = int(input())
a = list(map(int, input().split()))
b = deque()
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if n % 2 != 0:
    for i in reversed(b):
        print(i, end=" ")
else:
    for i in b:
        print(i, end=" ")


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03673/Python/s153812591.py", line 6, in <module>
    print(" ".join(a[N::-2] + a[::2]))
TypeError: sequence item 0: expected str instance, int found


n = int(input())
a = list(map(int, input().split()))
b = []

for i in range(n):
    b.append(a[i])
    b.reverse()

print(*b)

from collections import deque

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

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if n % 2 == 1:
    b.reverse()

print(*b)


n = int(input())
a = list(map(int, input().split()))
a1 = []
a2 = []
for i in range(n):
    if i % 2 == 0:
        a1.append(a[i])
    else:
        a2.append(a[i])
if n % 2 == 0:
    rev = list(reversed(a2))
    print(*rev, *a1)
else:
    rev = list(reversed(a1))
    print(*rev, *a2)

n = int(input())
a = list(map(int, input().split()))
a1 = []
a2 = []
for i in range(n):
    if i % 2 == 0:
        a1.append(a[i])
    else:
        a2.append(a[i])
if n % 2 == 0:
    a2.reverse()
    print(*a2 + a1)
else:
    a1.reverse()
    print(*a1 + a2)


n = int(input())
a = list(map(int, input().split()))
even = []
odd = []
for i in range(n):
    if i % 2:
        even.append(a[i])
    else:
        odd.append(a[i])
if n % 2 == 0:
    print(*even[::-1], *odd)
else:
    print(*odd[::-1], *even)

n = int(input())
a = list(map(int, input().split()))
even = []
odd = []
for i in range(n):
    if i % 2:
        even.append(a[i])
    else:
        odd.append(a[i])
if n % 2 == 0:
    print(*even[::-1], end=" ")
    print(*odd)
else:
    print(*odd[::-1], end=" ")
    print(*even)


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

b = []

for i in range(n):
    b.append(a[i])
    b = b[::-1]
print(*b)

from collections import deque

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

b = deque()

for i in range(n):
    if i % 2 == 0:
        b.appendleft(a[i])
    else:
        b.append(a[i])
if n % 2 == 0:
    b = list(b)[::-1]
print(*b)


n = int(input())
a = list(map(int, input().split()))
b = []
for p in a:
    b.append(p)
    b.reverse()
for p in b:
    print(str(p) + " ", end="")
print()

n = int(input())
a = list(map(int, input().split()))
if n % 2:
    for i in range(n // 2 + 1):
        print(str(a[n - 1 - 2 * i]) + " ", end="")
    for i in range(n // 2):
        print(str(a[1 + 2 * i]) + " ", end="")
    print()
else:
    for i in range(n // 2):
        print(str(a[n - 1 - 2 * i]) + " ", end="")
    for i in range(n // 2):
        print(str(a[2 * i]) + " ", end="")
    print()


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

B = []
for i in range(N):
    B.append(A[i])
    B = B[::-1]

print(*B)

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

if len(A) == 1:
    print(A[0])
    exit(0)

B_left = []
B_right = []
for i, a in enumerate(A):
    if i % 2 == 0:
        B_right.append(a)
    else:
        B_left.append(a)

if len(A) % 2 == 0:
    B = B_left[::-1] + B_right
else:
    B = B_right[::-1] + B_left
print(*B)


n = int(input())
A = list(map(int, input().split()))
B = []

for i in range(n):
    B.append(A[i])
    B = B[::-1]

print(*B)

from collections import deque

n = int(input())
A = list(map(int, input().split()))
deq = deque([])

for i in range(1, n + 1):
    if i % 2 == 1:
        deq.append(A[i - 1])
    else:
        deq.appendleft(A[i - 1])

if n % 2 == 0:
    print(*deq)
else:
    print(*reversed(list(deq)))


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

if len(a) % 2 == 0:
    print(*list(reversed(a[1::2])), *a[0::2])
else:
    print(*list(reversed(a[0::2])), *a[1::2])

from collections import deque

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

d = deque()
for i in range(n):
    if i % 2 != 0:
        d.append(a[i])
    else:
        d.appendleft(a[i])

if n % 2 == 0:
    print(*list(reversed(d)))
else:
    print(*d)


n = int(input())
a = input().split()

b = []

for i in a:
    b.append(i)
    b.reverse()

print(" ".join(b))

n = 4
a = [1, 2, 3, 4]

n = int(input())
a = input().split()

if n % 2 == 0:
    y = [a[j] for j in range(1, n, 2)][::-1]
    z = [a[j] for j in range(0, n, 2)]

else:
    y = [a[j] for j in range(0, n, 2)][::-1]
    z = [a[j] for j in range(1, n, 2)]

print(" ".join(map(str, y + z)))


N = int(input())
A = [int(_) for _ in input().split()]
mod = 10**9 + 7

f = [1] * (N + 2)
fi = [1] * (N + 2)
for i in range(2, N + 2):
    f[i] = i * f[i - 1]
    f[i] %= mod
for i in range(2, N + 2):
    fi[i] = fi[i - 1] * pow(i, mod - 2, mod)
    fi[i] %= mod

def comb(n, r):
    if 0 <= n and 0 <= r and 0 <= n - r:
        return (f[n] * fi[r] * fi[n - r]) % mod
    else:
        return 0

b = set()
for a in A:
    if a in b:
        break
    b.add(a)
c = []
for i in range(N):
    if A[i] == a:
        c += [i]
i, j = c
for x in range(1, N + 2):
    print((comb(N + 1, x) - (comb(N - j + i, x - 1))) % mod)

N = int(input())
A = [int(_) for _ in input().split()]
mod = 10**9 + 7

f = [1] * (N + 2)
fi = [1] * (N + 2)
for i in range(2, N + 2):
    f[i] = i * f[i - 1]
    f[i] %= mod
for i in range(2, N + 2):
    fi[i] = fi[i - 1] * pow(i, mod - 2, mod)
    fi[i] %= mod

def comb(n, r):
    if 0 <= n and 0 <= r and 0 <= n - r:
        return (f[n] * fi[r] * fi[n - r]) % mod
    else:
        return 0

b = set()
for a in A:
    if a in b:
        break
    b.add(a)
c = []
for i in range(N + 1):
    if A[i] == a:
        c += [i]
i, j = c
for x in range(1, N + 2):
    print((comb(N + 1, x) - (comb(N - j + i, x - 1))) % mod)


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

b = []

for i in range(n):
    if i % 2 != n % 2:
        b.insert(0, a[i])
    else:
        b.append(a[i])

print(" ".join(map(str, b)))

from collections import deque

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

b = deque()

for i in range(n):
    if i % 2 != n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])

print(" ".join(map(str, b)))


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

ans = [A[0]]
for i in range(1, N):
    if i % 2 == 0:
        ans.append(A[i])
    else:
        ans.insert(0, A[i])

if N % 2 == 1:
    ans = ans[::-1]

print(" ".join(list(map(str, ans))))


from collections import deque

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

b = deque([])
rev = 1
for i in a:
    if rev == 1:
        b.append(i)
        rev = -1
    elif rev == -1:
        b.appendleft(i)
        rev = 1

print(*(b if rev == 1 else b[::-1]))

from collections import deque

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

b = deque([])
rev = 1
for i in a:
    if rev == 1:
        b.append(i)
        rev = -1
    elif rev == -1:
        b.appendleft(i)
        rev = 1

print(*(b if rev == 1 else list(b)[::-1]))


import sys

sys.setrecursionlimit(100001)

def get_ncr(div):
    cache = {}

    def f(*args):
        if args in cache:
            return cache[args]
        n, r = args
        if r == 0 or n == r:
            cache[args] = 1
            return 1
        cache[args] = (f(n - 1, r) + f(n - 1, r - 1)) % div
        return cache[args]

    return f

def find_duplicated(aa):
    appeared = [-1] * (n + 1)
    for i, a in enumerate(aa):
        if appeared[a] >= 0:
            return appeared[a], i
        appeared[a] = i

n = int(input())
aa = list(map(int, input().split()))
i1, i2 = find_duplicated(aa)
between_n = i2 - i1 + 1
outside_n = n + 1 - between_n
div = int(1e9 + 7)
ncr = get_ncr(div)

for part_n in range(1, n + 2):
    sub = ncr(outside_n, part_n - 1) if outside_n >= part_n - 1 else 0
    print((ncr(n + 1, part_n) - sub) % div)

def ncr(n, r):
    return fact[n] * inv_fact[r] * inv_fact[n - r] % div

def find_duplicated(aa):
    appeared = [-1] * (n + 1)
    for i, a in enumerate(aa):
        if appeared[a] >= 0:
            return appeared[a], i
        appeared[a] = i

div = int(1e9 + 7)
n = int(input())
aa = list(map(int, input().split()))

fact, inv_fact = [1], [1]
fact_tmp = 1
for i in range(1, n + 2):
    fact_tmp *= i
    fact_tmp %= div
    fact.append(fact_tmp)
    inv_fact.append(pow(fact_tmp, div - 2, div))

i1, i2 = find_duplicated(aa)
outside_n = n + 1 - (i2 - i1 + 1)

for part_n in range(1, n + 2):
    sub = ncr(outside_n, part_n - 1) if outside_n >= part_n - 1 else 0
    print((ncr(n + 1, part_n) - sub) % div)


n = int(input())
buttons = [0]
target_index = 0
for _ in range(n):
    num = int(input())
    buttons.append(num)

count = 0
next_index = 2
while count < n:
    if next_index < 1 or len(buttons) - 1 <= next_index:
        count = -1
        break

    prev_index = buttons.index(next_index)
    count += 1
    if prev_index == 1:
        break
    else:
        next_index = prev_index

print(count if count < n else -1)

n = int(input())
buttons = [0]
target_index = 0
for _ in range(n):
    buttons.append(int(input()))

count = 0
prev_index = 1
while count < n:
    if prev_index < 1 or len(buttons) <= prev_index:
        count = -1
        break

    next_index = buttons[prev_index]
    count += 1
    if next_index == 2:
        break
    else:
        prev_index = next_index

print(count if count < n else -1)


N = int(input())
A = [int(input()) for _ in range(N)]

B = [1]
i = 0
flag = False
for _ in range(N):
    if 2 in B:
        flag = True
        break
    elif A[i] in B:
        break
    B.append(A[i])
    i = A[i] - 1

print(len(B) - 1) if flag else print(-1)

N = int(input())
A = [int(input()) for _ in range(N)]

B = [1]
i = 0
cnt = 0
flag = False
for _ in range(N):
    i = A[i] - 1
    cnt += 1
    if i == 1:
        flag = True
        break

print(cnt) if flag else print(-1)


n = int(input())
a = [0] + [int(input()) for i in range(n)]
c = a[1]
p = 1
while c > 2:
    c = a[c]
    p += 1

if c == 2:
    print(p)
else:
    print(-1)

n = int(input())
a = [0] + [int(input()) for i in range(n)]
c = a[1]
p = 1
while c > 2:
    d = a[c]
    a[c] = 0
    c = d
    p += 1

if c == 2:
    print(p)
else:
    print(-1)


n = int(input().strip())
a = [int(input().strip()) for _ in range(n)]
visited = [False] * n
visited[0] = True
now = 0
ans = 0
while True:
    now = a[now] - 1
    ans += 1
    if now == 1:
        print(ans)
        exit()
    elif visited[now]:
        print(-1)
        exit()
    visited[now] = True


n = int(input())
nlist = [int(input()) for i in range(n)]
xlist = []
c = 0
x = 1
while x != 2 and x not in xlist and c < n:
    xlist.append(x)
    x = nlist[x - 1]
    c += 1
if x == 2:
    print(c)
else:
    print(-1)

n = int(input())
nlist = [int(input()) for i in range(n)]
c = 0
x = 1
while x != 2 and c < n:
    x = nlist[x - 1]
    c += 1
if x == 2:
    print(c)
else:
    print(-1)


def main():
    n = int(input())
    a = [int(input()) for i in range(n)]

    btn = 1
    hist = []
    while True:
        if btn == 2:
            print(len(hist))
            break

        if btn in hist:
            print(-1)
            break

        hist.append(btn)
        btn = a[btn - 1]

if __name__ == "__main__":
    main()

def main():
    n = int(input())
    a = [int(input()) for i in range(n)]

    btn = 1
    hist = set()
    while True:
        if btn == 2:
            print(len(hist))
            break

        if btn in hist:
            print(-1)
            break

        hist.add(btn)
        btn = a[btn - 1]

if __name__ == "__main__":
    main()


N = int(input())
a = [int(input()) for _ in range(N)]

i = 1
c = 0
while True:
    i = a[i - 1]
    c += 1
    if i == 1:
        c = -1
        break
    elif i == 2:
        break
print(c)

N = int(input())
a = [int(input()) for _ in range(N)]

i = 1
c = 0
ans = -1
for _ in range(N):
    i = a[i - 1]
    c += 1
    if i == 2:
        ans = c
        break
print(ans)


n = input()
a = (input() for i in range(n))
counter = 0
i = 1
while counter < n:
    i = a[i - 1]
    counter += 1
    if i == 2:
        print(counter)
        break
else:
    print(-1)

n = int(input())
a = [int(input()) for i in range(n)]
counter = 0
i = 1
while counter <= n:
    i = a[i - 1]
    counter += 1
    if i == 2:
        print(counter)
        break
else:
    print(-1)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03680/Python/s197975639.py", line 2, in <module>
    a = (input() for i in range(n))
TypeError: 'str' object cannot be interpreted as an integer


N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

pushed = [False] * N
pushed[0] = True
now = 0
cnt = 0
while True:
    next = A[now] - 1
    if pushed[next]:
        cnt = -1
        break

    if next != 1:
        now = next
        cnt += 1

    if next == 1:
        cnt += 1
        break

print(cnt)

N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

pushed = [False] * N
pushed[0] = True
now = 0
cnt = 0

while True:
    next = A[now] - 1

    if pushed[next]:
        cnt = -1
        break

    if next == 1:
        cnt += 1
        break

    if next != 1:
        now = next
        pushed[next] = True
        cnt += 1

print(cnt)


N = int(input())
a = [int(input()) for i in range(N)]

pushed = [0]
ans = 0
current = 0
while True:
    ans += 1
    current = a[current] - 1
    if current in pushed:
        ans = -1
        break
    if current == 1:
        break
    pushed.append(current)
print(ans)

N = int(input())
a = [int(input()) for i in range(N)]

pushed = [False] * N
ans = 0
current = 0
while True:
    ans += 1
    current = a[current] - 1
    if pushed[current]:
        ans = -1
        break
    if current == 1:
        break
    pushed[current] = True
print(ans)