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

import math
import sys
import numpy as np
from decimal import Decimal, ROUND_HALF_UP
N = int(input())
A_list = list(map(str,input().split()))
B_list = []

if '0' in A_list:
  print('0')
  sys.exit()
  
else:
  for i in range(N):
    logA = Decimal(A_list[i]).log10()
    B_list.append(logA)

sum = 0
for j in range(N):
  sum += B_list[j]

if sum > 18:
  print('-1')
else:
  pro = np.power(10,sum)
  print(Decimal(str(pro)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))

### FIXED CODE ###

import sys
N = int(input())
A_list = list(map(int,input().split()))
border = 10**18

if 0 in A_list:
  print(0)
  sys.exit()
else:
  A_list.sort(reverse=True)
  pro = 1
  for i in range(N):
    pro *= A_list[i]
    if pro > 10**18:
      print('-1')
      sys.exit()
    else:
      pass

print(pro)
### BUGGY CODE ###

N=input()
P=[list(map(int,input().split())) for i in range(3)]
ans=0
for i in P[0]:
    for j in P[1]:
        for k in P[2]:
            if i<j<k:ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
A,B,C=[sorted(map(int,input().split())) for i in range(3)]
ans=a=c=0
for i in B:
    while a<N and A[a]<i:
        a+=1
    while c<N and C[c]<=i:
        c+=1
    if c==N:break
    ans+=a*(N-c)
print(ans)
### BUGGY CODE ###

l,r=map(int,input().split())

r=min(r,l+4038)

ans=2020

for i in range (l,r):
    for j in range(i+1,r+1):
        ans=min(ans,i*j%2019)

print(ans)


### FIXED CODE ###

l,r=map(int,input().split())

ans=2020

if(r-l>=2019):
    print(0)
else:
    for i in range (l,r):
        for j in range(i+1,r+1):
            ans=min(ans,i*j%2019)
    print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[];B=[]
retu=[[0]*N for _ in range(N)]
flg=[1]*N


for m in range(M):
  array=list(map(int,input().split()))
  A.append(array[0])
  B.append(array[1])

for m in range(M):
  if H[A[m]-1]<H[B[m]-1]:
    flg[A[m]-1]=0
  elif H[A[m]-1]>H[B[m]-1]:
    flg[B[m]-1]=0
  else:
    flg[A[m]-1]=flg[B[m]-1]=0
  
print(sum(flg))
 
  

### FIXED CODE ###

N,M=map(int,input().split())
H=list(map(int,input().split()))
flg=[1]*N


for m in range(M):
  a,b =map(int,input().split())
  if H[a-1]<H[b-1]:
    flg[a-1]=0
  elif H[a-1]>H[b-1]:
    flg[b-1]=0
  else:
    flg[a-1]=flg[b-1]=0
  
print(flg.count(1))
### BUGGY CODE ###

num = int(input())
data = []
for _ in range(num):
    data.append(sorted(input()))
data = sorted(data)
count = 0
for i in range(num):
    tmp = data[i]
    for j in range(i+1,num):
        if tmp == data[j]:
            count+=1
        else:
            break
print(count)

### FIXED CODE ###

"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

n = int(input())

data = {}
for _ in range(n):
    temp = "".join(sorted(input()))
    # print(temp)
    if temp in data.keys():
        data[temp] += 1
    else:
        data[temp] = 1
# print(data)

answer = 0
for num in data.values():
    answer += (num*(num-1))//2
print(answer)
### BUGGY CODE ###

n,k=list(map(int,input().split()))
data=[int(x) for x in input().split()]
ans=[0]*n
for q in range(1,n):
    min=abs(data[q]-data[q-1])+ans[q-1]
    for w in range(q-2,q-k-1,-1):
        if(w>=0):
            val=abs(data[q]-data[w])+ans[w]
            #print(val)
            if(val<min):
                min=val
        else:
            break
    #print(min)
    ans[q]=min
print(ans[-1])


### FIXED CODE ###

n,k=list(map(int,input().split()))
data=[int(x) for x in input().split()]
ans=[0]*n
for q in range(1,n):
    min=abs(data[q]-data[q-1])+ans[q-1]
    for w in range(q-2,q-k-1,-1):
        if(w>=0):
            val=abs(data[q]-data[w])+ans[w]
            #print(val)
            if(val<min):
                min=val
        else:
            break
    #print(min)
    ans[q]=min
print(ans[-1])
### BUGGY CODE ###

import heapq

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())), reverse = True)

flg = 0
heap = []

for i in range(N):
	heapq.heappush(heap, [- A[i] * F[i], F[i]])
	
for i in range(K):
	score, tmp_F = heapq.heappop(heap)
	if score != 0:
		score += tmp_F
		heapq.heappush(heap, [score, tmp_F])
	else:
		flg = 1
		break
		
if flg:
	print(0)
else:
	ret = heapq.heappop(heap)
	print(-1 * ret[0])	


### FIXED CODE ###

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

A.sort()
F.sort(reverse = True)

ng = -1
ok = 10 ** 12

while ok - ng > 1:
	mid = (ok + ng) // 2
	ctr = 0
	for i in range(N):
		ctr += max(0, A[i] - mid // F[i])
	if ctr <= K:
		ok = mid
	else:
		ng = mid

print(ok)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N = int(readline())
A = np.array([int(x) for x in readline().rstrip().split()])
A_sum = A.sum()
A_sum //= 2
ans = []
for i in range(N):
    temp = A_sum
    flag = 1
    for _ in range((N - 1) // 2):
        if flag:
            i += 1
            flag = 0
        else:
            i += 2
        if i >= N:
            i -= N
        temp -= A[i]
    ans.append(2 * temp)
print(* ans)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N = int(readline())
A = np.array([int(x) for x in readline().rstrip().split()])
A_sum = A.sum()
A_sum //= 2
ans = []
x1 = A_sum
j = 1
for i in range((N-1)//2):
    x1 -= A[j]
    j += 2
ans.append(2 * x1)
for k in range(1, N):
    x = A[k-1] - (ans[k-1] // 2)
    ans.append(2 * x)
print(* ans)
### BUGGY CODE ###

N = int(input())


i = 0
sum = 0
item_list = []

while i < N:
  item = input()
  if not(item in item_list) :
    item_list.append(item)
    sum += 1
  i += 1
#while_end

print(sum)





### FIXED CODE ###

N = int(input())

i = 0
item_list = []

while i < N:
  item = input()
  item_list.append(item)
  i += 1
#while_end

print(len(set(item_list)))
### BUGGY CODE ###

from collections import deque

Q = deque()
N, X, Y = map(int, input().split())
K = [0 for i in range(N)]

edge = [[]for i in range(N+1)]
for i in range(1, N):
    edge[i].append(i + 1)
    edge[i+1].append(i)
edge[X].append(Y)
edge[Y].append(X)

for i in range(1, N):
    Done = [-1 for j in range(N+1)]
    Q.append(i)
    Done[0] = 0
    Done[i] = 0
    while len(Q) > 0:
        x = Q.popleft()
        for y in edge[x]:
            if Done[y] >= 0:
                continue
            else:
                Done[y] = Done[x] + 1
                Q.append(y)
                if y > i:
                    K[Done[y]] += 1

for z in K[1:]:
    print(z)


### FIXED CODE ###

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
K = [0] * N

for i in range(N-1):
    for j in range(i+1, N):
        a = abs(j - i)
        b = abs(X - i) + 1 + abs(j - Y)
        c = abs(Y - i) + 1 + abs(j - X)
        K[min(a, b, c)] += 1

for i in range(1, N):
    print(K[i])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N = [int(x) for x in input().rstrip()][::-1] + [0]
L = len(N)

dp = [[10 ** 18, 10 ** 18] for _ in range(L)]
dp[0] = [N[0], 10 - N[0]]

for i in range(1, L):
    n = N[i]
    dp[i][0] = min(dp[i - 1][0] + n, dp[i - 1][1] + (n + 1))
    dp[i][1] = min(dp[i - 1][0] + (10 - n), dp[i - 1][1] + (10 - (n + 1)))

print(dp[-1][0])

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = [int(x) for x in input().rstrip()][::-1] + [0]
L = len(N)

dp = [[10 ** 18, 10 ** 18] for _ in range(L + 1)]
dp[0] = [0, 0]
dp[1] = [N[0], 10 - N[0]]

for i in range(2, L + 1):
    n = N[i - 1]
    dp[i][0] = min(dp[i - 1][0] + n, dp[i - 1][1] + (n + 1))
    dp[i][1] = min(dp[i - 1][0] + (10 - n), dp[i - 1][1] + (10 - (n + 1)))

print(dp[-1][0])
### BUGGY CODE ###

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

be = A[0:K]
b = 1
for i in be:
    b *= i
for i in range(N-K):
    af = A[i+1:i+K+1]
    a = 1
    for i in af:
        a *= i
    if b < a :
        print("Yes")
    else:
        print("No")
    b = a


### FIXED CODE ###

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

result = []
for i in range(K, N):
    if A[i] > A[i - K]:
        result.append('Yes')
    else:
        result.append('No')
print(*result, sep='\n')
### BUGGY CODE ###

N = int(input())
S = input()

from collections import defaultdict
d = defaultdict(list)

for ix, c in enumerate(S):
    d[c].append(ix+1)

ans = len(d["B"]) * len(d["G"]) * len(d["R"])

for i in range(1, N+1):
    for j in range(i+1, N+1):
        k = 2 * j - i
        # print(i,j,k)
        if k > j and k <= N and S[i-1] != S[j-1] and S[i-1] != S[k-1] and S[j-1] != S[k-1]:
            ans -= 1
print(ans)

### FIXED CODE ###

N = int(input())
S = input()

from collections import defaultdict
# d = defaultdict(list)
d = defaultdict(int)

for ix, c in enumerate(S):
    # d[c].append(ix+1)
    d[c] += 1

# ans = len(d["B"]) * len(d["G"]) * len(d["R"])
ans = d["R"] * d["G"] * d["B"]

for i in range(1, N+1):
    ci = S[i-1]
    for j in range(i+1, N+1):
        cj = S[j-1]

        if ci == cj:
            continue

        k = j + j - i
        if k <= N:
            ck = S[k-1]
            if ci != ck and cj != ck:
                ans -= 1
        else:
            break
print(ans)
### BUGGY CODE ###

N = int(input())
S = input()
s = list(S)
r = 0
g = 0
b = 0
for i in range(N):
    if s[i] == 'R':
        r = r + 1
    if s[i] == 'G':
        g = g + 1
    if s[i] == 'B':
        b = b + 1
p = 0
for i in range(N-1):
    for j in range(i+1,N):
        if 2*j-i < N:
            if s[2*j-i] == s[i] or s[2*j-i] == s[j] or s[i] == s[j]:
                p = p
            else:
                p = p+1
print(r*g*b-p)

### FIXED CODE ###

N = int(input())
S = input()
s = list(S)
r = 0
g = 0
b = 0
for i in range(N):
    if s[i] == 'R':
        r = r + 1
    if s[i] == 'G':
        g = g + 1
    if s[i] == 'B':
        b = b + 1
p = 0
for i in range(N-1):
    for j in range(i+1,N):
        if 2*j-i < N:
            if s[2*j-i] == s[i] or s[2*j-i] == s[j] or s[i] == s[j]:
                p = p
            else:
                p = p+1
        else:
            break
print(r*g*b-p)
### BUGGY CODE ###

import sys

p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def pbit(aa,L):
    for a in aa:print(format(a,"b").zfill(L))
    print()

def main():
    n=II()
    aa=[[int(c) for c in SI()] for _ in range(n-1)]
    #p2D(aa)
    
    # 人iが勝てる相手をbitで管理する
    win=[0]*n
    for i,row in enumerate(aa,1):
        for j,a in enumerate(row):
            if a:win[i]|=1<<j
            else:win[j]|=1<<i
    #pbit(win,n)

    # dpl[i]...[j,i]の範囲で優勝できるjをbitで
    # dpr[i]...[i,j]の範囲で優勝できるjをbitで
    dpl=[1<<i for i in range(n)]
    dpr=[1<<i for i in range(n)]
    for d in range(1,n):
        for i in range(n):
            j=i+d
            if j<n and dpl[j] & dpr[i+1] & win[i]:dpl[j]|=1<<i
            j=i-d
            if j>=0 and dpl[i-1] & dpr[j] & win[i]:dpr[j]|=1<<i
    #pbit(dpl,n)
    #pbit(dpr,n)
    #print(format(dpl[n-1]&dpr[0],"b").zfill(n))
    print(bin(dpl[n-1]&dpr[0]).count("1"))

main()

### FIXED CODE ###

import sys

p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def pbit(aa,L):
    for a in aa:print(format(a,"b").zfill(L))
    print()

def main():
    n=II()
    aa=[[int(c) for c in SI()] for _ in range(n-1)]
    #p2D(aa)
    
    # 人iが勝てる相手をbitで管理する
    win=[0]*n
    for i,row in enumerate(aa,1):
        for j,a in enumerate(row):
            if a:win[i]|=1<<j
            else:win[j]|=1<<i
    #pbit(win,n)

    # dpl[i]...[j,i]の範囲で優勝できるjをbitで
    # dpr[i]...[i,j]の範囲で優勝できるjをbitで
    dpl=[1<<i for i in range(n)]
    dpr=[1<<i for i in range(n)]
    for d in range(1,n):
        for i in range(n):
            j=i+d
            if j<n and dpl[j] & dpr[i+1] & win[i]:dpl[j]|=1<<i
            j=i-d
            if j>=0 and dpl[i-1] & dpr[j] & win[i]:dpr[j]|=1<<i
    #pbit(dpl,n)
    #pbit(dpr,n)
    #print(format(dpl[n-1]&dpr[0],"b").zfill(n))
    print(bin(dpl[n-1]&dpr[0]).count("1"))

main()
### BUGGY CODE ###

N=int(input())
L=[int(x) for x in input().split()]
L.sort()
count=0

for i,a in enumerate(L):
    for j,b in enumerate(L[i+1:]):
        for k,c in enumerate(L[i+j+2:]):
            if c>=a+b:
                break
            count+=1
print(count)

### FIXED CODE ###

def main():
    N=int(input())
    L=[int(x) for x in input().split()]
    L.sort()
    count=0

    dic={}

    for i in range(N):
        for j in range(i+1,N):
            if i:
                try:
                    start=dic[j]
                    count+=dic[j]-j-1
                except:
                    count+=N-j-1
                    continue
            else:
                start=j+1
            for k in range(start,N):
                if L[k]>=L[i]+L[j]:
                    dic[j]=k
                    break
                count+=1
                
                
                
    print(count)

main()
### BUGGY CODE ###

from collections import Counter
s=input()[::-1]
m=len(s)
DP=[0]
word=""

for i in s:
    word +=i
    DP.append(int(word[::-1])%2019)

DP=Counter(DP)
ans=0
for v,m in DP.items():
    if m>=2:
        ans +=m*(m-1)//2
print(ans)

### FIXED CODE ###

from collections import Counter
s=input()[::-1]
DP=[0]

num,point=0,1
for i in s:
    num +=int(i)*point
    num %=2019
    DP.append(num)
    point *=10
    point %=2019

ans=0
DP=Counter(DP)
for v,m in DP.items():
    if m>=2:
        ans +=m*(m-1)//2
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
A = [int(c) for c in input().split()]

numbers = set(A)
numbers = {n: A.count(n) for n in numbers}
numbers = [A.count(n) for n in numbers]
numbers.sort()
if len(numbers) <= K:
    print(0)
else:
    print(sum(numbers[:len(numbers) - K]))


### FIXED CODE ###

from collections import defaultdict

N, K = map(int, input().split())
A = list(map(int, input().split()))
D = defaultdict(lambda: 0)
for a in A:
    D[a] += 1
V = list(D.values())
V.sort(reverse=True)
print(sum(V[K:]))
### BUGGY CODE ###

def solve(N,X):
    ans = []
    cnt = X.count("1")

    for i in range(N):
        if X[i] == "1":
            X[i] = "0"
            ans.append(cal(X,0))
            X[i] = "1"
        else:
            X[i] = "1"
            ans.append(cal(X,0))
            X[i] = "0"
    return ans

def cal(X,rec):
    cnt = X.count("1")
    if cnt == 0:
        return rec
    else:
        amari = 0
        for i in range(len(X)):
            if X[i] == "1":
                amari += pow(2,len(X)-i-1,cnt)
                amari %= cnt
        b = bin(amari)[2:]
        Y = [b[i] for i in range(len(b))]
        return cal(Y,rec+1)

def main():
    N = int(input())
    X = list(input())

    ans = solve(N,X)
    for i in range(N):
        print(ans[i])

if __name__ == "__main__":
    main()


### FIXED CODE ###

def solve(N,X):
    ans = []
    cnt = X.count("1")
    rem_ori = [0,0]
    for i in range(N):
        if X[i] == "1":
            if cnt != 1:
                rem_ori[0] += pow(2,N-i-1,cnt-1)
                rem_ori[0] %= (cnt-1)
            else:
                rem_ori[0] = 0
            rem_ori[1] += pow(2,N-i-1,cnt+1)
            rem_ori[1] %= (cnt+1)

    rem = [(rem_ori[0] if X[i] == "1" else rem_ori[1]) for i in range(N)]
    for i in range(N):
        if X[i] == "1":
            if cnt != 1:
                rem[i] -= pow(2,N-i-1,cnt-1)
                rem[i] %= (cnt-1)
                ans.append(cal(rem[i],1))
            else:
                ans.append(0)
        else:
            rem[i] += pow(2,N-i-1,cnt+1)
            rem[i] %= (cnt+1)
            ans.append(cal(rem[i],1))

    return ans

def cal(rem,rec):
    if rem == 0:
        return rec
    else:
        b = bin(rem)[2:]
        cnt = b.count("1")
        rem %= cnt
        return cal(rem,rec+1)

def main():
    N = int(input())
    X = input()

    ans = solve(N,X)
    for i in range(N):
        print(ans[i])

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

n, q = map(int, input().split())
s = input()
for i in range(q):
    l, r = map(int, input().split())
    print(s[l-1:r].count("AC"))

### FIXED CODE ###

n, q = map(int, input().split())
s = input()
lis = [0]
cnt = 0
for i in range(1, n):
    if s[i-1:i+1] == "AC":
        cnt += 1
        lis.append(cnt)
    else:
        lis.append(cnt)
for i in range(q):
    l, r = map(int, input().split())
    print(lis[r-1] - lis[l-1])
### BUGGY CODE ###

'''
制約
2≦K≦2500
0≦S≦3K
K,S は整数である。



'''
# from collections import deque # キュー、スタックに利用

# sys.stdin.readline() # 標準入力の高速化に利用
import sys
input = sys.stdin.readline

# import numpy as np


def main():
    '''メイン処理'''
    k, s = list(map(int, input().split()))

    counter = 0
    # x,y,zは全て0～kの値を取る。 x+y+z = sを満たす。
    for x in range(k+1):
        for y in range(k+1):
            for z in range(k+1):
                if (x+y+z) == s:
                    counter += 1

    print(counter)


if __name__ == "__main__":
    # ファイル実行時に、main()関数を実行
    main()


### FIXED CODE ###

'''
制約
2≦K≦2500
0≦S≦3K
K,S は整数である。

'''
# from collections import deque # キュー、スタックに利用

# sys.stdin.readline() # 標準入力の高速化に利用
import sys
input = sys.stdin.readline

# import numpy as np


def main():
    '''メイン処理'''
    k, s = map(int, input().split())

    counter = 0
    # x,y,zは全て0～kの値を取る。 x+y+z = sを満たす。
    for x in range(k+1):
        if x > s:
            # 合計がsを超えたら、このforループでは条件を満たせないのでbreak
            break

        for y in range(k+1):
            if x+y > s:
                # 合計がsを超えたら、このforループでは条件を満たせないのでbreak
                break
            
            # 3重ループではTLEになる。x+y+z = s なので、z=s-x-yとなるzがあればカウントする
            z = s-x-y
            if z >= 0 and z <= k:
                counter += 1

    print(counter)


if __name__ == "__main__":
    # ファイル実行時に、main()関数を実行
    main()
### BUGGY CODE ###

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

def prime(n):
    a = 2
    b = n
    ps = []
    while b != 1:
        if b % a == 0:
            ps.append(a)
            b /= a
        else:
            a += 1
    return ps

def count(ls):
    if ls == []:
        return 0
    else:
        n = len(ls)
        a = 1
        for i in range(n-1):
            if ls[i] != ls[i + 1]:
                a += 1
    return a

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

g = gcd(a,b)
ls = prime(g)
print(count(ls) + 1)


### FIXED CODE ###

import math
def gcd(a,b):
    while a > 0 and b > 0:
        if a > b:
            a = a % b
        elif a < b:
            b = b % a
        else:
            b = 0
    return max(a,b)

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

def trial(k):
    factor = []
    m = int(math.sqrt(k)) + 1
    for i in range(2,m):
        while k % i == 0:
            k = k // i
            factor.append(i)
    if not factor:
        return [1,k]
    else:
        factor.append(k)
        factor.append(1)
        return factor

k = gcd(a,b)

ps = trial(k)

count = 1
for i in range(len(ps)-1):
    if ps[i] != ps[i + 1]:
        count += 1

print(count)
### BUGGY CODE ###

n = int(input())
xs = list(map(int, input().split()))
 
ans = 0
sums = 0
xors = 0
for i in range(n):
  for j in range(i, n):
    sums += xs[j]
    xors ^= xs[j]
    if sums == xors:
      ans += 1
    else:
      break
  sums = 0
  xors = 0
print(ans)

### FIXED CODE ###

n = int(input())
xs = list(map(int, input().split()))
 
ans = 0
sums = xs[0]
xors = xs[0]
i, j = 0, 0

while True:
  if xors == sums:
    ans += j - i + 1
    j += 1
    if j >= n: break
    sums += xs[j]
    xors ^= xs[j]
  else:
    sums -= xs[i]
    xors ^= xs[i]
    i += 1
    
print(ans)
### BUGGY CODE ###

from collections import Counter

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


for i in range(N):
    kosu = Counter(A)

tempSum = 0
for v in kosu.values():
    tempSum += v * (v - 1) // 2


def C(N):
    if N <= 0:
        return 0
    else:
        return N*(N-1)//2


for a in A:
    print(tempSum - C(kosu[a]) + C(kosu[a] - 1))




### FIXED CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))

cnt = Counter(A)

ans = 0
for v in cnt.values():
    ans += v * (v - 1) // 2

for k in A:
    # n*(n-1)//2 - (n-1)*(n-2)//2 = n - 1
    print(ans - (cnt[k] - 1))
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import sys
import os
import math


N = int(input())
lst = []
for i in range(N):
    lst.append(int(input()))

max_diff = lst[1] - lst[0]

for i in range(N):
    for j in range(i + 1, N):
        diff = lst[j] - lst[i]
        if diff > max_diff:
            max_diff = diff

print(max_diff)

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
import os
import math


N = int(input())
lst = []
for i in range(N):
    lst.append(int(input()))

max_profit = lst[1] - lst[0]
min_value = min(lst[0], lst[1])

for i in range(2, N):
    price = lst[i]
    max_profit = max(max_profit, price - min_value)
    min_value = min(min_value, price)

print(max_profit)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

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

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

passed = [1 for _ in range(n)]

for card in range(1,n+1):
    for gate in gates:
        if not gate[0] <= card <= gate[1]:
            passed[card-1] = 0

print(sum(passed))


### FIXED CODE ###

import numpy as np
N,M=map(int,input().strip().split())
LR=np.array([list(map(int,input().strip().split())) for _ in range(M)])
print(max(min(LR[:,1])-max(LR[:,0])+1,0))
### BUGGY CODE ###

def solve():
    global N, A, PA, XA, i
    N = int(input())
    A = list(map(int, input().split()))

    PA = [0]*(N+1)
    XA = [0]*(N+1)

    PA[0] = A[0]
    XA[0] = A[0]

    for i in range(1,N):
        PA[i] = PA[i-1] + A[i]
        XA[i] = XA[i-1] ^ A[i]

    # print(PA)
    # print(XA)

    count = 0
    for i in range(N):
        r = bs(i, N, solver) - 1
        # print("i, r, r-i+1", i, r, r-i+1)
        count += r-i+1
    print(count)

def bs(ng, ok, solver):  # binary search for integer set
    import math
    """
    input:
        ng: max number known to be ng. default -1
        ok: min number known to be ok. default max number + 1
    output:
        the number that is OK firstly
    """
    while math.fabs(ok-ng) > 1:
        mid = (ok+ng)//2
        if solver(mid):
            ok = mid
        else:
            ng = mid
    return ok

def solver(x):
    if PA[x] - PA[i-1] == XA[x] ^ XA[i-1]:
        return False
    else:
        return True

if __name__ == "__main__":
    solve()


### FIXED CODE ###

import math
def solve():
    global N, A, PA, XA, i
    N = int(input())
    A = list(map(int, input().split()))

    PA = [0]*(N+1)
    XA = [0]*(N+1)
    PA[0] = A[0]
    XA[0] = A[0]

    for i in range(1,N):
        PA[i] = PA[i-1] + A[i]
        XA[i] = XA[i-1] ^ A[i]

    count = 0
    for i in range(N):
        r = bs(i, N, solver) - 1
        count += r-i+1
    print(count)

def bs(ng, ok, solver):  # binary search for integer set
    """
    input:
        ng: max number known to be ng. default -1
        ok: min number known to be ok. default max number + 1
    output:
        the number that is OK firstly
    """
    while math.fabs(ok-ng) > 1:
        mid = (ok+ng)//2
        if solver(mid):
            ok = mid
        else:
            ng = mid
    return ok

def solver(x):
    if PA[x] - PA[i-1] == XA[x] ^ XA[i-1]:
        return False
    else:
        return True

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

N = int(input())

ans = 0
for a in range(1,N):
    for b in range(1,N):
        c = N - a * b
        if a * b + c == N and c > 0:
            ans += 1
            # print(a,b,c)
        elif a * b > N:
            break

print(ans)


### FIXED CODE ###

N = int(input())

ans = 0
for a in range(1,N):
    for b in range(1,N):
        c = N - a * b
        if a * b + c == N and c > 0:
            ans += 1
            # print(a,b,c)
        elif a * b > N:
            break

print(ans)