Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import collections
n = int(input())

s = []
sLen = len(s)
for i in range(n):
    s.append(input())
c = collections.Counter(s)
max = c.most_common()[0][1]
print()
ans = []
for i in range(len(c.most_common())):
    if max == c.most_common()[i][1]:
        ans.append(c.most_common()[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)


### FIXED CODE ###

import collections
n = int(input())

s = []
sLen = len(s)
for i in range(n):
    s.append(input())

c = collections.Counter(s)
c_m = c.most_common()
max = c.most_common()[0][1]
print()
ans = []
for i in range(len(c_m)):
    if max != c_m[i][1]:
        break
    ans.append(c_m[i][0])
ans.sort()
for i in ans:
    print(i)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    m = 10**9 + 7
    B =[a%m for a in A]
    ans = 0
    for i in range(N-1):
        for j in range(i+1,N):
            # print(B[i],B[j])
            # ans += (A[i]*A[j])%(10**9+7)
            ans += A[i]%m * A[j]%m
    print(ans%m)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    W = [0]*N
    W[0] = A[0]
    for i in range(1,N):
        W[i] += W[i-1] + A[i]
    ans = 0
    for i in range(N-1):
        ans += A[i]*(W[N-1] - W[i])
    print(ans%(10**9+7))

if __name__ == '__main__':
    main()
### BUGGY CODE ###

a, b, k = map(int, input().split())
numlist = []
 
for i in range(a, b+1):
    if i < a + k or i >  b - k:
        numlist.append(i)

numlist.sort()
 
for l in range(len(numlist)):
    print(numlist[l])

### FIXED CODE ###

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

if (b-a+1)/2 < k:
    for i in range(a, b+1):
        print(i)
else:
    for j in range(a, a+k):
        print(j)
    for k in range(b-k+1, b+1):
        print(k)
### BUGGY CODE ###

S = input()
T = input()
for x in range(0,len(S)):
    S = S.replace(S[x],'A').replace(T[x],S[x]).replace('A',T[x])
if S == T:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

S = input()
T = input()
for x in set(T):
    S = S.replace(S[T.index(x)],'A').replace(x,S[T.index(x)]).replace('A',x)
if S == T:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

#!usr/bim/python
#! -*- coding: utf-8 -*-

import numpy as np

n = raw_input()
n = int(n)

tree = []
for i in range(n):
    tree.append([])

for i in range(n-1):
    abc = raw_input()
    abc = abc.split()
    abc = map(int, abc)
    tree[abc[0]-1].append([abc[1]-1,abc[2]])
    tree[abc[1]-1].append([abc[0]-1,abc[2]])


qk = raw_input()
qk = qk.split()
q,k = map(int,qk)

question = []
for i in range(q):
    xy = raw_input()
    xy = xy.split()
    xy = map(int,xy)
    question.append(xy)

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

distance[k-1] = 0

while 1:
    status = 0
    for i in range(n):
        if distance[i] == -1:
            status = 1
        else:
            for j in tree[i]:
                if distance[j[0]] == -1:
                    distance[j[0]] = distance[i] + j[1]
    if status == 0:
        break

for line in question:
    print distance[line[0]-1] + distance[line[1]-1]


### FIXED CODE ###

#!usr/bim/python
#! -*- coding: utf-8 -*-

import numpy as np

n = raw_input()
n = int(n)

tree = []
for i in range(n):
    tree.append([])

for i in range(n-1):
    abc = raw_input()
    abc = abc.split()
    abc = map(int, abc)
    tree[abc[0]-1].append([abc[1]-1,abc[2]])
    tree[abc[1]-1].append([abc[0]-1,abc[2]])


qk = raw_input()
qk = qk.split()
q,k = map(int,qk)

question = []
for i in range(q):
    xy = raw_input()
    xy = xy.split()
    xy = map(int,xy)
    question.append(xy)

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

distance[k-1] = 0

next_point = [k-1]

while 1:
    search_point = next_point
    next_point = []
    if len(search_point) == 0:
        break
    else:
        for i in search_point:
            for j in tree[i]:
                if distance[j[0]] == -1:
                    distance[j[0]] = distance[i] + j[1]
                    next_point.append(j[0])

for line in question:
    print distance[line[0]-1] + distance[line[1]-1]
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
a_set = sorted(set(a), key=a.index)

maxval = a[0]
cc = {maxval: 1}

ans = 0
idx = 0

for i in range(1, n):
    if a[i] in cc:
        cc[a[i]] += 2
    else:
        cc[a[i]] = 2
    cc[maxval] -= 1
    ans += maxval
    if cc[maxval] == 0:
        idx += 1
        maxval = a_set[idx]
    # print(cc)

print(ans)


### FIXED CODE ###

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

maxval = a[0]
cc = {maxval: 1}

ans = 0
idx = 0

for i in range(1, n):
    if a[i] in cc:
        cc[a[i]] += 2
    else:
        cc[a[i]] = 2
    cc[maxval] -= 1
    ans += maxval
    if cc[maxval] == 0:
        while 1:
            idx += 1
            if maxval > a[idx]:
                maxval = a[idx]
                break

print(ans)
### BUGGY CODE ###

def rev(s):
    new_s = list(reversed(s))
    return new_s

S = list(input())
N = int(input())
r_flag=False
for _ in range(N):
    Q = input()
    if Q.isdigit():
        r_flag=not r_flag
    else:
        q = Q.split()
        if r_flag:
            if q[1]=="1":
                S.append(q[2])
            else:
                S.insert(0,q[2])
        else:
            if q[1]=="1":
                S.insert(0,q[2])
            else:
                S.append(q[2])
if r_flag:
    print(''.join(reversed(S)))
else:print(''.join(S))


### FIXED CODE ###

from collections import deque

def rev(s):
    new_s = list(reversed(s))
    return new_s

S = deque(input())
N = int(input())
r_flag=False
for _ in range(N):
    Q = input()
    if Q.isdigit():
        r_flag=not r_flag
    else:
        q = Q.split()
        if r_flag:
            if q[1]=="1":
                S.append(q[2])
            else:
                S.appendleft(q[2])
        else:
            if q[1]=="1":
                S.appendleft(q[2])
            else:
                S.append(q[2])
if r_flag:
    print(''.join(reversed(S)))
else:print(''.join(S))
### BUGGY CODE ###

def get_(i):
    zero_len = 6-len(str(i))
    return '0'*zero_len+str(i)

N,M = list(map(int,input().split()))
N_list=[[] for n in range(N)]
M_list=[]

for m in range(M):
    P,Y=list(map(int,input().split()))
    N_list[P-1].append(Y)
    M_list.append([P,Y])
    
for n in N_list:
    n.sort()
    
for m in M_list:
    p=get_(m[0])
    
    i=N_list[m[0]-1].index(m[1])+1
    i=get_(i)
    
    print(p+i)


### FIXED CODE ###

def get_(i):
    zero_len = 6-len(str(i))
    return '0'*zero_len+str(i)

def get_idx(n,L):
    if len(L)<100:
        left=0
        right=len(L)
    else:    
        left=0
        right=len(L)

        i=0
        while i < 50:
            half=int((left+right)/2)
            if n <= L[half]:
                right = half
            else:
                left = half
            i+=1
        
    if left >= 1:
        left -= 1
        
    for i in range(left,right+1):
        if L[i]==n:
            return i

N,M = list(map(int,input().split()))
N_list=[[] for n in range(N)]
M_list=[]

for m in range(M):
    P,Y=list(map(int,input().split()))
    N_list[P-1].append(Y)
    M_list.append([P,Y])
    
for n in N_list:
    n.sort()
    
for m in M_list:
    p=get_(m[0])
    
    i=get_idx(m[1],N_list[m[0]-1])+1
    i=get_(i)
    
    print(p+i)
### BUGGY CODE ###

def main():
    N = int(input())
    X = tuple(map(int,input().split()))
    MOD = 10 ** 9 + 7
    goal = X[-1]
    ans = goal - X[0]
    x = 1
    count = 2
    for i in X[1:N-1]:
       tmp = goal - i
       ans = ((ans * count % MOD) + ((x*tmp)%MOD)) % MOD
       x *= count % MOD
       count += 1
    print(ans)
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N = int(input())
    X = list(map(int,input().split()))
    MOD = 10 ** 9 + 7
    goal = X[-1]
    ans = goal - X[0]
    fact = [1]
    fact_inv = [1]
    for i in range(10**5+5):
        new_fact = fact[-1]*(i+1)%MOD
        fact.append(new_fact)
    count = 1
    for i in range(1,N-1):
        count += 1
        tmp = goal - X[i]
        ans = ((ans * count) + ((fact[i] * tmp))) % MOD  
    print(ans)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

# https://atcoder.jp/contests/abc126/tasks/abc126_e
import itertools
from collections import Counter
from collections import defaultdict
import bisect


# Union find
class UnionFind():
    def __init__(self,size):
        self.table = [-1 for _ in range(size)]  # 負の値の場合根を表す。正の値は次の要素を返す、根まで続く

    #集合の代表を求める
    def find(self,x):
        while self.table[x] >= 0:
            #根に来た時,self.table[根のindex]は負の値なのでx = 根のindexで値が返される。
            x = self.table[x]
        return x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    #併合
    def union(self,x,y):
        s1 = self.find(x)#根のindex,table[s1]がグラフの高さ
        s2 = self.find(y)
        if s1 != s2:#根が異なる場合
            if self.table[s1] != self.table[s2]:#グラフの高さが異なる場合
                if self.table[s1] < self.table[s2]:
                    self.table[s2] = s1
                else:
                    self.table[s1] = s2
            else:
                #グラフの長さが同じ場合,どちらを根にしても変わらない
                #その際,グラフが1長くなることを考慮する
                #self.table[s1] += -1
                self.table[s2] = s1
        return

    def num_group(self):
        # print(self.table)
        return self.table.count(-1)


def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)

    for _ in range(M):
        x, y, z = map(int, input().split())
        uf.union(x - 1, y - 1)
    print(uf.num_group())

if __name__ == '__main__':
    main()


### FIXED CODE ###

# https://atcoder.jp/contests/abc126/tasks/abc126_e
import itertools
from collections import Counter
from collections import defaultdict
import bisect


# Union find
class UnionFind():
    def __init__(self,size):
        self.table = [-1 for _ in range(size)]  # 負の値の場合根を表す。正の値は次の要素を返す、根まで続く

    #集合の代表を求める
    def find(self,x):
        while self.table[x] >= 0:
            #根に来た時,self.table[根のindex]は負の値なのでx = 根のindexで値が返される。
            x = self.table[x]
        return x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def rewrite(self,x, p):
        while self.table[x] >= 0:
            #根に来た時,self.table[根のindex]は負の値なのでx = 根のindexで値が返される。
            tmp = x
            x = self.table[x]
            self.table[tmp] = p
        return

    #併合
    def union(self,x,y):
        s1 = self.find(x)#根のindex,table[s1]がグラフの高さ
        s2 = self.find(y)
        if s1 != s2:#根が異なる場合
            if self.table[s1] != self.table[s2]:#グラフの高さが異なる場合
                if self.table[s1] < self.table[s2]:
                    self.table[s2] = s1
                    self.rewrite(y, s1)
                else:
                    self.table[s1] = s2
                    self.rewrite(x, s2)
            else:
                #グラフの長さが同じ場合,どちらを根にしても変わらない
                self.table[s2] = s1
                self.rewrite(y, s1)
        return

    def num_group(self):
        # print(self.table)
        return self.table.count(-1)


def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)

    for _ in range(M):
        x, y, z = map(int, input().split())
        uf.union(x - 1, y - 1)
    print(uf.num_group())

if __name__ == '__main__':
    main()
### BUGGY CODE ###

# coding: utf-8

import collections

# 標準入力 <int><int>
N, X, Y = map(int, input().split())

br = []

for i in range(N):
  for j in range(i + 1, N):
    l = []
    #print("(" , i+1, j+1, ")", j-i, abs(X - (i + 1)) + 1 + abs(Y - (j + 1)), abs(Y - (i + 1)) + 1 + abs(X - (j + 1)))
    l.append(j - i)
    l.append(abs(X - (i + 1)) + 1 + abs(Y - (j + 1)))
    l.append(abs(Y - (i + 1)) + 1 + abs(X - (j + 1)))
    br.append(min(l))

c = collections.Counter(br)

for k, v in c.items():
  print(v)

for _ in range(N - 1 - len(c)):
  print(0)


### FIXED CODE ###

# coding: utf-8

import collections

# 標準入力 <int><int>
N, X, Y = map(int, input().split())

br = []

for i in range(N - 1):
  for j in range(i + 1, N):
    """
    #print("(" , i+1, j+1, ")", j-i, abs(X - (i + 1)) + 1 + abs(Y - (j + 1)), abs(Y - (i + 1)) + 1 + abs(X - (j + 1)))
    """
    br.append(min(j - i, abs(X - (i + 1)) + 1 + abs(Y - (j + 1)), abs(Y - (i + 1)) + 1 + abs(X - (j + 1))))

c = collections.Counter(br)

for k, v in c.items():
  print(v)

for _ in range(N - 1 - len(c)):
  print(0)
### BUGGY CODE ###

words = lambda t : list(map(t, input().split()))



n = int(input())
a = words(int)
b = words(int)

def getNext(i):
    if i == n-1:
        return 0
    else:
        return i+1

def getPrev(i):
    if i == 0:
        return n-1
    else:
        return i-1

import queue
q = queue.Queue()

def verify(i):
    if b[i] != a[i] and b[i] - (b[getNext(i)] + b[getPrev(i)]) >= a[i]:
        return True
    else:
        return False

for i in range(len(b)):
    if b[i] >= a[i] and verify(i):
        q.put(i)

ans = 0
succeed = True
while not q.empty():
    i = q.get()
    ni = getNext(i)
    pi = getPrev(i)
    #print(i, b)
    d = b[ni] + b[pi]
    if b[i] % d == a[i] % d:
        ans += b[i] // d - (a[i] // d)
        b[i] = a[i]
    else:
        ans += b[i] // d
        b[i] %= d
    if b[i] < a[i]:
        succeed = False
        break

    if verify(ni):
        q.put(ni)
    if verify(pi):
        q.put(pi)

for i in range(len(b)):
    if a[i] != b[i]:
        succeed = False
        break

if succeed:
    print(ans)
else:
    print(-1)


### FIXED CODE ###

words = lambda t : list(map(t, input().split()))



n = int(input())
a = words(int)
b = words(int)

def getNext(i):
    if i == n-1:
        return 0
    else:
        return i+1

def getPrev(i):
    if i == 0:
        return n-1
    else:
        return i-1

from collections import deque
q = deque()

def verify(i):
    if b[i] != a[i] and b[i] - (b[getNext(i)] + b[getPrev(i)]) >= a[i]:
        return True
    else:
        return False

for i in range(len(b)):
    if b[i] >= a[i] and verify(i):
        q.append(i)

ans = 0
succeed = True
while not len(q) == 0:
    i = q.popleft()
    ni = getNext(i)
    pi = getPrev(i)
    #print(i, b)
    d = b[ni] + b[pi]
    if b[i] % d == a[i] % d:
        ans += b[i] // d - (a[i] // d)
        b[i] = a[i]
    else:
        ans += b[i] // d
        b[i] %= d
    if b[i] < a[i]:
        succeed = False
        break
    if verify(ni):
        q.append(ni)
    if verify(pi):
        q.append(pi)

for i in range(len(b)):
    if a[i] != b[i]:
        succeed = False
        break

if succeed:
    print(ans)
else:
    print(-1)
### BUGGY CODE ###

import collections
s=str(input())
m=len(s)
for i in range(m-1):
    for j in range(i+1,m):
        target =s[i:j+1]
        c=collections.Counter(target)
        mc=c.most_common()
        if mc[0][1]>(j-i+1)//2:
            print(i+1,j+1)
            exit()
                
print('-1 -1')

### FIXED CODE ###

s=str(input())
L=len(s)
if L==1:
    print('-1 -1')
    exit()
elif L==2 and s[0]==s[1]:
    print('1 2')
    exit()
elif L==2 and s[0]!=s[1]:
    print('-1 -1')
    exit()
    


for i in range(L-1):
    if s[i]==s[i+1] and i+1==L-1:
        print(i,i+2)
        exit()
    elif s[i]==s[i+1] and i+1<L-1:
        print(i+1,i+3)
        exit()
        
for i in range(L-2):
    if s[i]==s[i+2]:
        print(i+1,i+3)
        exit()
 
print('-1 -1')
### BUGGY CODE ###

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

ans=0
i=0
while i<N:
    j=i+1+A[i]
    while j<N:
        if j-i==A[j]+A[i]:
            ans+=1
        j+=1
    i+=1

print(ans)

### FIXED CODE ###

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

J=[0]*N
j=0
while j<N:
    J[j]=j-A[j]
    j+=1

import collections
C = collections.Counter(J)

ans=0
i=0
while i<N:
    ans+=C[i+A[i]]
    i+=1

print(ans)
### BUGGY CODE ###

from collections import Counter

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

if len(a) == len(set(a)):
    for i in range(n):
        print(0)
else:
    kw = Counter(a)
    for i in range(n):
        ans = 0
        for k, v in kw.most_common():
            if k == a[i]:
                ans += (v - 1) * (v - 2) // 2
            else:
                ans += v * (v - 1) // 2

        print(ans)


### FIXED CODE ###

from collections import Counter

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

if len(a) == len(set(a)):
    for i in range(n):
        print(0)
else:
    kw = Counter(a)
    ans = sum([x * (x - 1) // 2 for x in kw.values()])

    for i in range(n):
        print(ans - kw[a[i]] + 1)
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
def ligh(li):
  for x in range(k):
    if li==[n]*n:
      return li
    ne=[0]*(n+1)
    zr=[]
    lis=[]
    for (i,a) in zip(range(n),li):
      if a==0:
        zr.append(i)
      else:
        ne[max(0,i-a)]+=1
        ne[min(i+a+1,n)]-=1

    for i in range(1,n):
      ne[i]+=ne[i-1]
    for i in zr:
      ne[i]+=1
    li=ne[:-1]
    #print(li)
  return li

for i in ligh(a):
  print(i,end=" ")


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
def ligh(li):
  for x in range(k):
    if li==[n]*n:
      return li
    ne=[0]*(n+1)
    zr=[]
    lis=[]
    for (i,a) in zip(range(n),li):
      if a==0:
        zr.append(i)
      else:
        ne[max(0,i-a)]+=1
        ne[min(i+a+1,n)]-=1

    for i in range(1,n):
      ne[i]+=ne[i-1]
    for i in zr:
      ne[i]+=1
    li=ne[:-1]
    #print(li)
  return li

for i in ligh(a):
  print(i,end=" ")
### BUGGY CODE ###

S =input()

input_line = int(input())

# alpha = alpha[::-1]

for i in range(input_line):
    action = list(input())
    # print(action)
    if action[0]=="1":
        S = S[::-1]
    else:
        if action[2] == "2":
            S += action[4]
        elif action[2] == "1":
            S = action[4]+S

print(S)
    

### FIXED CODE ###

S =input()

input_line = int(input())

flag0 = ""
flag1 = ""
flag = 0


for i in range(input_line):
    action = list(input())
    # print(flag0,flag1)
    # print(action)
    if action[0]=="1":
        if flag == 0:
            flag = 1
        else:
            flag = 0
    else:
        # print("check")
        if action[2] == "2":
            
            if flag == 0:
                flag1 = flag1 + action[4]
            elif flag ==1:
                flag0 = action[4] + flag0
        else:
            if flag == 0:
                flag0 = action[4] + flag0
            
            elif flag == 1:
                flag1 += action[4]
                
S = flag0 + S + flag1
if flag == 1:
    S = S[::-1]
print(S)
### BUGGY CODE ###

def calc(a, b):
    k = 0
    if a == 0 or b == 0:
        return True
    while 2 ** k  - 1 <= a + b:
        if 2 ** k - 1 == a + b:
            return True
        k += 1
    return False

L = int(input(),2)
count = 0
for i in range(L + 1):
    for j in range(L - i + 1):
        if calc(i, j):
            count += 1

print(count % (10 ** 9 + 7))

### FIXED CODE ###

L = input()
#dp1[k] := k桁目までを確定させ、その時点でA+BがL以下が確定
#dp2[k] := k桁目までを確定させ、その時点でA+BがL以下が確定していない
dp1 = [0 for i in range(len(L))]
dp2 = [0 for i in range(len(L))]
mod = 10**9 + 7
dp1[0] = 1 # A,Bの最上位bitが(0,0)
dp2[0] = 2 # A,Bの最上位bitが(0,1), (1,0)の二通り
#最上位bitを(1,1)にしてしまうと、Lを超えてしまうのでない
for i in range(1,len(L)):
    #dp1の更新から行う
    if L[i] == '1':
        dp1[i] = dp1[i-1] * 3 + dp2[i-1]
        dp2[i] = dp2[i-1] * 2
    else:
        dp1[i] = dp1[i-1] * 3
        dp2[i] = dp2[i-1]
    dp1[i] %= mod
    dp2[i] %= mod
print((dp1[-1] + dp2[-1]) % mod)
### BUGGY CODE ###

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

mod = 998244353

dp = [[0] * n for _ in range(3000 + 1)]

# init
dp[a[0]][0] = 1

for i in range(1, s + 1):
    for j in range(1, n):
        if i == a[j]:
            dp[i][j] = dp[i][j-1] + j + 1
        elif i - a[j] > 0:
            dp[i][j] = dp[i][j-1] + dp[i - a[j]][j - 1]
        else:
            dp[i][j] = dp[i][j-1]

ans = 0
for j in range(n):
    ans += dp[s][j]
    ans %= mod

print(ans % mod)


### FIXED CODE ###

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

mod = 998244353

dp = [[0] * n for _ in range(3000 + 1)]

# init
dp[a[0]][0] = 1

for i in range(1, s + 1):
    for j in range(1, n):
        if i == a[j]:
            dp[i][j] = (dp[i][j-1] + j + 1) % mod
        elif i - a[j] > 0:
            dp[i][j] = (dp[i][j-1] + dp[i - a[j]][j - 1]) % mod
        else:
            dp[i][j] = dp[i][j-1] % mod



ans = 0
for j in range(n):
    ans += dp[s][j]

print(ans % mod)
### BUGGY CODE ###

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

def lcm(x,y):
  return x*y//gcd(x,y)
a, b, c, d = list(map(int, input().split()))

num_mul_c = 0
num_mul_d = 0
num_mul_cd = 0

n=1
while True:
    nc = n*c
    if nc>b:
        break
    if (a<=nc)and(nc<=b):
        num_mul_c += 1
    n += 1
n=1
while True:
    nd = n*d
    if nd>b:
        break
    if (a<=nd)and(nd<=b):
        num_mul_d += 1
    n += 1
n=1
cd = int((c*d)//gcd(c, d))
while True:
    ncd = cd*n
    if ncd>b:
        break
    if (a<=ncd)and(ncd<=b):
        num_mul_cd += 1
    n += 1
print(b-a+1 - num_mul_c - num_mul_d + num_mul_cd)

### FIXED CODE ###

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

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

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

print(
    b - (b//c) - (b//d) + (b//cd) \
    -((a-1) - ((a-1)//c) - ((a-1)//d) + ((a-1)//cd))
    )
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
ans_list = []
for i in range(q):
    ans = 0
    l, r = map(int, input().split())
    S = s[l-1:r]
    for i in range(len(S)-1):
        if S[i] == "A" and S[i+1] == "C":
            ans += 1
    ans_list.append(ans)
for i in range(q):
    print(ans_list[i])

### FIXED CODE ###

n, q = map(int, input().split())
s = input()
ans_list = [0]*n
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        ans_list[i+1] = ans_list[i] + 1
    else:
        ans_list[i+1] = ans_list[i]
for _ in range(q):
    a, b = map(int, input().split())
    print(ans_list[b-1]-ans_list[a-1])
### BUGGY CODE ###

import sys

input = sys.stdin.readline

def main():
    n = int(input().rstrip())
    a = list(map(int, input().rstrip().split()))
    count = 0
    b = []
    for i in range(n):
      flag = True
      if not a[i] in b:
        for x in b:
          if a[i] % x == 0:
            flag = False
            break
        if flag:
          for k in range(n):
            if i != k and a[i] % a[k] == 0:
              flag = False
              break
        if flag:
          count += 1
          b.append(a[i])
    print(count)
  
if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import Counter
import sys
n=int(input())
a=sorted(list(map(int,input().split())))
 
c=[1 for i in range(10**6+1)]
d = Counter(a)
s = list(set(a))
count = 0
if d[1] == 1:
  print(1)
  sys.exit()
elif d[1] >=2:
  print(0)
  sys.exit()
for x in s:
  t = x * 2
  while t <= 10 ** 6:
    c[t] = 0
    t += x
 
for x in a:
  if d[x] == 1 and c[x] == 1:
    count += 1
print(count)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    for a in A:
        ans *= a
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    INF = 10 ** 18
    ans = 1
    is_INF = False
    for a in A:
        ans *= a
        if ans > INF:
            is_INF = True
            break
    if is_INF:
        if 0 in A:
            print(0)
        else:
            print(-1)
    else:
        print(ans)
if __name__ == "__main__":
    main()