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

n, m = map(int, input().split())
l, r = map(int, input().split())
ans = [x for x in range(l, r+1)]
if m > 1:
    for i in range(m-1):
        l, r = map(int, input().split())
        ans = [x for x in range(l, r+1) if x in ans]

print(len(ans))


### FIXED CODE ###

n, m = map(int, input().split())
l, r = map(int, input().split())
ans = -1
if m > 1:
    for i in range(m-1):
        _l, _r = map(int, input().split())
        if (l < _l <= r):
            l = _l
        if (l <= _r < r):
            r = _r
        if _r < l or r < _l:
            ans = 0
            print(ans)
            break

if ans == -1:
    print(r-l+1)
### BUGGY CODE ###

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

printed = False
if 0 in a:
    print(0)
    printed = True

ans = 1

for x in a:
    ans *= x
    if ans > 1e18:
        if not printed:
            print(-1)
        printed = True
    
if not printed:
    print(ans)

### FIXED CODE ###

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

printed = False
if 0 in a:
    print(0)
    printed = True

ans = 1

for x in a:
    ans *= x
    if ans > 1e18:
        if not printed:
            print(-1)
            printed = True
        break    
    
if not printed:
    print(ans)
### BUGGY CODE ###

import math

n = int(input())
aL = list(map(int, input().split(" ")))
q = int(input())
bcL = [list(map(int, input().split(" "))) for _ in range(q)]

d = {}
for i in range(n):
    if aL[i] in d:
        d[aL[i]] += 1
    else:
        d[aL[i]] = 1

for b, c in bcL:
    if b in d.keys():
        if c in d:
            d[c] += d[b]
        else:
            d[c] = d[b]
        del d[b]

    _sum = 0
    for k, v in d.items():
        _sum += k * v
    print(_sum)

### FIXED CODE ###

import math

n = int(input())
aL = list(map(int, input().split(" ")))
q = int(input())
bcL = [list(map(int, input().split(" "))) for _ in range(q)]

sums = [0 for i in range(10**5 + 1)]

for a in aL:
    sums[a] += 1

_sum = 0
for i, a in enumerate(sums):
    _sum += i * a

for b, c in bcL:
    _sum += (c - b) * sums[b]

    sums[c] += sums[b]
    sums[b] = 0
    print(_sum)
### BUGGY CODE ###

#!/usr/bin/env python3
n,*a=map(int,open(0).read().split())
s = [0]
ans = 0
for i in a:
    s.append(s[-1]+i)
for i in range(1,n+1):
    ans += s[:i].count(s[i])
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict
n,*a=map(int,open(0).read().split())
d = defaultdict(int)
s = 0
ans = 0
d[0] += 1
for i in a:
    s += i
    ans += d[s]
    d[s] += 1
print(ans)
### BUGGY CODE ###

s=input()
line=[int(c) for c in s]
length=len(line)
while 1:
  line2=[]
  for i in range(len(line)-1):
    if line[i]!=2 and line[i]!=line[i+1]:
      line[i]=2
      line[i+1]=2
  if 2 in line:
    line=[i for i in line if i!=2]
  else:
    break
print(length-len(line))

### FIXED CODE ###

s=str(input())
if s.count('1')>s.count('0'):
    print(s.count('0')*2)
else:
    print(s.count('1')*2)
### BUGGY CODE ###

beforex=[]
beforey=[]
sum=0
for i in range(int(input())):
  xy=list(map(int,input().split()))
  beforex.append(xy[0])
  beforey.append(xy[1])

for i in range(len(beforex)-1):
  for j in range(i,len(beforex)):
    sum=max(sum,abs(beforex[i]-beforex[j])+abs(beforey[i]-beforey[j]))

print(sum)

### FIXED CODE ###

beforex_plus_y=[]
beforex_minus_y=[]
for i in range(int(input())):
  xy=list(map(int,input().split()))
  beforex_plus_y.append(xy[0]+xy[1])
  beforex_minus_y.append(xy[0]-xy[1])

print(max(max(beforex_plus_y)-min(beforex_plus_y),max(beforex_minus_y)-min(beforex_minus_y)))
### BUGGY CODE ###

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

t_max = -1
t_i = 0
a_max = -1
a_i = 0
ans = 1
mod = 10 ** 9 + 7

for i in range(N):
    t = t_list[i]
    a = a_list[i]

    if t > t_max:
        t_max = t
        t_i = i
    if a >= a_max:
        a_max = a
        a_i = i
if a_max == t_max and t_i <= a_i:
    prev_a = a_list[-1]
    prev_t = t_list[0]
    for i in range(1, t_i):
        t = t_list[i]
        if t == prev_t:
            ans *= prev_t % mod
        prev_t = t
    for i in range(N-2, t_i, -1):
        a = a_list[i]
        if a == prev_a:
            ans *= prev_a % mod
        prev_a = a
    print(ans % mod)
else:
    print(0)


### FIXED CODE ###

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

t_max = -1
t_i = 0
a_max = -1
a_i = 0
ans = 1
mod = 10 ** 9 + 7

for i in range(N):
    t = t_list[i]
    a = a_list[i]
    if t > t_max:
        t_max = t
        t_i = i
    if a >= a_max:
        a_max = a
        a_i = i
if a_max == t_max and t_i <= a_i:
    prev_a = a_list[-1]
    prev_t = t_list[0]
    for i in range(1, t_i):
        t = t_list[i]
        if t == prev_t:
            ans *= prev_t
            ans %= mod
        prev_t = t
    for i in range(N-2, t_i, -1):
        a = a_list[i]
        if a == prev_a:
            ans *= prev_a
            ans %= mod
        prev_a = a
    print(ans % mod)
else:
    print(0)
### BUGGY CODE ###

class UnionFind:
    def __init__(self, size):
        self.rank = [-1 for _ in range(size)]
        self.number = [1 for _ in range(size)]

    def find(self, x):
        while self.rank[x] >= 0:
            x = self.rank[x]
        return x

    def union(self, s1, s2):
        if s1 == s2:
            return
        if self.rank[s1] == self.rank[s2]:
            self.rank[s1] -= 1
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        elif self.rank[s1] < self.rank[s2]:
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        else:
            self.rank[s1] = s2
            self.number[s2] += self.number[s1]


n, K, L = map(int, input().split())
pq = [tuple(int(x) for x in input().split()) for _ in range(K)]
rs = [tuple(int(x) for x in input().split()) for _ in range(L)]

uk = UnionFind(n)
for p, q in pq:
    rp = uk.find(p - 1)
    rq = uk.find(q - 1)
    if rp != rq:
        uk.union(rp, rq)

ul = UnionFind(n)
for p, q in rs:
    rp = ul.find(p - 1)
    rq = ul.find(q - 1)
    if rp != rq:
        ul.union(rp, rq)

res = [[uk.find(i), ul.find(i)] for i in range(n)]

ans = ['' for _ in range(n)]
for i in range(n):
    ans[i] = str(res.count(res[i]))

print(' '.join(ans))




### FIXED CODE ###

from collections import Counter

class UnionFind:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def find_root(self, x):
        if self.p[x] != x:
            self.p[x] = self.find_root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def unite(self, x, y):
        u = self.find_root(x)
        v = self.find_root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def get_size(self, x):
        return self.size[self.find_root(x)]


n, K, L = map(int, input().split())
pq = [tuple(int(x)-1 for x in input().split()) for _ in range(K)]
rs = [tuple(int(x)-1 for x in input().split()) for _ in range(L)]

uk = UnionFind(n)
for p, q in pq:
    uk.unite(p, q)

ul = UnionFind(n)
for p, q in rs:
    ul.unite(p, q)

res = [uk.find_root(i) * 1000000 +  ul.find_root(i) for i in range(n)]
c = Counter(res)
ans = [0] * n

for i in range(n):
    ans[i] = c[res[i]]

print(*ans, sep=' ')
### BUGGY CODE ###

import time
start=time.time()
import random
d=int(input())
c=list(map(int, input().split()))
s=[list(map(int, input().split())) for _ in range(d)]
t=[0]*26
ans=0
solution=[]
for i in range(1,d+1):
  tmp=s[i-1].index(max(s[i-1]))
  solution.append(tmp)
  t[tmp]=i
  ans+=s[i-1][tmp]
  for j in range(26):
    ans-=c[j]*(i-t[j])
now=time.time()
while now-start<1.85:
  di=random.randrange(1,d+1)
  qi=random.randrange(1,27)
  old=solution[di-1]
  solution[di-1]=qi-1
  tmp2=ans
  for _ in range(26):
    tmp2=tmp2-s[di-1][old]+s[di-1][qi-1]
  if ans-tmp2>=0:
    solution[di-1]=old
    continue
  else:
    ans=tmp2
  now=time.time()
  if now>start+1.5:
    break
for k in solution:
  print(k+1)

### FIXED CODE ###

d=int(input())
c=list(map(int, input().split()))
s=[list(map(int, input().split())) for _ in range(d)]
t=[0]*26
ans=0
for i in range(1,d+1):
  tmp=s[i-1].index(max(s[i-1]))
  print(tmp+1)
### BUGGY CODE ###

s = input()
n = len(s)
while '01' in s or '10' in s:
  s = s.replace('01','').replace('10','')
print(n-len(s))

### FIXED CODE ###

s = list(input())
c0 = s.count('0')
c1 = s.count('1')
print(2*min(c1,c0))
### BUGGY CODE ###

s = input()

orilen = len(s)
ans = 0

for i in range(10**5):
    s = s.replace("01", "")
    s = s.replace("10", "")

print(orilen - len(s))


### FIXED CODE ###

s = input()

cnt_0 = 0
cnt_1 = 0

for i in range(len(s)):
    if s[i] == "0":
        cnt_0 += 1
    else:
        cnt_1 += 1

print(2*min(cnt_0, cnt_1))
### BUGGY CODE ###

N, M = map(int, input().split())
lista = []
for m in range(M):
    am = int(input())
    lista. append(am)
listans = [0]*N 
for n in range(N):
    if n+1 in lista:
        pass
    elif n == 0:
        listans[0] = 1
    elif n == 1:
        listans[1] = listans[0]+1
    else:
        listans[n] = (listans[n-1]+listans[n-2])%1000000007    
#print(listans)       
ans = listans[N-1] 
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
lista = []
for m in range(M):
    am = int(input())
    lista.append(am)
lista.append(0)    
an = 0
an1 = 1 
for n in range(N):
    if n+1 == lista[0]:
        del lista[0]
        #print(lista)
        an, an1 = an1, 0
    else:
        an, an1 = an1, (an+an1)%1000000007
print(an1)
### BUGGY CODE ###

n = int(input())
l = [int(i) for i in input().split()]
l.sort()
s = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    k_max = n-1
    k_min = j
    while k_min!=k_max:
      k = (k_max+k_min)//2+1
      if l[k] < l[i] + l[j]:
        k_min = k
      else:
        k_max = k-1
    s += k_min - j
print(s)

### FIXED CODE ###

from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += bisect_left(l, l[i]+l[j]) - j - 1
print(ans)
### BUGGY CODE ###

while True:
  a = 1


### FIXED CODE ###

K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [abs(x - y) for x, y in zip(A[1:], A)]
B += [K - A[-1] + A[0]]

print(sum(B) - max(B))
### BUGGY CODE ###

import copy
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

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

def coprime(a, b):
    return gcd(a, b) == 1

A , B = map(int , input().split())
gcd_value = gcd(A , B)
cd = []

for i in range(1,gcd_value + 1):
    if A % i == 0 and B % i == 0:
        cd.append(i)
'''
cnt = copy.deepcopy(cd)
i = 0
j = 1

while i < len(cnt) - 1:
#for i in range(len(cnt) - 1):
    j = i + 1
    while j < len(cnt):
    #for j in range(i + 1 , len(cnt)):
        if not coprime(cnt[i] , cnt[j]):
            if cnt[j] in cnt:
                cnt.remove(cnt[j])
                continue
        j += 1
    i += 1
print(len(cnt))
'''
#print(cnt)
count = 1
for value in cd:
    if is_prime(value):
        count += 1
print(count)


### FIXED CODE ###

import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

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

def coprime(a, b):
    return gcd(a, b) == 1

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
A , B = map(int , input().split())
#A = 100000000000
#B = 50000000000
#print(make_divisors(A))

gcd_value = gcd(A , B)
cd = []
div = make_divisors(gcd_value)

for i in range(len(div)):
    if A % div[i] == 0 and B % div[i] == 0 and is_prime(div[i]):
        cd.append(div[i])
print(len(cd) + 1)
### BUGGY CODE ###

def dp(st):
    ref = ""
    count = 0
    pos = []
    ans = []
    for n,s in enumerate(st):
        if ref=="":
            ref = s
        else:
            if ref != s:
                pos.append(n-1)
            else:
                count = 0
            ref = s
    # print(pos)
    if pos:
        for p in pos:
            ans.append(dp(st[:p]+st[p+2:])+1)
    else:
        return 0
    return max(ans)



s = input()
ans = dp(s)
print(ans*2)

### FIXED CODE ###

s = input()
ones = [1 for x in s if x=="1" ]
print(min(len(ones),len(s)- len(ones))*2)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=1
for i in a:
    ans*=i
if ans >10**18:
    print("-1")
else:
    print(ans)
    


### FIXED CODE ###

n = int(input())
lis = list(map(int,input().split()))
ans = 1
if 0 in lis:
  print(0)
  exit()
for num in lis:
  ans *= num
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)
### BUGGY CODE ###

import itertools
S = str(input())

ans = 0
for i,j in itertools.combinations(range(len(S)), 2):
  if int(S[i:j+1]) % 2019 == 0:
    ans += 1
      
print(ans)

### FIXED CODE ###

S = str(input())
li = [0] * 2019
ans = 0
li[0] = 1

d = 1
s = 0
for i in S[::-1]:
  s += int(i) * d
  s = s % 2019
  li[s] += 1
  d *= 10
  d = d % 2019
  
for l in li:
  ans += l * (l-1) // 2

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

def allocate(remains, limit_h, limit_w):
    global m
    if not remains:
        return 1
    if limit_w == 1:
        return int(remains <= limit_h)
    return sum(allocate(remains - i, i, limit_w - 1) for i in
               range(min(limit_h, remains, m - limit_w), (remains - 1) // limit_w, -1))


while True:
    n, m, s = map(int, input().split())
    if not n:
        break
    remains = s - sum(range(1, n ** 2 + 1))
    print(allocate(remains, remains, n ** 2))

### FIXED CODE ###

while True:
    n, m, s = map(int, input().split())
    if not n:
        break
    n2 = n ** 2
    dpp = [0] * (s + 1)
    dpp[0] = 1

    for i in range(1, n2 + 1):
        dpn = [0] * (s + 1)
        for j in range(i * (i + 1) // 2, s + 1):
            dpn[j] += dpp[j - i] + dpn[j - i]
            if j - m - 1 >= 0:
                dpn[j] -= dpp[j - m - 1]
            dpn[j] %= 100000
        dpp = dpn

    print(dpp[s])
### BUGGY CODE ###

#F - Tree and constraints
import itertools
from collections import defaultdict
N = int(input())
G = [[] for i in range(N+1)]
edge = defaultdict(int)
for i in range(N-1):
    a, b = map(int, input().split())
    edge[(min(a, b), max(a, b))] = i+1
    G[a].append(b)
    G[b].append(a)
M = int(input())
que = [tuple(map(int, input().split())) for i in range(M)]
Data = [set([]) for i in range(M)]


def dfs(node):
    visited[node] = True
    for child in G[node]:
        if visited[child] == False:
            parent[child] = node
            dfs(child)


for i in range(M):
    s, g = que[i]
    visited = [False for i in range(N+1)]
    parent = [-1 for i in range(N+1)]
    dfs(s)
    now = g
    while parent[now] > 0:
        number = edge[(min(now, parent[now]), max(now, parent[now]))]
        Data[i].add(number)
        now = parent[now]
ans = 2**(N-1)

for i in range(1, M+1):
    # Mこからi+1こを選ぶ
    S = 0
    subset = set([])
    for v in itertools.combinations(Data, i):
        subset.clear()
        for x in v:
            subset = x | subset
        S += 2**(N-1-len(subset))
    ans -= (-1)**((i-1) % 2)*S
print(ans)

### FIXED CODE ###

#F - Tree and constraints
import itertools
from collections import defaultdict
N = int(input())
G = [[] for i in range(N+1)]
edge = defaultdict(int)
for i in range(N-1):
    a, b = map(int, input().split())
    edge[(min(a, b), max(a, b))] = i+1
    G[a].append(b)
    G[b].append(a)
M = int(input())
que = [tuple(map(int, input().split())) for i in range(M)]
Data = [set([]) for i in range(M)]


def dfs(node):
    visited[node] = True
    for child in G[node]:
        if visited[child] == False:
            parent[child] = node
            dfs(child)


for i in range(M):
    s, g = que[i]
    visited = [False for i in range(N+1)]
    parent = [-1 for i in range(N+1)]
    dfs(s)
    now = g
    while parent[now] > 0:
        number = edge[(min(now, parent[now]), max(now, parent[now]))]
        Data[i].add(number)
        now = parent[now]
ans = 2**(N-1)
seq = [i for i in range(M)]
for i in range(1, M+1):
    # Mこからi+1こを選ぶ
    S = 0
    subset = set([])
    for v in itertools.combinations(seq, i):
        subset.clear()
        for x in v:
            subset = subset | Data[x]
        S += 2**(N-1-len(subset))
    ans -= (-1)**((i-1) % 2)*S
print(ans)
### BUGGY CODE ###

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

friend = [[] for _ in range(n)]
block = [[] for _ in range(n)]

for _ in range(m):
  a, b = map(int, input().split())
  friend[a-1].append(b-1)
  friend[b-1].append(a-1)
  
for _ in range(k):
  c, d = map(int, input().split())
  block[c-1].append(d-1)
  block[d-1].append(c-1)
  
groups = [0] * n
g_size = []
active = [True] * n
g = 0
while any(active):
  idx = active.index(True)
  groups[idx] = g
  active[idx] = False
  size = 1
  stack = [idx]
  while stack:
    v = stack.pop()
    for i in friend[v]:
      if active[i]:
        stack.append(i)
        groups[i] = g
        active[i] = False
        size += 1
  g += 1
  g_size.append(size)
  
for i in range(n):
  size = g_size[groups[i]] - 1 - len(friend[i])
  for j in block[i]:
    if groups[i] == groups[j]:
      size -= 1
  print(size, end=' ')

### FIXED CODE ###

class UnionFind:
  def __init__(self, n: int):
    self.parent = list(range(n))
    self.size = [1] * n
    self.rank = [1] * n
    
  def find(self, i: int) -> int:
    if self.parent[i] != i:
      self.parent[i] = self.find(self.parent[i])
    return self.parent[i]
  
  def unite(self, i: int, j: int):
    ri = self.find(i)
    rj = self.find(j)
    if ri != rj:
      if self.rank[ri] < self.rank[rj]:
        self.parent[ri] = rj
        self.size[rj] += self.size[ri]
      else:
        self.parent[rj] = ri
        self.size[ri] += self.size[rj]
        if self.rank[ri] == self.rank[rj]:
          self.rank[ri] += 1


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

n_friend = [1 for _ in range(n)]
block = [[] for _ in range(n)]
friendship = UnionFind(n)

for _ in range(m):
  a, b = map(int, input().split())
  n_friend[a-1] += 1
  n_friend[b-1] += 1
  friendship.unite(a-1, b-1)
  
for _ in range(k):
  c, d = map(int, input().split())
  block[c-1].append(d-1)
  block[d-1].append(c-1)
  
for i in range(n):
  r = friendship.find(i)
  cand = friendship.size[r] - n_friend[i]
  for j in block[i]:
    if r == friendship.find(j):
      cand -= 1
  print(cand, end=' ')
### BUGGY CODE ###

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

dp = [0]*N

for i in range(1,N):
  dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(i-K,0),i))
print(dp[N-1])


### FIXED CODE ###

def main():
  N,K= map(int,input().split())
  h = list(map(int,input().split()))
  dp = [0]*N
  for i in range(1,N):
    dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(i-K,0),i))
  print(dp[N-1])

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

# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc077/tasks/arc084_a

"""
import sys
from sys import stdin
from bisect import bisect_left, bisect_right
from functools import lru_cache
input = stdin.readline



@lru_cache(maxsize=None)
def calc(i):
    ans = 0
    for b in B[i:]:
        j = lut_B[b]
        ans += (N - j)
    return ans


lut_B = {}
B = []
N = 0
def main(args):
    global lut_B
    global B
    global N
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    A.sort()
    B.sort()
    C.sort()

    lut_A = {a:bisect_right(B, a) for a in A}
    lut_B = {b:bisect_right(C, b) for b in B}


    ans = 0
    for a in A:
        i = lut_A[a]
#        for b in B[i:]:
#            j = lut_B[b]
#            temp += (N - j)
        ans += calc(i)


    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc077/tasks/arc084_a

"""
import sys
from sys import stdin
from bisect import bisect_left, bisect_right
input = stdin.readline


def main(args):
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    A.sort()
    B.sort()
    C.sort()

    lut_A = {}
    lut_C = {}
    for b in B:
        i = bisect_left(A, b)
        lut_A[b] = i
        j = bisect_right(C, b)
        lut_C[b] = N - j


    ans = 0
    for b in B:
        i = lut_A[b]
        j = lut_C[b]
        ans += i * j

    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

n = int(input())
a = input().split()
m = 1
for i in range(n):
    m = m * int(a[i])
    if m == 0:
        break
    

if m > 10**18:
    print("-1")
else:
    print(m)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
m = 1
for i in range(n):
    if a[i] == 0:
        m = 0
        print("0")

if m == 1:
    for j in range(n):
        m = m * a[j]
        if m > 10**18:
            break
    if m > 10**18:
        print("-1")
    else:
        print(m)
### BUGGY CODE ###

import sys

# input処理を高速化する
input = sys.stdin.readline
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(300*300*300+10)

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

    # dp[i][j][k] := 残り1個の皿がi枚、2個の皿がj枚、3個の皿がk枚の状態から、
    # 寿司をすべてなくすのに必要な操作回数の期待値
    # dpは-1で初期化
    dp = [[[-1] * (N+1) for _ in range(N+1)] for _ in range(N+1)]

    def rec(i, j, k):
        if dp[i][j][k] >= 0:
            return dp[i][j][k]
        if (i == 0 and j == 0 and k == 0):
            return 0.0
        
        res = 0.0
        if i > 0:
            res += rec(i-1, j, k) * i
        if j > 0:
            res += rec(i+1, j-1, k) * j
        if k > 0:
            res += rec(i, j+1, k-1) * k
        res += N
        res *= 1.0 / (i + j + k)

        dp[i][j][k] = res
        return dp[i][j][k]

    one, two, three = 0, 0, 0
    for a in lst_a:
        if a == 1:
            one += 1
        elif a == 2:
            two += 1
        else:
            three += 1

    print(rec(one, two, three))

main()

### FIXED CODE ###

import sys

# input処理を高速化する
input = sys.stdin.readline

def main():
    N = int(input())
    lst_a = list(map(int, input().split()))
    one, two, three = lst_a.count(1), lst_a.count(2), lst_a.count(3)

    # dp[i][j][k] := 残り1個の皿がi枚、2個の皿がj枚、3個の皿がk枚の状態から、
    # 寿司をすべてなくすのに必要な操作回数の期待値
    dp = [[[0.0] * (N+1) for _ in range(N+1)] for _ in range(N+1)]

    for k in range(three + 1):
        for j in range(two + three + 1  - k):
            for i in range(one + two + three + 1 - k -j):
                if i == 0 and j == 0 and k == 0:
                    continue
                tmp = N * 1.0
                if i > 0:
                    tmp += i * dp[i -1][j][k]
                if j > 0:
                    tmp += j * dp[i + 1][j - 1][k]
                if k > 0:
                    tmp += k * dp[i][j + 1][k -1]
                dp[i][j][k] = tmp / (i + j + k)

    print(dp[one][two][three])


main()
### BUGGY CODE ###

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

for i in range(len(a)):
    x = a.index(i + 1) + 1
    print(x, end=' ')

### FIXED CODE ###

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

l = [0] * n

for i in range(n):
    l[a[i] - 1] = i + 1

print(*l)