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

n = int(input())
li = list(map(int,input().split()))
ans = li[0]
for i,l in enumerate(li):
    if i == 0:
        continue
    else:
        #print(l,'l')
        ans *= l
        #print(ans)
if ans > 10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))
if 0 in li:
    print(0)
    exit()

ans = li[0]
for i,l in enumerate(li):
    if i == 0:
        continue
    else:
        #print(l,'l')
        ans *= l
        if ans > 10**18:
            print(-1)
            exit()
        #print(ans)
if ans > 10**18:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=list(input())
    S+=["Z"]*3
    N=len(S)
    
    ans=0
    i=0
    while i!=N:
        if S[i:i+3]==["A","B","C"]:
            ans+=1
            S[i]="B"
            S[i+1]="C"
            S[i+2]="A"
            i=max(0,i-1)
        else:
            i+=1

    print(ans)
            

main()


### FIXED CODE ###

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    S=S.replace("BC","D")
    S+="Z"
    N=len(S)
    ans=0
    cnta=0

    
    for i in range(N):
        if S[i]=="D":
            ans+=cnta
        elif S[i]=="A":
            cnta+=1
        else:
            cnta=0
                
    print(ans)
            

main()
### BUGGY CODE ###

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

minint = 10**9

if N == 2:
    print(abs(a[0] - a[1]))

else:
    for i in range(1, N):
        s1 = sum(a[0:i])
        s2 = sum(a[i: N])
        minint = min(minint, abs(s1 - s2))

    print(minint)

### FIXED CODE ###

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

minint = 10**9

if N == 2:
    print(abs(a[0] - a[1]))

else:
    s1 = s1 = sum(a[0:1])
    s2 = sum(a[1: N])
    for i in range(1, N - 1):
        s1 += a[i]
        s2 -= a[i]
        
        minint = min(minint, abs(s1 - s2))

    print(minint)
### BUGGY CODE ###

from fractions import gcd

n = int(input())
temp = []
ans = 0

for i in range(1, n+1):
    for j in range(1, n+1):
      temp.append(gcd(i,j))

for temp_i in temp:
  for k in range(1, n+1):
    ans += gcd(temp_i, k)
    
print(ans)

### FIXED CODE ###

from fractions import gcd
from collections import defaultdict

n = int(input())
temp = defaultdict(int)
ans = 0

for i in range(1, n+1):
    for j in range(1, n+1):
      x = gcd(i,j)
      temp[x] += 1

for k,v in temp.items():
  for w in range(1, n+1):
    ans += gcd(k,w)* v

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

import sys
from collections import deque

n, *ppp = map(int, sys.stdin.buffer.read().split())

n2 = n + 2
row_base0 = list(range(n))
row_base1 = [-1] + row_base0 + [-1]
row_base0.reverse()
row_base2 = [-1] + row_base0 + [-1]
row_base = [min(a, b) for a, b in zip(row_base1, row_base2)]

seats = [-1] * n2
for i in range(n):
    ud = min(i, n - 1 - i)
    seats.extend(min(a, ud) for a in row_base)
seats.extend([-1] * n2)

is_seated = [False] * n2
is_seated.extend(([False] + [True] * n + [False]) * n)
is_seated.extend([False] * n2)


def pg(aaa):
    for i in range(0, n2 ** 2, n2):
        print(aaa[i:i + n2])
    print()


ans = 0
MOVE = (-n2, -1, 1, n2)
q = deque()
popl = q.popleft
appl = q.appendleft
appr = q.append
clrq = q.clear

for p in ppp:
    i, j = divmod(p - 1, n)
    i = (i + 1) * n2 + j + 1
    res = seats[i]
    ans += res
    is_seated[i] = False

    appr((res, i))
    updated = set()

    while q:
        val, j = popl()
        if j in updated:
            continue
        updated.add(j)
        seats[j] = val
        if is_seated[j]:
            val += 1
            upd_func = appr
        else:
            upd_func = appl
        for dj in MOVE:
            nj = j + dj
            if seats[nj] > val and nj not in updated:
                upd_func((val, nj))
    clrq()
    # print(p, i, res)
    # pg(seats)

print(ans)


### FIXED CODE ###

import sys
import numpy as np

from numba import njit


@njit('i4(i4,i4[:])', cache=True)
def solve(n, ppp):
    n2 = n + 2
    nsq = n2 * n2
    seats = np.zeros(nsq, dtype=np.int16)
    is_seated = np.zeros(nsq, dtype=np.int8)
    for i in range(n):
        ud = min(i, n - 1 - i)
        ri = (i + 1) * n2
        for j in range(n):
            ij = ri + j + 1
            seats[ij] = min(ud, j, n - 1 - j)
            is_seated[ij] = 1

    MOVES = np.array([-n2, -1, 1, n2], dtype=np.int32)

    ans = 0

    for pi in range(n * n):
        i, j = divmod(ppp[pi], n)
        i = (i + 1) * n2 + j + 1
        res = seats[i]
        ans += res
        is_seated[i] = 0

        q = []
        for mi in range(4):
            ni = i + MOVES[mi]
            if seats[ni] > res:
                seats[ni] = res
                q.append(ni)

        while q:
            j = q.pop()
            # print(val, j, seats[j], l, r)
            val = seats[j]

            if is_seated[j]:
                val += 1
            for mi in range(4):
                nj = j + MOVES[mi]
                if seats[nj] > val:
                    seats[nj] = val
                    q.append(nj)

        # print(ppp[pi] + 1, i, ans)
        # print(seats.reshape((n2, n2)))
        # print(is_seated.reshape((n2, n2)))

    return ans


n = int(sys.stdin.buffer.readline())
ppp = np.array(list(map(int, sys.stdin.buffer.read().split())), dtype=np.int32) - 1

# n = 20
# np.random.seed(seed=32)
# ppp = np.random.permutation(n * n).astype(np.int32)
# print(ppp)

print(solve(n, ppp))
### BUGGY CODE ###

import sys
from collections import deque

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


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


def bfs(dist, black, H, W):
    q = deque(black)

    res = 0
    while q:
        h, w = q.pop()

        for dh, dw in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            nh = h + dh
            nw = w + dw
            if 0 <= nh < H and 0 <= nw < W:
                if dist[nh][nw] == -1:
                    dist[nh][nw] = dist[h][w] + 1
                    if res < dist[nh][nw]:
                        res = dist[nh][nw]
                    q.appendleft((nh, nw))

    return res


def main():
    H, W = map(int, input().split())
    A = [input() for _ in range(H)]
    black = []
    dist = [[-1] * W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                black.append((h, w))
                dist[h][w] = 0

    ans = bfs(dist, black, H, W)
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import deque

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


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


def bfs(dist, black, H, W):
    q = deque(black)

    res = 0
    while q:
        h, w = q.pop()

        for dh, dw in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            nh = h + dh
            nw = w + dw
            if 0 <= nh < H and 0 <= nw < W:
                if dist[nh][nw] == -1:
                    dist[nh][nw] = dist[h][w] + 1
                    if res < dist[nh][nw]:
                        res = dist[nh][nw]
                    q.appendleft((nh, nw))

    return res


def main():
    H, W = map(int, input().split())
    A = [input() for _ in range(H)]
    black = []
    dist = [[-1] * W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                black.append((h, w))
                dist[h][w] = 0

    ans = bfs(dist, black, H, W)
    print(ans)


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

import heapq
import sys
input = sys.stdin.readline

# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
q = []
q = [(-b, i) for i, b in enumerate(B)]
heapq.heapify(q)
ans = 0
N_m1 = N-1
while len(q)>0:
    b, idx = q[0]
    b = -b
    b_p1, b_m1 = B[idx+1 if idx<N_m1 else 0], B[idx-1]
    d = b_p1 + b_m1

    a = A[idx]
    p = min((b-a)//d, (b-b_m1)//d+1, (b-b_p1)//d+1)

    b -= p * d
    B[idx] = b
    ans += p
    if b > a:
        heapq.heapreplace(q, (-b, idx))
        if q[0][1] == idx:
            print(-1)
            exit()
    else:
        heapq.heappop(q)
print(ans)


### FIXED CODE ###

import heapq
import sys
input = sys.stdin.readline

# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
# 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
q = []
q = [(-b, i) for i, b in enumerate(B)]
heapq.heapify(q)
ans = 0
N_m1 = N-1
while len(q)>0:
    b, idx = q[0]
    b = -b
    b_p1, b_m1 = B[idx+1 if idx<N_m1 else 0], B[idx-1]
    d = b_p1 + b_m1

    a = A[idx]
    p = min((b-a)//d, (b-b_m1)//d+1, (b-b_p1)//d+1)

    b -= p * d
    B[idx] = b
    ans += p
    if b > a:
        heapq.heapreplace(q, (-b, idx))
        if q[0][1] == idx:
            print(-1)
            exit()
    else:
        heapq.heappop(q)
print(ans)
### BUGGY CODE ###

import math
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

def nasu(x):
  t = make_divisors(x)
  c = 0
  for i in t:
    c += D[i]
  return c

def honya(x):
  t = X[:x]
  y = int(t, 2)
  c = y
  k = y
  j = 0
  r = (1 << x) - 1
  for i in range(N // x):
    j = (j << x) + k
    k = k ^ r
  if Y >= j:
    c += 1
  return c

N = int(input())
X = input()
Y = int(X, 2)
MOD = 998244353

D = [0] * (N + 1)
L = make_divisors(N)

cnt = 0
for i in L:
  if i != N and (N // i) % 2 == 1:
    D[i] = honya(i) - nasu(i)
    cnt += D[i]

D[N] = Y - cnt + 1

ans = 0
for i in L:
  ans = (ans + D[i] * i * 2) % MOD

print(ans)

### FIXED CODE ###

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

def nasu(x):
  t = make_divisors(x)
  c = 0
  for i in t:
    c += D[i]
  return c

def honya(x):
  y = 0
  k = 1
  for i in range(x - 1, -1, -1):
    if X[i]:
      y = (y + k) % MOD
    k = (k * 2) % MOD
  return y + honyaraka(x)

def honyaraka(x):
  cnt = 0
  for i in range(N // x):
    t = i % 2
    for j in range(x):
      if X[cnt] != (X[j] ^ t):
        if X[cnt] == 0:
          return 0
        else:
          return 1
      cnt += 1
  return 1


N = int(input())
X = list(map(int, input()))
MOD = 998244353

Y = 0
k = 1
for i in range(N - 1, -1, -1):
  if X[i]:
    Y = (Y + k) % MOD
  k = (k * 2) % MOD

D = [0] * (N + 1)
L = make_divisors(N)

cnt = 0
for i in L:
  if i != N and (N // i) % 2 == 1:
    D[i] = honya(i) - nasu(i)
    cnt += D[i]

D[N] = Y - cnt + 1

ans = 0
for i in L:
  ans = (ans + D[i] * i * 2) % MOD

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

n = int(input())
lst = [int(s) for s in input().split()]

is_success = True

if n % 2 == 1:
    is_success = lst.count(0) == 1

for i in range(n - 1, 0, -2):
    if lst.count(i) != 2:
        is_success = False
        break

if is_success:
    tmp = 1

    for _ in range(n // 2):
        tmp *= 2
        tmp %= 10 ** 9 + 7

    print(tmp)
else:
    print(0)

### FIXED CODE ###

import collections

n = int(input())
lst = [int(s) for s in input().split()]

is_success = True

if n % 2 == 1:
    is_success = lst.count(0) == 1

counters = collections.Counter(lst)

for i in range(n - 1, 0, -2):
    if counters[i] != 2:
        is_success = False
        break

if is_success:
    tmp = 1

    for _ in range(n // 2):
        tmp *= 2
        tmp %= 10 ** 9 + 7

    print(tmp)
else:
    print(0)
### BUGGY CODE ###

s=input()
q=int(input())
for i in range(q):
  k=input().split()
  if k[0]=='1':
    s=s[::-1]
  elif k[1]=='1':
    s=k[2]+s
  else:
    s=s+k[2]
print(s)

### FIXED CODE ###

s=input()
q=int(input())
direction=1
#↑で1は右向き2は左向きに対応。
migi_matu=''
hidari_matu=''
#↑リストにしてしまうと後で文字sと連結できなくなる。
for i in range(q):
  k=input().split()
  #k[0] is Ti, k[1] is Fi, k[2] is character
  if k[0]=='1':
    direction*=(-1)
  if k[0]=='2':
    if k[1]=='1':
      if direction==1:
        hidari_matu+=k[2]
      if direction==-1:
        migi_matu+=k[2]
    else:
      if direction==1:
        migi_matu+=k[2]
      if direction==-1:
        hidari_matu+=k[2]
#  print('入力は',k,'とする。このとき')
#  print(i,'回目の操作後')
#  print(direction)
#  if direction==1:
#    print(hidari_matu[::-1]+s+migi_matu)
#  if direction==-1:
#    print(migi_matu[::-1]+s[::-1]+hidari_matu)
  
  
if direction==1:
  print(hidari_matu[::-1]+s+migi_matu)
if direction==-1:
  print(migi_matu[::-1]+s[::-1]+hidari_matu)
### BUGGY CODE ###

from collections import deque

N, M = map(int, input().split()) # ノード数, エッジ数
edges = [[] for i in range(N)] # エッジ
for i in range(M):
    A, B = map(int, input().split())
    edges[A - 1] += [B - 1]
    edges[B - 1] += [A - 1]

# 幅優先探索
que = deque([0]) # 探索用キュー
ans = [0] + [-1 for i in range(N - 1)] # 未探索ノード 兼 道しるべ
while -1 in ans: # 未探索ノードがある間
    node = que.popleft() # キューから取り出し
    for neighbor in edges[node]: # 全ての隣接ノードに対して
        if ans[neighbor] == -1: # 未探索なら
            ans[neighbor] = node + 1 # 道しるべを設定
            que.append(neighbor) # キューに入れる

print('Yes')
for a in ans[1:]:
    print(a)


### FIXED CODE ###

# 入力
N, M = map(int, input().split()) # ノード数, エッジ数
edges = [[] for i in range(N)] # エッジ
for i in range(M):
    A, B = map(int, input().split())
    edges[A - 1] += [B - 1]
    edges[B - 1] += [A - 1]

# 幅優先探索
que = [0] # 探索用キュー
ans = [0] + [-1 for i in range(N - 1)] # 未探索ノード 兼 道しるべ
while -1 in ans: # 未探索ノードがある間
    quetmp = que
    que = []
    for node in quetmp: # 探索キュー内のノードに対して
        for neighbor in edges[node]: # 全ての隣接ノードに対して
            if ans[neighbor] == -1: # 未探索なら
                ans[neighbor] = node + 1 # 道しるべを設定
                que += [neighbor] # キューに入れる

# 出力
print('Yes')
for a in ans[1:]:
    print(a)
### BUGGY CODE ###

from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

H, W, N = map(int, input().split())
xy = []
dot = defaultdict(int)
seen = defaultdict(bool)
for _ in range(N):
    a, b = map(int, input().split())
    xy.append((a, b))
    dot[(a, b)] = 1

ans = [0] * 10
for x, y in xy:
    for dx in [-2, -1, 0]:
        for dy in [-2, -1, 0]:
            nx = x + dx
            ny = y + dy
            if seen[(nx, ny)] or nx <= 0 or nx + 2 > H or ny <= 0 or ny + 2 > W:
                continue
            seen[(nx, ny)] = True
            cnt = 0
            for i in range(3):
                for j in range(3):
                    cnt += int(dot[(nx + i, ny + j)])
            ans[cnt] += 1

zero = (H - 2) * (W - 2) - sum(ans)
ans[0] = zero
print(*ans, sep="\n")

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

H, W, N = map(int, input().split())
cand = set()
dot = set()
for _ in range(N):
    x, y = map(int, input().split())
    dot.add((x, y))
    for i in range(-2, 1):
        if 1 <= x + i <= H - 2:
            for j in range(-2, 1):
                if 1 <= y + j <= W - 2:
                    cand.add((x + i, y + j))

ans = [0] * 10
for x, y in cand:
    cnt = 0
    for i in range(3):
        for j in range(3):
            cnt += int((x + i, y + j) in dot)
    ans[cnt] += 1

zero = (H - 2) * (W - 2) - sum(ans)
ans[0] = zero
print(*ans, sep="\n")
### BUGGY CODE ###

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

s=[]
for i in range(N):
    s=sorted(X[:i]+X[i+1:])
    print(s[N//2-1])

### FIXED CODE ###

N=int(input())
X=list(map(int,input().split()))
S=sorted(X)
b=S[N//2]
a=S[(N//2)-1]
for i in X:
    print(b if i<b else a)
### BUGGY CODE ###

N,K = map(int, input().strip().split(' '))
S = input().strip()

# 奇数番目は1のカタマリの人数　偶数番目は0のカタマリの人数 両端は必ず1のカタマリの人数
now_state, now_count = '1', 0
L = []
Ladd = L.append
for i in range(len(S)):
  if S[i] == now_state:
    now_count += 1
  else:
    Ladd(now_count)
    # reset
    now_count = 1
    now_state = '1' if now_state == '0' else '0'
Ladd(now_count)
if now_state == '0':
  Ladd(0)

#print(L)
# 0の塊をj個ひっくり返す
# j==1のとき101の3個の和の最大
# j==2のとき10101の5個の和の最大
# j==jのとき101...1のj*2+1個の和の最大

def evenngram(n, _list):
  return [_list[i:i+n] for i in range(len(_list)-n+1) if i%2==0]

now_max = 0
j = min(int((len(L)-1)/2), K) # 0のカタマリをひっくり返せるだけひっくり返す
tmp = evenngram(j*2+1, L)
tmp = [sum(t) for t in tmp]
tmp = max(tmp) if len(tmp) > 0 else 0
now_max = max(tmp, now_max)
print(now_max)


### FIXED CODE ###

N,K = map(int, input().strip().split(' '))
S = input().strip()
l,r,now_max,now_zeros = 0,0,1,0
for r in range(1,N):
  if S[r-1] == '0':
    if S[r] == '0':
      continue
    else:
      now_zeros += 1
  else:
    if S[r] == '0':
      if now_zeros < K:
        continue
      else:
        now_max = max(r-l, now_max)
        now_zeros -= 1
        for _ in range(l,r):
          l += 1
          if S[l-1:l+1] == '01':
            break
    else:
      continue
now_max = max(r-l+1, now_max)
print(now_max)
### BUGGY CODE ###

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


### FIXED CODE ###

n = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(n - 2):
    a = L[i]
    k = i
    for j in range(i + 1, n - 1):
        b = L[j]
        while k < n and L[k] < a + b:
            k += 1
        ans += k - (j + 1)
print(ans)
### BUGGY CODE ###

import queue
import sys
def input(): return sys.stdin.readline().rstrip()

N = int(input())


vlist = [[] for _ in range(N)]

for i in range(N-1):
    a,b,w = map(int, input().split())
    a -= 1
    b -= 1
    vlist[a].append((b,w))
    vlist[b].append((a,w))

ans = [-1] * N
q = queue.Queue()

ans[0] = 0
q.put(0)

while q:
    new = q.get()
    for node, weight in vlist[new]:
        if ans[node] != -1:
            continue
        ans[node] = (ans[new] + weight) % 2
        q.put(node)
    
for i in ans:
    print(i)



### FIXED CODE ###

from collections import deque

N = int(input())


vlist = [[] for _ in range(N)]

for i in range(N-1):
    a,b,w = map(int, input().split())
    a -= 1
    b -= 1
    vlist[a].append((b,w))
    vlist[b].append((a,w))

ans = [-1] * N
q = deque()

ans[0] = 0
q.append(0)

while q:
    new = q.popleft()
    for node, weight in vlist[new]:
        if ans[node] != -1:
            continue
        ans[node] = (ans[new] + weight) % 2
        q.append(node)
    
for i in ans:
    print(i)
### BUGGY CODE ###

n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
import time
s_time = time.time()

memo = {}
for i in range(n):
    memo[i] = 0

cnt = 0
while True:
    visited = [False] * n
    flag = False
    for i in range(n):
        if memo[i] == len(a[0]):
            continue
        if visited[i] or visited[a[i][memo[i]] - 1]:
            continue
        visited[i] = True
        if i + 1 == a[a[i][memo[i]] - 1][memo[a[i][memo[i]] - 1]]:
            visited[a[i][memo[i]] - 1] = True
            flag = True
            tmp = memo[i]
            memo[i] += 1
            memo[a[i][tmp] - 1] += 1
    if flag:
        cnt += 1
    else:
        for i in memo:
            if memo[i] != len(a[0]):
                print(-1)
                exit()
        break
    if abs(s_time - time.time()) > 1.9:
        print(n**2 //2)
print(cnt)


### FIXED CODE ###

import time
s_time = time.time()


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]

memo = {}
for i in range(n):
    memo[i] = 0

cnt = 0
while True:
    visited = [False] * n
    flag = False
    for i in range(n):
        if memo[i] == len(a[0]):
            continue
        if visited[i] or visited[a[i][memo[i]] - 1]:
            continue
        visited[i] = True
        if i + 1 == a[a[i][memo[i]] - 1][memo[a[i][memo[i]] - 1]]:
            visited[a[i][memo[i]] - 1] = True
            flag = True
            tmp = memo[i]
            memo[i] += 1
            memo[a[i][tmp] - 1] += 1
    if flag:
        cnt += 1
    else:
        for i in memo:
            if memo[i] != len(a[0]):
                print(-1)
                exit()
        break
    if abs(s_time - time.time()) > 1.7:
        print(n*(n-1) //2)
        exit()
print(cnt)
### BUGGY CODE ###

k, s = map(int, input().split())

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                ans += 1
                break

print(ans)

### FIXED CODE ###

k, s = map(int, input().split())

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - (x + y)
        if z <= k and z >= 0:
            #print(x, y, z)
            ans += 1

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

N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(M)]

count = [0 for i in range(N)]

for aibi in ab:
    ai = aibi[0]
    bi = aibi[1]

    if bi < ai:
        tmp = ai
        ai = bi
        bi = tmp

    for j in range(ai - 1, bi - 1):
        count[j] += 1

yes_or_no = True
for num in count:
    if num % 2 == 1:
        yes_or_no = False

if yes_or_no:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(M)]

count = [0 for i in range(N)]

# for aibi in ab:
#     ai = aibi[0]
#     bi = aibi[1]
#
#     if bi < ai:
#         tmp = ai
#         ai = bi
#         bi = tmp
#
#     for j in range(ai - 1, bi - 1):
#         count[j] += 1

for aibi in ab:
    ai = aibi[0]
    bi = aibi[1]
    if ai != 1 and bi != 1:
        count[ai - 1] += 1
        count[bi - 1] += 1
    else:
        if ai == 1:
            count[bi - 1] += 1
        else:
            count[ai - 1] += 1

yes_or_no = True
for num in count:
    if num % 2 == 1:
        yes_or_no = False

if yes_or_no:
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

#1は含まれない
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1


A,B=map(int,input().split())
L = cf(A,B)
cnt = 1
for l in L:
    if is_prime(l):
        cnt+=1

print(cnt)


### FIXED CODE ###

#1は含まれない
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = set(table)
    return table

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1


A,B=map(int,input().split())
AL = divisor(A)
BL = divisor(B)
AB = list(AL & BL)
cnt = 1
for l in AB:
    if is_prime(l):
        cnt+=1

print(cnt)
### BUGGY CODE ###

import math

N=int(input())
num=math.ceil(N**0.5)
num=int(num)
for i in range(num,N+1):
    if N%i==0:
        x=str(i)
        break
print(len(x))

### FIXED CODE ###

def cal(N):
    num=(N**0.5)//1
    num=int(num)
    for i in range(num,0,-1):
       if N%i==0:
           k=int(N/i)
           x=len(str(k))
           break
    return x

print(cal(int(input())))