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

N, X, Y = map(int, input().split())
dist_list = []
for i in range(1, N+1):
    for j in range(i+1, N+1):
        dist_list.append(min([j-i,abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X)]))
for k in range(1,N):
    print(dist_list.count(k))

### FIXED CODE ###

N, X, Y = map(int, input().split())
result = [0]*N
for i in range(1, N+1):
    for j in range(i+1, N+1):
        result[min([j-i,abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X)])-1]+=1
s = '\n'.join(map(str, result[:-1]))
print(s)
### BUGGY CODE ###

from collections import deque

def bfs(grid, costs, queue, wall):
    ans = 0
    dxy = [(1,0), (-1,0), (0,1), (0,-1)]
    while queue:
        y,x = queue.popleft()
        for dy, dx in dxy:
            y_,x_ = y+dy,x+dx
            if grid[y_][x_] == wall:
                continue
            queue.append([y_,x_])
            grid[y_][x_] = wall
            costs[y_][x_] = costs[y][x] + 1
            ans = max(ans, costs[y_][x_])
    return ans

H,W = map(int, input().split())
wall = '#'
queue = deque([])
edges = [wall for _ in range(W+2)]
grid = [edges]
costs = [[0 for _ in range(W+2)]]

for i in range(1,H+1):
    S = [wall]+list(input().strip())+[wall]
    for j in range(1,W+1):
        if S[j] == wall:
            queue.append([i,j])
    grid.append(S)
    costs.append([0 for _ in range(W+2)])
grid.append(edges)
print(bfs(grid, costs, queue, wall))


### FIXED CODE ###

from collections import deque

def bfs(grid, queue, wall):
    ans = 0
    dxy = [(1,0), (-1,0), (0,1), (0,-1)]
    while queue:
        cnt,y,x = queue.popleft()
        for dy, dx in dxy:
            y_,x_ = y+dy,x+dx
            if grid[y_][x_] == wall:
                continue
            queue.append([cnt+1,y_,x_])
            grid[y_][x_] = wall
            ans = max(ans, cnt+1)
    return ans

H,W = map(int, input().split())
wall = '#'
queue = deque([])
edges = [wall for i in range(W+2)]
grid = [edges]

for i in range(1,H+1):
    S = [wall]+list(input().strip())+[wall]
    for j in range(1,W+1):
        if S[j] == wall:
            queue.append([0,i,j])
    grid.append(S)
grid.append(edges)
print(bfs(grid, queue, wall))
### BUGGY CODE ###

import itertools
x,y,z,k = list(map(int, input().split())) 
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab = [i + j for (i, j) in list(itertools.product(a, b))]

ab.sort(reverse=True)

del ab[min(3000,x*y):]

abc = [ij + h for (ij, h) in list(itertools.product(ab, c))]

abc.sort(reverse=True)

for g in range(k):
  print(abc[g])

### FIXED CODE ###

import heapq
x,y,z,k = list(map(int, input().split())) 
a = sorted(list(map(int, input().split())),reverse=True)
b = sorted(list(map(int, input().split())),reverse=True)
c = sorted(list(map(int, input().split())),reverse=True)

ans = []
log = set()

total = (a[0] + b[0] + c[0]) * (-1)
heapq.heappush(ans, (total, 0, 0, 0))
log.add((0, 0, 0))

for i in range(k):
  (total, aa, bb, cc) = heapq.heappop(ans)
  print(total * (-1))
  if (aa+1, bb, cc) not in log:
    if aa+1 < x:
      total = (a[aa+1] + b[bb] + c[cc]) * (-1)
      heapq.heappush(ans, (total, aa+1, bb, cc))
      log.add((aa+1, bb, cc))
  if (aa, bb+1, cc) not in log:
    if bb+1 < y:
      total = (a[aa] + b[bb+1] + c[cc]) * (-1)
      heapq.heappush(ans, (total, aa, bb+1, cc))
      log.add((aa, bb+1, cc))
  if (aa, bb, cc+1) not in log:
    if cc+1 < z:
      total = (a[aa] + b[bb] + c[cc+1]) * (-1)
      heapq.heappush(ans, (total, aa, bb, cc+1))
      log.add((aa, bb, cc+1))
### BUGGY CODE ###

N = int(input())
print(sum(range(N)))

### FIXED CODE ###

N = int(input())
print(sum(range(N)))
### BUGGY CODE ###

N=input()
s=input()

N=int(N)
score=[]
wn=[]
bn=[]
a=0
b=0

for i in range(N):
    j=N-(i+1)
    if(s[j]=="."):
        a+=1
    if(s[i]=="#"):
        b+=1
    bn.insert(0,a)
    wn.append(b)
bn.append(0)
wn.insert(0,0)
#print(bn)
#print(wn)

#score算出
min=1000000
a=0
for i in range(N+1):
    score=bn[i]+wn[i]
    if(score<min):
        min=score

print(min)

### FIXED CODE ###

N=input()
s=input()

N=int(N)
wn=[]
bn=[]
a=0
b=0

#各行間よりも前と後ろに何個白（黒）があるかをカウント
wn.append(0)
for i in range(N):
    j=N-(i+1)
    if(s[j]=="."):
        a+=1
    if(s[i]=="#"):
        b+=1
    bn.append(a)
    wn.append(b)

bn.reverse()
bn.append(0)
#print(bn)
#print(wn)

#各行間のscore算出
min=1000000
for i in range(N+1):
    score=bn[i]+wn[i]
    if(score<min):
        min=score

print(min)
### BUGGY CODE ###

n = int(input())
xs = list(map(int,input().split()))
xs.sort()
ans = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if xs[i] + xs[j] <= xs[k]:
        break
      ans += 1
print(ans)




### FIXED CODE ###

import bisect

n = int(input())
xs = list(map(int,input().split()))
xs.sort()
ans = 0

for i in range(n-2):
  for j in range(i+1,n-1):
    k = bisect.bisect_left(xs[j+1:], xs[i]+xs[j])
    #print(xs[j+1:], k, xs[i]+xs[j])
    ans += k
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from scipy.sparse.csgraph import csgraph_from_dense,dijkstra

def main():
    N,M = map(int,input().split())
    edge = [[-1 for _ in range(N)] for _ in range(N)]
    for i in range(N-1):
        edge[i+1][i] = 0
    for _ in range(M):
        l,r,c = map(int,input().split())
        edge[l-1][r-1] = c

    G = csgraph_from_dense(edge,null_value = -1)
    if dijkstra(G,indices = 0)[-1] == float("inf"):
        print(-1)
    else:
        print(int(dijkstra(G,indices = 0)[-1]))

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
import heapq

def main():
    N,M = map(int,input().split())
    INF = 10**15
    root = [[] for _ in range(N)]
    for i in range(N-1):
        root[i+1].append((0,i))
    for _ in range(M):
        l,r,c = map(int,input().split())
        root[l-1].append((c,r-1))
    
    dist = [INF for _ in range(N)]
    q = [(0,0)]
    dist[0] = 0
    while q:
        d,now = heapq.heappop(q)
        if dist[now] < d:
            continue
        for cost,fol in root[now]:
            _d = d+cost
            if dist[fol] > _d:
                dist[fol] = _d
                heapq.heappush(q,(_d,fol))

    if dist[-1] == INF:
        print(-1)
    else:
        print(dist[-1])

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

N, C = map(int, input().split())
D = [[int(i) for i in input().split()] for c in range(C)]
Ini = [[int(i) for i in input().split()] for n in range(N)]
Mod0, Mod1, Mod2 = [[0, c] for c in range(C)], [[0, c] for c in range(C)], [[0, c] for c in range(C)]

for i in range(N):
    for j in range(N):
        k = i+j+2
        if k%3==0:
            for c in range(C):
                Mod0[c][0] += D[Ini[i][j]-1][c]
        elif k%3==1:
            for c in range(C):
                Mod1[c][0] += D[Ini[i][j]-1][c]
        else:
            for c in range(C):
                Mod2[c][0] += D[Ini[i][j]-1][c]
Mod0.sort()
Mod1.sort()
Mod2.sort()
Ans = float("inf")
for a in range(3):
    A = Mod0[a]
    for b in range(3):
        B = Mod1[b]
        for c in range(3):
            C = Mod2[c]
            if A[1] != B[1] and B[1] != C[1] and C[1] != A[1]:
                Ans = min(Ans, A[0]+B[0]+C[0])
print(Ans)

### FIXED CODE ###

from collections import defaultdict

N, C = map(int, input().split())
D = [[int(i) for i in input().split()] for c in range(C)]
Ini = [[int(i) for i in input().split()] for n in range(N)]
C0, C1, C2 = defaultdict(int), defaultdict(int), defaultdict(int)
D0, D1, D2 = [[0, d] for d in range(C)], [[0, d] for d in range(C)], [[0, d] for d in range(C)]
for i in range(N):
    for j in range(N):
        if (i+j+2)%3 == 0:
            C0[Ini[i][j] - 1] += 1
        elif (i+j+2)%3 == 1:
            C1[Ini[i][j] - 1] += 1
        else:
            C2[Ini[i][j] - 1] += 1

for i in range(C):
    for c in C0:
        D0[i][0] += D[c][i] * C0[c]
    for c in C1:
        D1[i][0] += D[c][i] * C1[c]
    for c in C2:
        D2[i][0] += D[c][i] * C2[c]

D0.sort()
D1.sort()
D2.sort()
Ans = float("inf")
for i in range(3):
    I = D0[i]
    for j in range(3):
        J = D1[j]
        for k in range(3):
            K = D2[k]
            if I[1] != J[1] and J[1] != K[1] and K[1] != I[1]:
                Ans = min(Ans, I[0] + J[0] + K[0])
print(Ans)
### BUGGY CODE ###

import collections
import itertools
import functools
import math
import scipy.special

if __name__ == "__main__":
    k, s = map(int, input().split())
    res = 0
    for i in range(k + 1):
        for j in range(k + 1):
            res += int(0 <= s - i - j <= k)
    print(res)

### FIXED CODE ###

import collections
import itertools
import functools
import math
import scipy.special

if __name__ == "__main__":
    k, s = map(int, input().split())
    res = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if 0 <= s - i - j <= k:
                res += 1
    print(res)
### BUGGY CODE ###

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

correct=[]
data={}

for j in range(m):
    if p[j][0] in correct:
        continue
    if p[j][0] in data.keys():
        if p[j][1]=='WA': 
            data[p[j][0]]+=1
        else:
            correct.append(p[j][0])
    else:
        if p[j][1]=='WA':
            data[p[j][0]]=1
        else:
            correct.append(p[j][0])

#print(correct,data)
#print(len(correct),sum(data.values()))
sum_wa=0
for i in correct:
    if i in data.keys():
        sum_wa+=data[i]
#print(sum_wa)
print(len(correct),sum_wa)

### FIXED CODE ###

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

if m==0:
    print(0,0)
    import sys
    sys.exit()

p=[list(input().split()) for _ in range(m)]
correct=set([p[i][0] for i in range(m) if p[i][1]=='AC'])

s=set()
sum_wa=0

for i in [p[j] for j in range(m) if p[j][0] in correct]:
    if i[0] in s:
        continue
    else:
        if i[1]=='WA':
            sum_wa+=1
        else:
            s.add(i[0])

print(len(correct),sum_wa)
### BUGGY CODE ###

K = int(input())
S = input()
X = len(S)
mod = 10**9+7

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*10**6+3
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

ans = 0
for i in range(X,K+X+1):
    temp = 1
    A = i-X
    B = K+X-i
    temp *= cmb(A+X-1,X-1,mod)*power(25,A,mod)
    temp %= mod
    temp *= power(26,B,mod)
    ans += temp
    ans %= mod
print(ans)

### FIXED CODE ###

K = int(input())
S = input()
X = len(S)
mod = 10**9+7

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod


A = 0
B = K
temp = cmb(A+X-1,X-1,mod)*power(25,A,mod)
temp %= mod
temp *= power(26,B,mod)
temp %= mod

ans = temp

for i in range(X+1,K+X+1):

    temp *= 25
    temp %= mod
    
    temp *= pow(26, mod-2, mod)
    temp %= mod
    
    temp *= i-1
    temp %= mod
    
    temp *= pow(i-X, mod-2, mod)
    temp %= mod    

    ans += temp
    ans %= mod

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

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
p = 1
for i in range(N):
    p *= i+1
print(p % 1000000007)


### FIXED CODE ###

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
p = 1
for i in range(N):
    p *= i+1
    p %= 1000000007
print(p)
### BUGGY CODE ###

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

A = []
B = []
x = []

for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1:
        A.append(b)
    elif b == N:
        B.append(a)

ans = 'IMPOSSIBLE'
for a in A:
    for b in B:
        if a == b:
            ans = 'POSSIBLE'
            break
print(ans)

### FIXED CODE ###

N, M = list(map(int, input().split()))
A = [0 for i in range(200000+1)]
B = [0 for i in range(200000+1)]
ans = 'IMPOSSIBLE'

for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1:
        A[b] = 1
        if A[b] and B[b]:
            ans = 'POSSIBLE'
            break
    elif b == N:
        B[a] = 1
        if A[a] and B[a]:
            ans = 'POSSIBLE'
            break
print(ans)
### BUGGY CODE ###

# dp_b.py
def chmin(h, k, i):
    if i == 0:
        return 0
    ans = 10**9
    for j in range(min(i, k)):
        _min = dp[i-j-1] + abs(h[i]-h[i-j-1])
        if ans > _min:
            ans = _min
    return ans


N, K = map(int, input().split())
H = list(map(int, input().split()))
dp = [0]*N
for i in range(N):
    dp[i] = chmin(H, K, i)
    # print(dp)
print(dp[N-1])


### FIXED CODE ###

# dp_b.py
def chmin(h, k, i):
    if i == 0:
        return 0
    ans = 10**9
    for j in range(min(i, k)):
        _min = dp[i-j-1] + abs(h[i]-h[i-j-1])
        if ans > _min:
            ans = _min
    return ans


N, K = map(int, input().split())
H = list(map(int, input().split()))
dp = [0]*N
for i in range(N):
    dp[i] = chmin(H, K, i)
    # print(dp)
print(dp[N-1])
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

from operator import mul
from functools import reduce

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

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

total = reduce(mul, A)
if total > 10 ** 18:
    print(-1)
else:
    print(total)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

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

A = sorted(A)

total = A[0]
limit = 10 ** 18

for a in A[1:]:
    total *= a
    if total > limit:
        print(-1)
        exit()
print(total)
### BUGGY CODE ###

import heapq

N = int(input())
a    = [ int(x) for x in input().split() ]
aneg = [-x for x in a]
arev = a[::-1]

HL0 = aneg[:N-1]
heapq.heapify(HL0) #; print(HL0)

sumL = []
for i in range(N+1):
    heapq.heappush(HL0, aneg[N-1+i])
    H = HL0.copy() #; print(i, H)
    sum_ = 0
    for j in range(N):
        x = heapq.heappop(H) #; print(x) 
        sum_ += x     
    sumL.append(sum_)

    
HR0 = arev[:N-1]
heapq.heapify(HR0) #; print(HR0)

sumR = []
for i in range(N+1):
    heapq.heappush(HR0, arev[N-1+i])
    H = HR0.copy() #;     print(i, H)
    sum_ = 0
    for j in range(N):
        x = heapq.heappop(H) #; print(x) 
        sum_ += x      
    sumR.append(sum_)

# print(sumL, sumR)    
sumL = [-x for x in sumL ]    
sumR = sumR[::-1]

dif = [ i-j for i, j in zip(sumL, sumR) ]

# print(l_sumL, l_sumR) ; print(dif)
print(max(dif))

### FIXED CODE ###

import heapq

N = int(input())
a    = [ int(x) for x in input().split() ]
arev = [ -x for x in a[::-1] ]

Hl = a[:N]
heapq.heapify(Hl) #; print(Hl)
suml = sum(Hl)
sumL = [suml]

Hr = arev[:N]
heapq.heapify(Hr) #; print(Hr)
sumr = sum(Hr)
sumR = [sumr]

for i in range(N):
    x = heapq.heappushpop(Hl, a[N+i])
    #print(i, x, Hl, sum(Hl))
    suml += -x + a[N+i]
    sumL.append(suml)
    
for i in range(N):
    x = heapq.heappushpop(Hr, arev[N+i])
    #print(i, x, Hr, sum(Hr))
    sumr += -x + arev[N+i]
    sumR.append(sumr)

#print(sumL, sumR)
dif = [ i+j for i, j in zip(sumL, sumR[::-1])]  #; print(dif)
print(max(dif))
### BUGGY CODE ###

import math
N = int(input())

for i in range(1, N+1):
    ans = 0
    n = int(math.sqrt(i))+1
    for x in range(1, n+1):
        for y in range(1, n+1):
            for z in range(1, n+1):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    ans += 1
    print(ans)

### FIXED CODE ###

import math
N = int(input())

ans = [0] * N
n = int(math.sqrt(N)) 

for x in range(1, n+1):
    for y in range(1, x+1):
        for z in range(1, y+1):
            i = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if i <= N:
                if x == y == z:
                    ans[i-1] += 1
                elif x == y or y == z:
                    ans[i-1] += 3
                else:
                    ans[i-1] += 6

for j in range(N):
    print(ans[j])
### BUGGY CODE ###

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

def resolve():
    n=int(input())
    a=list(input().split())
    b=[]
    for i in range(1,n+1):
        if i%2==n%2:
            b.insert(0,a[i-1])
        else:
            b.append(a[i-1])
    print(*b)
resolve()

### FIXED CODE ###

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

def resolve():
    n=int(input())
    a=list(input().split())
    akisu=a[0::2]
    agusu=a[1::2][::-1]
    b=agusu+akisu
    if n%2==0:
        print(*b)
    else:
        print(*b[::-1])
resolve()
### BUGGY CODE ###

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

A = list(enumerate(A, start=1))
A.sort(reverse=True, key=lambda x: x[1])

dp = [[0]*(N + 1) for _ in range(N + 1)]
for j in range(N):
    dp[0][j+1] = dp[0][j] + A[j][1]*((N - j) - A[j][0])
for i in range(N):
    dp[i+1][0] = dp[i][0] + A[i][1]*(A[i][0] - (i + 1))
    for j in range(N - i - 1):
        dp[i+1][j+1] = max(dp[i+1][j] + A[i+j+1][1]*((N - j) - A[i+j+1][0]),
                           dp[i][j+1] + A[i+j+1][1]*(A[i+j+1][0] - (i + 1)))
print(max(dp[i][N-i] for i in range(N+1)))


### FIXED CODE ###

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

p = list(range(N))
p.sort(key=lambda i: A[i], reverse=True)

dp = [[0]*(N + 1) for _ in range(N + 1)]
for i in range(N):
    for j in range(i + 1):
        pi = p[i]
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + A[pi]*(N - i + j - 1 - pi))
        dp[i+1][j+1] = dp[i][j] + A[pi]*(pi - j)
print(max(dp[N]))
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
gcd_list = []
max_element = max(A)

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

for i in range(n):
    y = A[i]
    for j in range(1, max_element + 1):
        A[i] = j
        x = A[0]
        for k in range(1, n):
            x = gcd(x, A[k])
        gcd_list.append(x)
    A[i] = y
print(max(gcd_list))


### FIXED CODE ###

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

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

L = [0]; R = [0]
for i in range(N-1):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[N-1-i]))

maxGCD = 1
for j in range(N):
    maxGCD = max(maxGCD, gcd(L[j], R[N-j-1]))
print(maxGCD)
### BUGGY CODE ###

a, b = map(int, input().split())
num_list = list(map(int, input().split()))
k_sum = 0.0
for j in range(a - b + 1):
    k_sum = max(k_sum, sum(num_list[j:j+b]))

out = (k_sum + b) / 2
print(out)

### FIXED CODE ###

a, b = map(int, input().split())
num_list = list(map(int, input().split()))
k_sum = sum(num_list[0:b])
max_sum = k_sum
for i, j in zip(num_list[0:], num_list[b:]):
    k_sum -= i
    k_sum += j
    max_sum = max(max_sum, k_sum)
out = (max_sum + b) / 2
print(out)
### BUGGY CODE ###

n, m = map(int, input().split())
list = [int(i) for i in input().split()]
for i in range(m):
  list[list.index(max(list))] = max(list)//2

print(sum(list))

### FIXED CODE ###

import heapq
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
for i in range(n):
  a[i] *= -1

heapq.heapify(a)
for i in range(m):
    heapq.heapreplace(a, int(a[0] / 2))

print(sum(a)*-1)
### BUGGY CODE ###

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

def common_divisor(n):
    cd = []
    for i in range(1,int(n**0.5)+2):
        if n%i==0:
            cd.append(i)
            if i != n//i:
                cd.append(n//i)
    return list(set(cd))

cd_dic = {}
for cd in common_divisor(A[0]):
    cd_dic[cd] = 1

for cd in common_divisor(A[1]):
    if cd not in cd_dic:
        cd_dic[cd] = 1
    else:
        cd_dic[cd] = 2
#print(cd_dic)
for k in cd_dic.keys():
    if cd_dic[k] == 2:
        cd_dic[k] = True
    else:
        cd_dic[k] = False
from copy import copy
for a in A[2:]:
    #print(cd_dic)
    d = copy(cd_dic)
    for k,v in cd_dic.items():
        if a%k!=0:
            if v == True:
                d[k] = False
            else:
                d.pop(k)
    cd_dic = copy(d)
ans = max(cd_dic.keys())
print(ans)

### FIXED CODE ###

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

def common_divisor(n):
    cd = []
    for i in range(1,int(n**0.5)+2):
        if n%i==0:
            cd.append(i)
            if i != n//i:
                cd.append(n//i)
    return list(set(cd))

cd_dic = {}
for cd in common_divisor(A[0]):
    cd_dic[cd] = 1

for cd in common_divisor(A[1]):
    if cd not in cd_dic:
        cd_dic[cd] = 1
    else:
        cd_dic[cd] = 2
#print(cd_dic)
for k in cd_dic.keys():
    if cd_dic[k] == 2:
        cd_dic[k] = True
    else:
        cd_dic[k] = False
from copy import copy
for a in A[2:]:
    #print(cd_dic)
    d = copy(cd_dic)
    for k,v in cd_dic.items():
        if a%k!=0:
            if v == True:
                d[k] = False
            else:
                d.pop(k)
    cd_dic = copy(d)
ans = max(cd_dic.keys())
print(ans)
### BUGGY CODE ###

import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline.rstrip()
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl())

ans = 0
d = defaultdict(int)
for b in B:
    d[b] = len(C[bisect.bisect_right(C,b):])
for a in A:
    for b in B[bisect.bisect_right(B,a):]:
        ans += d[b]

print(ans)

### FIXED CODE ###

import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl())

ans = 0
for b in B:
    tmp = bisect.bisect_right(C,b)
    tmp2 = bisect.bisect_left(A,b)
    ans += (n-tmp) * tmp2

print(ans)