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

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

res = 1
for a in lst:
    res = res*a

if res > 1000000000000000000:
    print("-1")
else:
    print(res)

### FIXED CODE ###

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

if 0 in lst:
    print("0")
    quit()

res = 1
for a in lst:
    res = res*a
    if res > 1000000000000000000:
        print("-1")
        quit()
    else:
        pass

print(res)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import heapq

n,m,s,t = map(int, input().split())
s -= 1
t -= 1
e = [[] for _ in range(n)]
for _ in range(m):
    v,u,a,b = map(int, input().split())
    v -= 1
    u -= 1
    e[v].append((u,(a,b)))
    e[u].append((v,(a,b)))


def dijkstra(e,n,s,cu):
    inf = 10**15
    d = [inf]*n
    d[s] = 0
    q = [(s,0)]
    heapq.heapify(q)

    while len(q)>0:
        v,c = heapq.heappop(q)
        if d[v]<c:
            continue
        for u,ud in e[v]:
            if d[u]>c+ud[cu]:
                d[u] = c + ud[cu]
                heapq.heappush(q, (u, d[u]))
    return d


da = dijkstra(e,n,s,0)
db = dijkstra(e,n,t,1)
res = [0]*n
m = 10**15
for i in range(n-1,-1,-1):
    r = da[i]+db[i]
    m = min(m,r)

    res[i] = m

x = 10**15
for i in range(n):
    print(x - res[i])

### FIXED CODE ###

# -*- coding: utf-8 -*-
import heapq
n,m,s,t = map(int, input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    u,v,a,b = map(int, input().split())
    g[u].append((v,(a,b)))
    g[v].append((u,(a,b)))

inf = 10**18
def dijkstra(s, currency):
    d = [inf]*(n+1)
    d[s] = 0

    que = [(d[s],s)]
    heapq.heapify([que])
    while len(que)>0:
        _,v = heapq.heappop(que)
        for u,c in g[v]:
            if d[v]+c[currency]>=d[u]:
                continue
            d[u] = d[v]+c[currency]
            heapq.heappush(que, (d[u], u))
    return d

yen_c = dijkstra(s,0)
snuuk_c = dijkstra(t,1)

res = [0]*n
res[n-1] = yen_c[n] + snuuk_c[n]
for i in range(n-2,-1,-1):
    res[i] = min(res[i+1], yen_c[i+1]+snuuk_c[i+1])

for r in res:
    print(10**15-r)
### BUGGY CODE ###

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

WA = [sum(A[n:])%mod for n in range(N)]

total = 0
for i in range(N-1):
    total += (A[i] * WA[i+1]) % mod

print(total%mod)

### FIXED CODE ###

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

wa = sum(A)

total = 0
for n in range(N-1):
    wa -= A[n]

    total += A[n] * wa
    total %= mod

print(total)
### BUGGY CODE ###

def calc(n):
  return (n+1)/2.0

N,K=map(int,input().split())
P=tuple(map(int,input().split()))
Q=tuple(map(calc,P))

cnt=0.0
for i in range(N-K+1):
  S=sum(Q[i:i+K])
  cnt=max(cnt,S)

print(cnt)

### FIXED CODE ###

import numpy as np
N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[0]
def ex(A):
  return (1+A)/2.0
for i in range(N):
  Q.append(ex(P[i]))
Q=np.array(Q)
R=Q.cumsum()
ans=0
for i in range(K,N+1):
  S=R[i]-R[i-K]
  if ans<S:
    ans=S
print(ans)
### BUGGY CODE ###

has_duplicates= lambda seq:len(seq) == len(set(seq))
def main():
    n=int(input())
    l=list(map(int,input().split()))
    tel=[-1,-1,-1]
    temp=0
    bn=0
    tc=0
    pc=0
    i=0
    while len(bin(i))-3<n:
        bn=bin(i)
        if str(bn).count('1')==3:
            tc=0
            tel=[-1,-1,-1]
            for j in range(len(str(bn)[2:])):
                if (i>>j)&1:
                    tel[tc]=l[n-j-1]
                    tc+=1
            if has_duplicates(tel):
                tel.sort()
                if abs(tel[1]-tel[2])<tel[0] and tel[0] < tel[1]+tel[2]:
                    pc+=1
        i+=1
    print(pc)
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n=int(input())
    l=list(map(int,input().split()))
    ans=0
    for i in range(n):
        for k in range(i+1,n):
            for j in range(k+1,n):
                temp=[l[i],l[k],l[j]]
                if len(set(temp))==len(temp):
                    temp.sort()
                    if temp[0]+temp[1]>temp[2]:
                        ans+=1
    print(ans)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

from statistics import median
q0=int(input())
ind2=0
ind1=0
a=[]
b=0
for iii in range(q0):
  q=[int(_) for _ in input().split()]
  lenq=len(q)
  if lenq==1:
    a.sort()
    la=len(a)-1
    ind1=a[la//2]
    ind2=sum([abs(_a-ind1) for _a in a])+b
    print(ind1,ind2)
  elif lenq==3:
    a.append(q[1])
    b+=q[2]

### FIXED CODE ###

import heapq as h
q_num=int(input())
bsum=0
high=[]
low=[]
asum=0
for iii in range(q_num):
  q=[int(_) for _ in input().split()]
  if q[0]==1:
    bsum+=q[2]
    if len(low)==0:
      h.heappush(low,-q[1])
    else:
      asum+=abs(q[1]+low[0])
      if -low[0]>=q[1]:
        h.heappush(low,-q[1])
      else:
        h.heappush(high,q[1])
      
    if len(low)>=len(high)+2:
      ltoh=h.heappop(low)
      h.heappush(high, -ltoh)
    elif len(high)>=len(low)+1:
      ltoh=h.heappop(high)
      asum+=-low[0]-ltoh
      h.heappush(low, -ltoh)
  else:
    print(-low[0],asum+bsum)
### BUGGY CODE ###

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Factoring by trial split -- START --
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l
# Factoring by trial split --- END ---

# Summarize count of factor within list -- START --
def summarizeList(l):
  sl=sorted(l)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res
# Summarize count of factor within list --- END ---

def main():
  n=I()
  l=LI()
  l.sort()
  a=[1]*n

  for i,x in enumerate(l):
    if a[i]==0:
      continue
    for j in range(i+1,n):
      y=l[j]
      if x==y:
        a[i]=0
      if a[j]==0:
        continue
      if y%x==0:
        a[j]=0

  # print(a)
  return sum(a)

# main()
print(main())


### FIXED CODE ###

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

M=[0]*1001000

def main():
  n=I()
  l=LI()
  l.sort()
  MAX=l[-1]

  for x in l:
    M[x]+=1
    if M[x]==2:
      continue

    for i in range(2,1001000):
      y=i*x
      if MAX<y:
        break

      M[y]+=1

  ans=0
  for x in l:
    if M[x]==1:
      ans+=1

  # print(M[:100])
  return ans

# main()
print(main())
### BUGGY CODE ###

import math

n = int(input())
A = [None]*n
A = map(int, input().split())
T = math.prod(A)
if T > pow(10,18):
    print(-1)
else:
    print(T)



### FIXED CODE ###

n = int(input())
res = 1
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    for i in range(n):
        res *= a[i]
        if res > 10**18:
            print(-1)
            quit()
    print(res)
### BUGGY CODE ###

import math
from functools import lru_cache

n=int(input())
@lru_cache()
def sosu(l):
  
  if l ==2:
    return 1
  elif l % 2==0 or l==1 or l==3/2:
    return 0
  else:
    for d in range(3, math.floor(math.sqrt(l))+1,2):
      if l % d == 0:
        return 0
        break
    else:
      return 1

li=[]
for j in range(1,100001):
  li.append(sosu(j)*sosu((j+1)/2))

for i in range(n):
  a,b=[int(i) for i in input().split()]
  print(sum(li[a-1:b]))

### FIXED CODE ###

import math
from functools import lru_cache

n=int(input())
@lru_cache()
def sosu(l):
  if l ==2:
    return 1
  elif l % 2==0 or l==1 or l==3/2 or l==0:
    return 0
  else:
    for d in range(3, math.floor(math.sqrt(l))+1,2):
      if l % d == 0:
        return 0
        break
    else:
      return 1

m=0
li=[]
for j in range(0,100001):
  m+=sosu(j)*sosu((j+1)/2)
  li.append(m)

for i in range(n):
  a,b=[int(i) for i in input().split()]
  print(li[b]-li[a-1])
### BUGGY CODE ###

def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


if __name__ == '__main__':
    n = int(input().strip())
    fk = 1
    k = 1

    start_point = [[10000000, 838627288460105],
                   [3900000, 89047258904088],
                   [3500000, 64954450698416],
                   [3000000, 38711715279705],
                   [2500000, 17755581570386],
                   [2000000, 30326413365285],
                   [1500000, 16734924755096],
                   [1000000, 7235062807366],
                   [100000, 60838190672]]
    for sp in start_point:
        if sp[0] < n:
            fk = sp[1]
            k = sp[0]
            break


    for i in range(k + 1, n + 1):
        fk += i * len(make_divisors(i))
    print(fk)


### FIXED CODE ###

if __name__ == '__main__':
    n = int(input().strip())
    ans = 0

    for i in range(1, n + 1):
        limit = int(n / i)
        ans += limit * (limit + 1) * i / 2
    print(int(ans))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
a2 = [0]
cnt = 0
for i in a:
    a2.append(a2[-1] + i)

info = list(set(a2))
for j in info:
    tmp = a2.count(j)
    if tmp == 2:
        cnt += 1
    elif tmp == 1:
        continue
    else:
        cnt += tmp * (tmp - 1) // 2
print(cnt)

### FIXED CODE ###


n = int(input())
a = list(map(int, input().split()))
a2 = [0]
cnt = 0
tmp = 0
for i in a:
    a2.append(a2[-1] + i)

a2.sort()
for j in range(n):
    if a2[j] == a2[j+1]:
        tmp += 1
    else:
        if tmp >= 2:
            cnt += tmp*(tmp+1)//2
            tmp = 0
        else:
            cnt += tmp
            tmp = 0
if tmp != 0:
    if tmp >= 2:
        cnt += tmp*(tmp+1)//2
        tmp = 0
    else:
        cnt += tmp
        tmp = 0
print(cnt)
### BUGGY CODE ###

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

c=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if l[i] < l[j]+l[k] and l[j] < l[i]+l[k] and l[k] < l[i]+l[j]:
        c += 1

print(c)


### FIXED CODE ###

import bisect

n=int(input())
l=sorted(map(int,input().split()))

t=0
for i in range(n):
  for j in range(i+1,n):
    a = j+1
    b = bisect.bisect_left(l,l[i]+l[j])
    t += b-a if b>a else 0

print(t)
### BUGGY CODE ###

from functools import reduce
n,k=map(int,input().split())
a=list(map(int,input().split()))

d=list(map(lambda i:reduce(lambda x,y:x*y,a[i:i+k]),range(n-k+1)))
dd=list(map(lambda x,y:'Yes' if y>x else 'No',d[:-1],d[1:]))
list(map(print,dd))

### FIXED CODE ###

from functools import reduce
n,k=map(int,input().split())
a=list(map(int,input().split()))
d1,d2=a[:n-k],a[k:n]
dd=list(map(lambda x,y:'Yes' if y>x else 'No',d1,d2))
for i in range(len(dd)):print(dd[i])
### BUGGY CODE ###

A, B, N = map(int, input().split())
ans = 0
for x in range(1,min(B,N)+1):
  buf = ((A*x)//B) - (A*(x//B))
  ans = max(ans,buf)
print(ans)

### FIXED CODE ###

A, B, N = map(int, input().split())
ans = 0
x = min(B-1,N)
print((A*x)//B)
### BUGGY CODE ###

# Aizu Problem 0080: Third Root
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def third_root(q):
    x = q / 2
    while abs(x**3 - q) > 1e-8:
        x = x - (x**3 - q) / (3 * x**2)
    return x


for line in sys.stdin:
    n = int(line)
    if n == -1:
        break
    print("%.6f" % third_root(n))

### FIXED CODE ###

# Aizu Problem 0080: Third Root
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def third_root(q):
    x = q / 2
    while abs(x**3 - q) >= 1e-5 * q:
        x = x - (x**3 - q) / (3 * x**2)
    return x


for line in sys.stdin:
    n = int(line)
    if n == -1:
        break
    print("%f" % third_root(n))
### BUGGY CODE ###

from collections import deque
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())

maze = [list(input()) for i in range(h)]
ans = [[-1]*w for i in range(h)]

dx=[0,1,0,-1]
dy=[1,0,-1,0]

ans[ch-1][cw-1]=0
def bfs(ans):
  qu = deque([])
  qu.append([cw-1,ch-1])
  while qu:
    zahyou=qu.popleft()
    x=zahyou[0]
    y=zahyou[1]
    count=0
    for i in range(4):
      if 0 <= x+dx[i] < w and 0 <= y+dy[i] < h:
        if maze[y+dy[i]][x+dx[i]]=="." and (ans[y+dy[i]][x+dx[i]]>ans[y][x] or ans[y+dy[i]][x+dx[i]]==-1):
          qu.append([x+dx[i],y+dy[i]])
          ans[y+dy[i]][x+dx[i]] = ans[y][x]
          count+=1
    if count!=4:
      for i in range(x-2,x+3):
        for j in range(y-2,y+3):
          if 0<=i<w and 0<=j<h:
            if maze[j][i]=="." and (ans[j][i]>ans[y][x]+1 or ans[j][i]==-1):
              ans[j][i]=(ans[y][x]+1)
              qu.append([i,j])

bfs(ans)
print(ans[dh-1][dw-1])
  

### FIXED CODE ###

from collections import deque
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())

maze = [list(input()) for i in range(h)]
ans = [[-1]*w for i in range(h)]

dx=[0,1,0,-1]
dy=[1,0,-1,0]

ans[ch-1][cw-1]=0
def bfs(ans):
  qu = deque([])
  qu.append([cw-1,ch-1])
  while qu:
    zahyou=qu.popleft()
    x=zahyou[0]
    y=zahyou[1]
    count=0
    for i in range(4):
      if 0 <= x+dx[i] < w and 0 <= y+dy[i] < h:
        if maze[y+dy[i]][x+dx[i]]=="." and (ans[y+dy[i]][x+dx[i]]>ans[y][x] or ans[y+dy[i]][x+dx[i]]==-1):
          qu.appendleft([x+dx[i],y+dy[i]])
          ans[y+dy[i]][x+dx[i]] = ans[y][x]
          count+=1
    if count!=4:
      for i in range(x-2,x+3):
        for j in range(y-2,y+3):
          if 0<=i<w and 0<=j<h:
            if maze[j][i]=="." and (ans[j][i]>ans[y][x]+1 or ans[j][i]==-1):
              ans[j][i]=(ans[y][x]+1)
              qu.append([i,j])

bfs(ans)
print(ans[dh-1][dw-1])
### BUGGY CODE ###

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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys


def solve(N, S):
    S = sorted(S)
    used = [S[-1]]
    unused = S[:-1]
    num_of_generation = 1
    while len(used) < 2 ** N:
        next_used = []
        for i in range(num_of_generation):
            loc = bisect_left(unused, used[i])
            if loc == 0:
                return False
            else:
                next_used.append(used[i])
                next_used.append(unused[loc - 1])
                del unused[loc - 1]
        used = next_used
        num_of_generation *= 2
    return True


N = int(input())
S = list(map(int, input().split()))
print("Yes" if solve(N, S) else "No")


### FIXED CODE ###

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

# 参考: https://atcoder.jp/contests/abc140/submissions/7402925
# できるだけ大きいスライムを貪欲に生んでいく
# 自力コードはTLEのためmaspyさんのコードを参考にした

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys


def solve(N, S):
    S = sorted(S)
    used = [S[-1]]
    unused = S[:-1]
    for _ in range(N):
        next_used = []
        next_unused = []
        for p in used[::-1]:
            while unused:
                x = unused.pop()
                if x < p:
                    next_used.append(x)
                    break
                else:
                    next_unused.append(x)
                    continue
        used += next_used
        used.sort()
        unused = unused + next_unused[::-1]
    
    return len(used) == (2**N)


N = int(input())
S = list(map(int, input().split()))
print("Yes" if solve(N, S) else "No")
### BUGGY CODE ###

import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))

safe = [True]*(N+1)
for i in range(M):
    safe[(a[i])] = False


def func(i):
    global safe

    if not(safe[i]):
        return 0
    if i == 0:
        return 1
    if i == 1:
        return 1
    if i >= 2:
        return func(i-1)+func(i-2)


print(func(N) % 1000000007)

# print(a)
# dp = [0]*(N+1)
# print('safe', safe)
# dp[0] = 1
# if safe[1]:
#    dp[1] = 1
# for i in range(2, N+1):
#    if safe[i]:
#        dp[i] = dp[i-1]+dp[i-2]
#    if not(safe[i]):
#        dp[i] = 0
# print('dp', dp)
# print(dp[N] % 1000000007)


### FIXED CODE ###

import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))
# print(a)
dp = [0]*(N+1)
#dp[0] = 1
#dp[1] = 1
# for i in range(2, N):
#    dp[i] = dp[i-1]+dp[i-2]
safe = [True]*(N+1)
for i in range(M):
    safe[(a[i])] = False
#print('safe', safe)
dp[0] = 1
if safe[1]:
    dp[1] = 1
for i in range(2, N+1):
    if safe[i]:
        dp[i] = dp[i-1]+dp[i-2]
    if not(safe[i]):
        dp[i] = 0
#print('dp', dp)
print(dp[N] % 1000000007)
### BUGGY CODE ###


class Unionfind:
     
    def __init__(self,n):
        self.uf = [-1]*n
 
    def find(self,x):
        if self.uf[x] < 0:
            return x
        else:
            self.uf[x] = self.find(self.uf[x])
            return self.uf[x]
 
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.uf[x] > self.uf[y]:
            x,y = y,x
        self.uf[x] += self.uf[y]
        self.uf[y] = x
        return True
 
    def size(self,x):
        x = self.find(x)
        return -self.uf[x]


n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
xy2 = [[x[0],x[1],i] for (i,x) in enumerate(xy)]
xy2.sort()
u = Unionfind(n)

s = set()
for i,X in enumerate(xy2):
    x,y,ind = X
    check = True
    cand = []
    mi = -1
    count = n+5
    for j in s:
        if y > xy[j][1]:
            check = False
            u.union(ind,j)
            cand.append(j)
            if count > xy[j][1]:
                count = xy[j][1]
                mi = j
        
    if check:
        s.add(ind)
    else:
        for j in cand:
            if j == mi:
                continue
            s.remove(j)
for i in range(n):
    print(u.size(i))



### FIXED CODE ###

import sys
input = sys.stdin.readline

class Unionfind:
     
    def __init__(self,n):
        self.uf = [-1]*n
 
    def find(self,x):
        if self.uf[x] < 0:
            return x
        else:
            self.uf[x] = self.find(self.uf[x])
            return self.uf[x]
 
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.uf[x] > self.uf[y]:
            x,y = y,x
        self.uf[x] += self.uf[y]
        self.uf[y] = x
        return True
 
    def size(self,x):
        x = self.find(x)
        return -self.uf[x]

def main():
    n = int(input())
    xy = [list(map(int,input().split())) for i in range(n)]
    xy2 = [[x[0],x[1],i] for (i,x) in enumerate(xy)]
    xy2.sort()
    u = Unionfind(n)

    l = []
    for x,y,ind in xy2:
        M = y
        le = ind
        while l and xy[l[-1]][1] < y:
            v = l.pop()
            if M > xy[v][1]:
                M = xy[v][1]
                le = v
            u.union(ind,v)
        l.append(le)
    for i in range(n):
        print(u.size(i))

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

S = input()
Q = int(input())
queries = []
for _ in range(Q):
    queries.append(input())

for query in queries:
    if query == "1":
        S = S[::-1]
    else:
        _, F, C = list(query.split())
        if F == "1":
            S = C + S
        else:
            S = S + C

print(S)

### FIXED CODE ###

S = input()
Q = int(input())
queries = []
for _ in range(Q):
    queries.append(input())

# for query in queries:
#     if query == "1":
#         S = S[::-1]
#     else:
#         _, F, C = list(query.split())
#         if F == "1":
#             S = C + S
#         else:
#             S = S + C
# print(S)

left = ""
right = ""
target = 0

for query in queries:
    if query == "1":
        target = 1 - target
    else:
        _, F, C = list(query.split())
        if F == "1":
            if target == 0:
                left += C
            else:
                right += C
        else:
            if target == 0:
                right += C
            else:
                left += C
if target == 0:
    print("{}{}{}".format(left[::-1], S, right))
else:
    print("{}{}{}".format(right[::-1], S[::-1], left))
### BUGGY CODE ###

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

ans = math.prod(A)

print('-1' if ans > 10**18 else ans)


### FIXED CODE ###

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

A.sort()

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

ans = 1
for a in A[::-1]:
  ans *= a
  if ans > 10**18:
    print('-1')
    break
else:
  print(ans)
### BUGGY CODE ###

N = int(input())
L = []
Dic = {}
for n in range(N):
    S = input()
    L.append(S)
Unique = list(set(L))

for i in Unique:
    Dic[i]=0

for j in L:
    Dic[j] = Dic[j] + 1
    
max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max(Dic.values())]
max_k_list = sorted(max_k_list)
for t in max_k_list:
    print(t)

### FIXED CODE ###

from collections import Counter
N = int(input())
L = [input() for _ in range(N)]
#for n in range(N):
    #S = input()
    #L.append(S)
Dic = Counter(L)
max_value = max(Dic.values())
max_k_list = [i for i, j in Dic.items() if j == max_value]
max_k_list = sorted(max_k_list)
for t in max_k_list:
    print(t)