peterverebics/CodeNet_Python_118 huggingface dataset:
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''


n=int(input())
a=list(map(int,input().split()))
a.sort()
#print(a)
ans=0
from math import floor
for i in range(1,n-1):
    ans+=a[n-1-floor(i/2)]
    #print(ans)
print(ans)
n=int(input())
a=[int(j)for j in input().split()]
print(sum(a)-min(a))
n = int(input())
x = list(map(int, input().split()))
sum_ = sum(x)
min_ = min(x)
flag = 0
x = sorted(x)

for i in range(n-1):
  if x[i] == x[i+1]:
    flag = 1
    break

if flag == 0:
  print(sum_)
else:
  print(sum_-min_)
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

conf = 0
from heapq import heapify, heappop, heappush
As.sort(reverse=True)
m = As.pop(0)
s = As.pop(0)
conf += m
Q = []
heappush(Q, s)
heappush(Q, s)
for a in As:
    s = heappop(Q)
    conf += s
    heappush(Q, a)
    heappush(Q, a)
print(conf)
n=int(input())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
print(sum(a[:n-1]))
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
t=[A[0],A[1]]
ans=A[0]
half=N//2+N%2
for i in range(2,N):
    if i<half:
        ans+=A[i-1]
        
    else:
        ans+=A[i-half+1]

print(ans)
n = int(input())

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

a.sort(reverse=True)

point = 0
num_list = [a[0]]
for i in range(1, n):
  point += min(num_list)
  num_list.append(a[i])
print(point)
N=int(input())
A=list(map(int,input().split()))

print(sum(A)-sorted(A)[0])
N = int(input())
A = list(map(int, input().split()))
ans = sum(A) - min(A)
print(ans)
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)
ans = 0
incircle = []
for i in range (len(A)):
    if incircle == []:
        incircle.append(A[i])
    else:
        num = (i//2)-1
        ans += A[num]
        incircle.append(A[i])
print(ans)
n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)

print(sum(a[1:]))
N = int(input())
A = list(map(int, input().split()))

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

ans = sum(A[:-1])
print(ans)
# 2020/07/05
# AtCoder Beginner Contest 173 - D

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

# Calc
a.sort()
a.reverse()

ans = 0
for i in range(1, n):
    ans = ans + a[i-1]

# Output
print(ans)
n = int(input())
a = list(map(int,input().split()))
ans = 0
a.sort()
a = a[::-1]
r = []
for i in range(n):
    r.append(a[i])
    if i != 0:
        ans += min(r[0],r[-2])
print(ans)
import numpy as np


n = int(input())
ajs_str = input().split()
ajs = [int(aj) for aj in ajs_str]

ajs_sorted = np.sort(ajs)[::-1]

print(int(ajs_sorted[:-1].sum()))
import sys
from math import gcd

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    X = int(rl())
    
    ans = X * 360 // gcd(X, 360) // X
    print(ans)


if __name__ == '__main__':
    solve()
x = int(input())
for i in range(1,1000000):
  if (i * x) % 360 == 0:
    print(i)
    exit()
import math
x = int(input())
print(360//math.gcd(x, 360))
x = int(input())
for i in range(1, 361):
    if x*i % 360 == 0:
        print(i)
        exit()
n = int(input())
for i in range(1,1000):
  if n * i % 360 == 0:
    print(i)
    exit()
X = int(input())
for i in range(1, 361):
  if X*i % 360 == 0:
    print(i)
    exit()
X=int(input())

for i in range(1,180):
    if (i*360%X==0):
        print((i*360)//X)
        exit()
from math import gcd
x = int(input())
g = gcd(x,360)
print(((360//g)*(x//g)*g)//x)
x = int(input())
n = 1
while (x*n)%360!=0:
    n+=1
print(n)
#!python3

LI = lambda: list(map(int, input().split()))

# input
X = int(input())


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


def main():
    g = gcd(X, 360)
    v = X // g
    ans = 360 * v // X
    print(ans)


if __name__ == "__main__":
    main()
x=int(input())
for i in range(1,200):
  i*=360
  if(i%x==0):
    print(i//x)
    exit()
x=int(input())
for i in range(1,361):
  if (i*x)%360==0:
    print(i)
    break
x = int(input())
print([360*n//x for n in range(1, 500) if 360 * n % x == 0][0])
import math
n=int(input())
print(int(360/math.gcd(n,360)))
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

X = int(input())


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


l = lcm(360, X)

print(l // X)
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    X = int(input())

    lcm = X * 360 // math.gcd(X, 360)
    ans = lcm // X
    print(ans)


if __name__ == "__main__":
    main()
x=int(input())
from math import gcd
g=gcd(x,360)
print(360//g)
import sys
from math import gcd

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X = int(readline())

g = gcd(X, 360)
print(360//g)
from math import gcd
X = int(input())
print(360 // gcd(X, 360))
a = int(input())
x = a
k = 1
while a != 360:
    a = a + x
    if a > 360 :
        a = a - 360
    k = k + 1
print(k)
N=int(input())
import math
print(360//math.gcd(360,N))
import math
X = int(input())

for k in range(1, 361):
  if (k * X) % 360 == 0:
    print(k)
    break
X = int(input())
for k in range(1, 361):
  if k * X % 360 == 0:
    print(k)
    break
X = int(input())

count = 1
total_digree = X
while True:
    if total_digree % 360 == 0:
        break
    count += 1
    total_digree += X

print(count)
x = int(raw_input())
p = 0
for i in xrange(361):
    p += x
    if p % 360 == 0:
        print i + 1
        break
p = int(input())
index = 1
while True:
    if p* index % 360 == 0:
        print(index)
        break
    index += 1
X = int(input())

if 360 % X == 0:
    print(360 // X)
    exit()
else:
    mod = 0
    cnt = 0
    while (360 + mod) % X != 0:
        cnt += (360 + mod) // X
        mod = (360 + mod) % X
    cnt += (360 + mod) // X

print(cnt)
X = int(input())

for i in range(1, 1000000):
    if (X * i) % 360 == 0:
        print(i)
        exit()
from math import gcd
X = int(input())
lcm = X * 360 // gcd(X, 360)
print(lcm//X)
x = int(input())
for i in range(1,10000):
  if i*360%x == 0:
    print(i*360//x)
    break
X = int(input())
i = 1
while True:
    if i*X%360 == 0:
        print(i)
        break
    else:
        i += 1
x = int(input())
for i in range(1,361):
  if (x*i)%360 == 0:
    print(i)
    exit()
X = int(input())
import math

tmp = 360*X//math.gcd(360,X)
ans = tmp//X
print(ans)
import math
x = int(input())
d = math.gcd(360, x)
print(360//d)
x = int(input())

count=1
test= 0
test+=x
while test%360!=0:
	test+=x
	count+=1
print(count)
def resolve():
    import math
    x = int(input())

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

    if 360 % x == 0:
        print(360 // x)
    else:
        print(lcm(360, x) // x)


if 'unittest' not in globals():
    resolve()
import numpy as np
import math
import collections
import bisect


X = int(input())

print(int(360 / math.gcd(360, X)))
X = int(input())
K = 0
while ((X * K) % 360 != 0) or (K == 0):
  K += 1
print(K)
a = int(input())
k = 0
t = 1
count = 0
while t == 1 :
     k = k + a
     count = count + 1
     if k % 360 == 0 :
         break

print(count)
import math
#print(math.cos(math.radians(90)))
#exit()
x = int(input())
print(360//math.gcd(360,x))
import math
x = int(input())
y = math.gcd(x, 360)
print(int(360/y))
try:
    from math import gcd
except ImportError:
    from fractions import gcd

x=int(input())

print(360//gcd(x,360))
x = int(input())
for i in range(1,361):
    if (x * i) % 360 == 0:
        k = i
        break
print(k)
X=int(input())
i=1

while True:
  if X*i%360==0:
    print(i)
    break
  i+=1
X = int(input())

ans = 0
x = 0
while((360-x) % X != 0):
    ans += (360 - x) // X + 1
    x = X - (360-x) % X
ans += (360-x) // X
print(ans)
X=int(input())
cnt=0
for i in range(1,10**7):
    cnt+=X
    if cnt%360==0:
        print(i)
        break
x = int(input())

for i in range(1, 10**5):
    if 360 * i % x == 0:
        print(360 * i // x)
        break
x = int(input())
if 360 % x == 0:
    print(360//x)
else:
    for i in range(1,10000):
        if 360 * i % x == 0:
            print(360 * i // x)
            exit()
n = int(input())
a = 0
c = 0
while(True):
  a+=n
  c+=1
  if(a%360 == 0):
    print(c)
    break
x = int(input())

for k in range(1, 100000):
  if (k * x) % 360 == 0:
    print(k)
    exit()
import math
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    X = int(input())
    a = math.gcd(X, 360)
    a = X * 360 // a
    print(a // X)


if __name__ == "__main__":
    main()
import sys

def lcm(a, b):
    a, b = max(a, b), min(a, b)
    c = a * b
    while a % b > 0:
        a, b = b, a % b
    return c // b

def solve():
    input = sys.stdin.readline
    X = int(input())
    L = lcm(360, X)
    print(L // X)

    return 0

if __name__ == "__main__":
    solve()
t=int(input())
i=1
while((i*t)%360!=0):
    i+=1
print(i)
def main():
    n = int(input())
    i = 1
    now = n
    while True:
        if now % 360 == 0:
            print(i)
            break
        else:
            i += 1
            now += n


main()
import math
X = int(input())
print(360 // math.gcd(X, 360))
import math

k, = list(map(int,input().split()))
print(abs(360*k) // math.gcd(360, k) // k)
X = int(input())
sum = 0
ans = 0
while(True):
    sum += X
    ans += 1
    if(sum % 360 == 0):
        print(ans)
        break
N = int(input())
pi = 360
while True:
  if pi % N == 0:
    print(pi//N)
    exit()
  else:
    pi+=360
import math
x = int(input())
tol = 1e-6
ans = 1
cur = [0,1]
unit = x/180*math.pi
while cur[0]**2 + cur[1]**2 > tol:
    cur[0] += math.sin(ans*unit)
    cur[1] += math.cos(ans*unit)
    ans += 1
print(ans)
x = int(input())

for k in range(1, 10000):
    if x*k % 360 == 0:
        print(k)
        break
X = int(input())
theta, k = 0, 0
while theta % 360 != 0 or theta == 0:
    theta += X
    k += 1
print(k)
from math import gcd
x = int(input())

lcm = (x * 360)/gcd(x, 360)
print(int(lcm/x))
x = int(input())
k = 1
while(True):
  if k * x % 360 == 0:
    print(k)
    break
  else:
    k += 1
i=int(input())
a=0
for j in range(361):
    a=(i+a)%360
    if a==0:
        print(j+1)
        break
import sys
input=sys.stdin.readline
x=int(input())
import math
y=math.gcd(360,x)
z=x*360//y
ans=z//x
print(ans)
x = int(input())

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

print(lcm(360,x)//x)
x=int(input())
ans=1
now=x
while now%360!=0:
    now+=x
    ans+=1
print(ans)
x = int(input())

for i in range(1, 361):
  if x*i % 360 == 0:
    print(i)
    break
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)
ans = 360 // (gcd(360, int(input())))
print(ans)
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

x = inn()
for i in range(1,361):
    #if ((180-x)*i)%360==0:
    if ((x)*i)%360==0:
        print(i)
        exit()
def gcd(a, b):
	if a==0:
		return b
	else:
		return gcd(b%a, a)

X = int(input())
LCM = X*360/gcd(360, X)
print(int(LCM/X))


#a, b = map(int, input().split())
#print(gcd(a, b))
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
        return a

def main():
    X = int( input())
    # if X > 90:
    #     X -= 90
    for i in range(1, X+1):
        if i*360%X == 0:
            print(i*360//X)
            return
if __name__ == '__main__':
    main()
n=int(input())

for i in range(1,361):
  if (n*i)%360==0:
    print(i);exit()
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    # from collections import deque
    # from collections import Counter
    # import copy
    # import numpy as np
    import math
    # import random
    input = stdin.readline

    x = int(input())
    one_round = 360
    print(int(360//math.gcd(one_round, x)))
import numpy as np
 
X = int(input())
X_lcm = np.lcm(360, X)
print(X_lcm // X)
x = int(input())
j = 0
for i in range(360):
  j += x
  j %= 360
  if j == 0:
    print(i+1)
    exit()
N = int(input())
for i in range(360):
    if not N * (i + 1) % 360:
        print(i + 1)
        break
X = int(input())
ret = 0
cur = 0
while True:
    ret += 1
    cur += X
    if cur % 360 == 0:
        print(ret)
        break
import math
x = int(input())
print(((x*360)//math.gcd(x,360))//x)
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    while b:
        a, b = b, a % b
    return a


x = int(input())
ans = gcd(x, 360)
print(360 // ans)
import math

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

x = int(input())
print(lcm(x, 360)//x)
x=int(input())
n=1
tgt=1
Ans=0
while tgt>0:
    tgt=(360*n)%x
    Ans=(360*n)//x
    n+=1
print(Ans)
import math

n = int(input())

lcm = n * 360 // math.gcd(n, 360)
print(lcm // n)
X = int(input())
K = 1
while True:
    if X*K %360 ==0:
        print(K)
        break
    K += 1
X = int(input())
if 360 % X == 0:
  ans = int(360 / X)
else:
  import math
  kaku = (360 * X) / math.gcd(360, X)
  ans = int(kaku / X)
print(ans)
X = int(input())
tmp = X
count = 1
while 360 != tmp:
  tmp += X
  count += 1
  if tmp > 360:
    tmp -= 360
print(count)
def gcd(a,b):
    # assume a,b are +ve integers.
    if a>b:
        a,b = b,a
    if b%a==0:
        return a
    
    return gcd(a,b%a)
print(360//(gcd(360,int(input()))))
from math import gcd
def resolver(X):
    i = 1
    while True:
        if (360 * i) % X == 0:
            return (360 * i) // X
        i += 1



def main():
    X = int(input())
    ans = resolver(X)
    print(ans)


if __name__ == '__main__':
    main()
import numpy as np

import math

import collections

if __name__ == '__main__':
    n = int(input())
    print(int(np.lcm(360,n)/n))
import math

X = int(input())
aa = math.gcd(X, 360)
ans = int(360/aa)

print(ans)
from sys import stdin
x = int(stdin.readline().rstrip())

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

ans = int(lcm(x, 360) / x)
print(ans)
X = int(input())
import math
ans = 360 // math.gcd(360, X)
print(ans)
x = int(input())
y = 0
n =0
while(1):
  n += 1
  y += x
  y %= 360
  if(y==0):
    print(n)
    exit()
X=int(input())
K=0
B=0
C=0
for i in range(0,360):
    B=B+X
    C=B%360
    K=K+1
    if C==0:
        print(K)
        break
x = int(input())
x_max = 179

for i in range(1,x_max+1):
    if((360 * i) % x == 0):
        tmp = (360 * i) / x
        print(int(tmp))
        break
x = int(input())

for k in range(1, 361):
    n = k*x/360
    if n%1 ==0:
        break
print(k)
X = int(input())
k = 1
while True:
    cand = X*k
    if cand%360==0:
        break
    k+=1
print(k)
x = int(input())
i = 1
while x*i%360 != 0:
    i+= 1

print(i)
import math
X=int(input())
Xjiku=float(1)
Yjiku=float(0)
ans=int(1)
thita=int(0)
for _ in range(1000000):
    thita += X
    Xjiku += math.cos(math.radians(thita))
    Yjiku += math.sin(math.radians(thita))
    ans += int(1)
    if abs(Xjiku) < float(10**-10) and abs(Yjiku) < float(10**-10):
        break
print(ans)
x=int(input())
t=0
i=1
while True:
    t+=x
    t%=360
    if t==0:
        print(i)
        break
    i+=1
from math import *

a = int(input())
t = gcd(360, a)
print(360//t)
def gcd(a,b):
    a,b = max(a,b),min(a,b)
    while b:
        a,b =b,a%b
    return a

X=int(input())

if 360%X==0:
    print(360//X)
else:
    g =gcd(360,X)
    print(360//g)
i = 1
x = int(input())
while True:
  if (360 * i) % x == 0:
    print(360 * i // x)
    break
  i += 1
x = int(input())
y = x
while y % 360:
    y += x
print(y//x)
x = int(input())

from math import gcd

print(360 // gcd(x, 360))
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

import math

d=ni()

x=0
y=1
cnt=0
dd=0
while True:
  cnt+=1
  dd=(dd+d)%360
  r = math.radians(dd)
  x += math.sin(r)
  y += math.cos(r)

  # print("{}, {}".format(x,y))

  if abs(x)<10**(-10) and abs(y)<10**(-10):
    break
print(cnt+1)
def gcda(a,b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    return gcda(r, b)

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

X=int(input())
shukai=360
while True:
    if shukai%X==0:
        print(shukai//X)
        exit()
    else:
        shukai=lcm(shukai,X)
x = int(input())
d, k = x, 1
while True:
    if d%360==0:
        print(k)
        break
    d += x
    k += 1
n = int(input())
for i in range(1, 180, 1):
  if(360*i % n == 0):
    print(int(360*i//n))
    exit(0)
X = int(input())

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

print(360*X//gcd(X, 360)//X)
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

X = I()

from math import gcd

print(360//gcd(360,X))
X = int(input())

K = 0
rad = 360
while rad != 0:
    rad -= X
    K += 1
    if rad < 0:
        rad += 360
print(K)
import math
x = int(input())

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

if 360%x==0:
    print(int(360/x))

else:
    print(int(lcm(x)/x))
X=int(input())
for i in range(1,100000):
    if X*i%360==0:
        print(i)
        break
x = int(input())
for i in range(1000):
    if x * (i+1) % 360 == 0:
        print(i+1)
        exit()
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	x=II()

	a=0

	for i in range(100000):
		a+=x
		if a%360==0:
			print(i+1)
			exit(0)





if __name__ == "__main__":
	main()
X=int(input())
p=360
cnt=0

while p%X !=0:
    p += 360

print(p//X)
x=int(input())
for i in range(1,361):
  if 360*i % x == 0:
    print(int(360*i/x))
    exit()
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    return gcd(y,x%y)
def lcm(x,y):
    return x*y//gcd(x,y)

def main():
    x=int(input())
    l=lcm(360,x)
    print(l//x)
    
if __name__=='__main__':
    main()
def main():
    import sys
    X=int(sys.stdin.readline())
    i=1
    while True:
        if 360*i%X==0:
            print(360*i//X)
            break
        i+=1
main()
from math import gcd

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

X = int(input())
print(lcm(X, 360) // X)
n = int(input())
now = 0
for i in range(1,10000):
  now += n
  if now % 360 == 0:
    print(i)
    exit()
x = int(input())

for i in range(1, 1000):
    if x * i % 360 == 0:
        print(i)
        exit()
x=int(input())
import math
K=360//math.gcd(x,360)
print(K)
import math
x=int(input())
ans=math.gcd(x,360)
print(360//ans)
def gcd(a: int, b: int) -> int:
    return a if b == 0 else gcd(b, a%b)

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

x = int(input())
print(int(lcm(x, 360) / x))
import sys
import math
def input(): return sys.stdin.readline().rstrip()
def main():
    x = int(input())
    xx = x
    ans = 1
    while xx%360 != 0:
        xx += x
        ans += 1
    print(ans )

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

for i in range(360):
    if x*(i+1) % 360 == 0:
        print(i+1)
        exit()
def GCM(x,y):
  if x%y==0:
    return y
  else:
    return GCM(y,x%y)
  
X = int(input())
print(360//GCM(360,X))
import math

angle = int(input())
c = 1
x = 0
y = 1

while [round(x,2),round(y,2)] != [0,0]:
  angle_u= 180-angle*c
  y -= math.cos(math.radians(angle_u))
  x -= math.sin(math.radians(angle_u))
  c += 1
else:
  print(c)
# coding:utf-8
x = int(input())
r = 0
for k in range(360):
    r += x
    if r % 360 == 0:
        break
print(k + 1)
import math
def main():
    d = int(input())
    th = 90

    eps = 10**(-12)
    x = y = ans = 0
    while True:
        x += math.cos(math.radians(th))
        y += math.sin(math.radians(th))
        ans += 1

        if abs(x) <= eps and abs(y) <= eps:
            print(ans)
            break
        else:
            th += d

if __name__ == "__main__":
    main()
from sys import stdin

input = stdin.readline

def main():
    X = int(input().rstrip())
    ans = 1
    n = X
    while(n % 360 != 0):
        n += X
        ans += 1 
    print(ans)

if __name__ == "__main__":
    main()
X=int(input())
i=1
while i*X % 360 != 0:
	i+=1
print(i)
from math import gcd
x = int(input())
print(360 // gcd(360, x))
x = int(input())
k = 2
while k*x%360!=0:
    k += 1
print(k)
from math import gcd

X = int(input())

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

print(360 // gcd(X, 360))
# do simulation

X = int(input())
Y, K = 0, 0
while True:
  Y += X
  K += 1
  if Y % 360 == 0:
    print(K)
    exit()
def lcm(a, b):
    from math import gcd
    return a * b // gcd(a, b) 
print(lcm(360, n := int(input())) // n)
x=int(input())
i=1

while True:
  y=i*360/x
  i+=1
  if y%1==0:
    break
print(int(y))
import math

x=int(input())
G=math.gcd(x,360)
L=x*360//G
ans=L//x
print(ans)
X = int(input())
import math
A = X // math.gcd(360, X)
ans = 360 * A // X
print(ans)
X = int(input())

for i in range(1,361):
    if (360*i)%X==0:
        ans=(360*i)//X
        break
print(ans)
n=int(input())
for i in range(1, n+1):
  x=360*i%n
  if x==0:
    print(360*i//n)
    break;
  else:
    continue;
X = int(input())
i = 0
Y = X
while Y % 360 != 0:
  Y += X
  i += 1

i += 1  
print(i)
# A - Takahashikun, The Strider
x = int(input())
i = 1

while True:
  if 360 * i % x == 0:
    print(360 * i // x)
    break
  else:
    i += 1
def a():
    x = int(input())
    k = 1
    while (k * x) % 360 != 0:
        k += 1
    print(k)


a()
# -*- coding: utf-8 -*-
# get a integer
a = int(input())

m = a
c = 1
while m % 360 != 0:
	m+=a
	c+=1
print(c)
from math import gcd
g = gcd(int(input()), 360)
print(360 // g)
def main():
    X = int(input())
    t = 0

    for i in range(10**5):
        t += X
        if t % 360 == 0:
            return i + 1

print(main())
x = int(input())

for i in range(3,361):
    xk = x*i
    if xk%360 == 0:
        print(i)
        exit()
import math
n = int(input())
print(360*n//math.gcd(360,n)//n)
x = int(input())

idx = 0
tmp = 0
while 1:
    tmp += x
    idx += 1
    if tmp % 360 == 0:
        break

print(idx)
import sys
import math

X = int(sys.stdin.readline())
for i in range(1, 10**5):
    if (X * i) % 360 == 0:
        print(i)
        break
x = int(input())
y = 0
k = 0
while True:
    y += x
    k += 1
    if y % 360 == 0:
        break
print(k)
X = int(input())

n = 1
nX = [X]
k = 360
mk = [360]

while True:
    if mk.count(nX[-1]) == 1:
        print(n)
        break
    n += 1
    mk.append(n * k)
    nX.append(n * X)
X = int(input())
ans = 1
while(True):
    if (X*ans) %360 == 0:
        break
    else:
        ans += 1
print(ans)
import math
def main():
    x = int(input())
    print(360 // math.gcd(360, x))

main()
import math
n=int(input())
print(int(n*360/math.gcd(n,360)/n))
import math
n=int(input())
if 1 < math.gcd(360,n) < 360:
  print(360//math.gcd(360,n))
else:
  print(360)
X = int(input())
i = 1
while True:
  if (360*i) % X == 0:
    print((360*i) // X)
    exit()
  else:
    i += 1
X=int(input())
i=1
while True:
    if (X*i)%360==0:
        print(i)
        exit()
    i+=1