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

import heapq

x = map(int,raw_input().split())
n=x[0]
m=x[1]
a = map(int, raw_input().split())

def minus(n):
    return float(n*(-1))

def plus(n):
    return int(n*(-1))

a=list(map(minus, a))

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

a=list(map(plus, a))

print(sum(a))


### FIXED CODE ###

import heapq

x = map(int,raw_input().split())
n=x[0]
m=x[1]
a = map(int, raw_input().split())

def minus(n):
    return float(n*(-1))

def plus(n):
    return int(n*(-1))

a=list(map(minus, a))
heapq.heapify(a)

for i in range(m):
    heapq.heappush(a, heapq.heappop(a)/2)

a=list(map(plus, a))

print(sum(a))
### BUGGY CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
l = 0
r = k - 1
ans_max = 0
for i in range(n-k+1):
    ans = 0
    for j in range(l, r+1):
        ans += (p[j]+1) / 2
    ans_max = max(ans, ans_max)
    l += 1
    r += 1
print(ans_max)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))

kitaiti = [0 for _ in range(n)]
ruisekiwa = [0 for _ in range(n)]
r = k - 1
max = 0
now = 0
ans_list = []

for i in range(n):
    kitaiti[i] = (p[i]+1) / 2
    if i == 0:
        ruisekiwa[0] = kitaiti[0]
    else:
        ruisekiwa[i] = ruisekiwa[i-1] + kitaiti[i]
    if i == r:
        now = ruisekiwa[i]
    elif i > r:
        now = ruisekiwa[i] - ruisekiwa[i-r-1]
    if now > max:
        max = now
print(max)
### BUGGY CODE ###

def Next(x):
    return chr((ord(x)-ord("a")+1)%26+ord("a"))

def Next_k(x,k):
    if k==0:
        return x
    else:
        return Next_k(Next(x),k-1)

def g(x):
    return (ord("z")-ord(x)+1)%26

A={chr(ord("a")+a):a for a in range(26)}

T=input()
S=[]
for s in T:
    S.append(s)
K=int(input())

I=0
N=len(S)
for i in range(N):
    if (i!=N-1) and (g(S[i])<=K):
        K-=g(S[i])
        S[i]="a"
    elif i==N-1:
        S[i]=Next_k(S[i],K%26)

U=""
for s in S:
    U+=s

print(U)


### FIXED CODE ###

G={chr(a+ord("a")):a for a in range(26)}
H={G[b]:b for b in G}

T=input()
S=[]
for s in T:
    S.append(G[s])
K=int(input())

I=0
N=len(S)
for i in range(N):
    if (i<N-1) and (26-S[i]<=K) and S[i]!=0:
        K-=26-S[i]
        S[i]=0
    elif i==N-1:
        S[i]=(S[i]+(K%26))%26

U=""
for s in S:
    U+=H[s]

print(U)
### BUGGY CODE ###

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

if abs(A-B)/2 < K:
    for i in range(A, B+1):
        print(i)
else:
    for i in range(A,B+1):        
        if (i < A+K)or (i>B-K):
            print(i)

### FIXED CODE ###

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

if abs(A-B)<K:
    for i in range(A, B+1):
        print(i)
else:
    x = {i for i in range(A, A+K)}
    y = {j for j in range(B-K+1, B+1)}
    z = x | y
    z = sorted(list(z))
    for a in z:
        print(a)
### BUGGY CODE ###

import numpy as np
ni8 = np.int64
MOD = 998244353


def solve(lr, dp, n, k):
    acc_dp = np.ones_like(dp)
    for i in range(1, n):
        val = 0
        for j in range(k):
            a = i - lr[j, 0]
            if a < 0:
                continue
            b = i - lr[j, 1] - 1
            val += acc_dp[a] - (acc_dp[b] if b >= 0 else 0)
        dp[i] = val % MOD
        acc_dp[i] = (acc_dp[i - 1] + dp[i]) % MOD
    return dp[n - 1]


def main():
    f = open(0)
    n, k = [int(x) for x in f.readline().split()]
    lr = np.fromstring(f.read(), ni8, sep=' ').reshape((-1, 2))
    dp = np.zeros(n, ni8)
    dp[0] = 1
    ans = solve(lr, dp, n, k)
    print(ans)

main()

### FIXED CODE ###

import numpy as np
from numba import njit
from numba.types import i8
ni8 = np.int64
MOD = 998244353


@njit((i8[:,::-1], i8[:], i8, i8), cache=True)
def solve(lr, dp, n, k):
    acc_dp = np.ones_like(dp)
    for i in range(1, n):
        val = 0
        for j in range(k):
            a = i - lr[j, 0]
            if a < 0:
                continue
            b = i - lr[j, 1] - 1
            val += acc_dp[a] - (acc_dp[b] if b >= 0 else 0)
        dp[i] = val % MOD
        acc_dp[i] = (acc_dp[i - 1] + dp[i]) % MOD
    return dp[n - 1]


def main():
    f = open(0)
    n, k = [int(x) for x in f.readline().split()]
    lr = np.fromstring(f.read(), ni8, sep=' ').reshape((-1, 2))
    dp = np.zeros(n, ni8)
    dp[0] = 1
    ans = solve(lr, dp, n, k)
    print(ans)

main()
### BUGGY CODE ###

s = [ str( input() ) ]
q = int( input() )
query = []
rev_flag_k = 0
for _ in range( q ):
    query_i = list( input().split() )
    query.append( query_i )
    if query_i[ 0 ] == "1":
        rev_flag_k += 1

rev_flag = 0
for query_i in query:
    t = query_i[ 0 ]
    if t == "1":
        rev_flag += 1
    else:
        f = query_i[ 1 ]
        c = query_i[ 2 ]
        if f == "1" and rev_flag % 2 == 1:
            s.append( str( c ) )
        elif f == "2" and rev_flag % 2 == 0:
            s.append( str( c ) )
        else:
            s.insert( 0, str( c ) )
s = "".join( s )
if rev_flag_k % 2 == 1:
    s = s[::-1]

print( s )

### FIXED CODE ###

s = [ str( input() ) ]
q = int( input() )
query = []
rev_flag_k = 0
for _ in range( q ):
    query_i = list( input().split() )
    query.append( query_i )
    if query_i[ 0 ] == "1":
        rev_flag_k += 1

top = []
rev_flag = 0
for query_i in query:
    t = query_i[ 0 ]
    if t == "1":
        rev_flag += 1
    else:
        f = query_i[ 1 ]
        c = query_i[ 2 ]
        if f == "1" and rev_flag % 2 == 1:
            s.append( str( c ) )
        elif f == "2" and rev_flag % 2 == 0:
            s.append( str( c ) )
        else:
            top.append( str( c ) )
s = "".join( top )[::-1] + "".join( s )
if rev_flag_k % 2 == 1:
    s = s[::-1]

print( s )
### BUGGY CODE ###

S=str(input())
S_list=list(S)

Q=int(input())

q=[]
right=[]
left=[]

rev=1

for i in range(Q):
    q.append(input().split())
    if q[i][0]=="1":
        rev=rev*(-1)
    elif q[i][0]=="2":
        if q[i][1]=="1":
            if rev==1:
                right.reverse()
                right.append(q[i][2])
                right.reverse()
            else:
                left.append(q[i][2])
        elif q[i][1]=="2":
            if rev==1:
                left.append(q[i][2])
            else:
                right.reverse()
                right.append(q[i][2])
                right.reverse()

if rev==1:
    S_list=right+S_list+left
else:
    S_list=right+S_list+left
    S_list.reverse()

S=''.join(S_list)
print(S)

### FIXED CODE ###

S=str(input())
S_list=list(S)

Q=int(input())

q=[]
right=[]
left=[]

rev=1

for i in range(Q):
    q.append(input().split())
    if q[i][0]=="1":
        rev=rev*(-1)
    elif q[i][0]=="2":
        if q[i][1]=="1":
            if rev==1:
                right.append(q[i][2])
            else:
                left.append(q[i][2])
        elif q[i][1]=="2":
            if rev==1:
                left.append(q[i][2])
            else:
                right.append(q[i][2])
right.reverse()
if rev==1:
    S_list=right+S_list+left
else:
    S_list=right+S_list+left
    S_list.reverse()

S=''.join(S_list)
print(S)
### BUGGY CODE ###

K = int(input())
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd(i, j , k)

print(ans)

### FIXED CODE ###

K = int(input())
import math
from functools import reduce

def gcd3(a, b, c):
    return math.gcd(math.gcd(a,b), c)
ans = 0

for i in range(1, K+1):
    for j in range(i+1, K+1):
        for k in range(j+1, K+1):
            ans += gcd3(i, j, k)

ans *= 6

for i in range(1, K+1):
    ans += gcd3(i, i, i)

for i in range(1, K+1):
    for j in range(i+1, K+1):
        ans += gcd3(i, i, j)
        ans += gcd3(i, i, j)
for i in range(1, K+1):
    for j in range(i+1, K+1):
        ans += gcd3(i, j, j)
        ans += gcd3(i, j, j)
for i in range(1, K+1):
    for j in range(i+1, K+1):
        ans += gcd3(i, j, i)
        ans += gcd3(i, j, i)
print(ans)
### BUGGY CODE ###

n = int(input())

ls = []

for _ in range(n):
    a = int(input())
    if a not in ls:
        ls.append(a)
    else:
        ls.remove(a)

print(len(ls))


### FIXED CODE ###

from collections import defaultdict

n = int(input())
d = defaultdict(int)
cnt = 0

for _ in range(n):
    d[int(input())] += 1

for i in d.values():
    if i % 2 == 1:
        cnt += 1

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

N = int(input())
S = list(input())
ans = []
for i in range(N):
    S_s = sum([ 1 for x in S[:i] if x == 'W' ])
    S_e = sum([ 1 for x in S[i+1:] if x == 'E']) 
    ans.append(S_s+S_e)
print(min(ans))

### FIXED CODE ###

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

ans = S.count('E')
w = 0
e = S.count('E')
for i in range(N):
    if S[i-1] == 'W' and i != 0:
        w += 1
    if S[i] == 'E':
        e -= 1
    if w + e < ans:
        ans = w + e
print(ans)
### BUGGY CODE ###

import numpy as np
N = int(input())
n = np.array([i + 1 for i in range(N)])
ans = 0

print(N * (N - 1) // 2)



### FIXED CODE ###

#import numpy as np
N = int(input())
#n = np.array([i + 1 for i in range(N)])
ans = 0

print(N * (N - 1) // 2)
### BUGGY CODE ###

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

for i in range(m):
    A[i][2] = - (A[i][2]-p)


import numpy as np
S = [np.inf for i in range(n+1)]

S[1]=0
for i in range(m):
    if A[i][0] == 1:
        S[A[i][1]]=A[i][2]

for j in range(n-1):
    for i in range(m):
        S[A[i][1]] = min(S[A[i][1]], S[A[i][0]]+A[i][2])

#print(S)
ans1 = -S[n]

for j in range(1):
    for i in range(m):
        S[A[i][1]] = min(S[A[i][1]], S[A[i][0]]+A[i][2])
#print(S)
ans2 = -S[n]

if ans1 != ans2:
    print(-1)
else:
    print(max(0, ans1))

### FIXED CODE ###

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

for i in range(m):
    A[i][2] = - (A[i][2]-p)

#import numpy as np
# A = np.full(np.inf, (n+1, n+1))

# scipy.sparse.csgraph.bellman_ford


S = [10**13 for i in range(n+1)]

S[1]=0
for i in range(m):
    if A[i][0] == 1:
        S[A[i][1]]=A[i][2]

for j in range(n-1):
    for i in range(m):
        S[A[i][1]] = min(S[A[i][1]], S[A[i][0]]+A[i][2])

#print(S)
ans1 = -S[n]

for j in range(n):
    for i in range(m):
        S[A[i][1]] = min(S[A[i][1]], S[A[i][0]]+A[i][2])
#print(S)
ans2 = -S[n]

if ans1 != ans2:
    print(-1)
else:
    print(max(0, ans1))
### BUGGY CODE ###

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

key = []

for i in range(10):
    for j in range(10):
        for k in range(10):
            key.append([i,j,k])
            
flag1 = 0
flag2 = 0
flag3 = 0
ans = 0



for i in range(len(key)):
    flag1 = 0
    flag2 = 0
    flag3 = 0
    
    for j in range(N):
        if key[i][0] == int(S[j]):
            flag1 = 1
            break
            
    for k in range(j+1,N):
        if key[i][1] == int(S[k]):
            flag2 = 1
            break
                
    for l in range(k+1,N):
        if key[i][2] == int(S[l]):
            flag3 = 1
            break
                            
    if flag1 == 1 and flag2 == 1 and flag3 == 1:
        ans += 1
        
print(ans)

### FIXED CODE ###

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

key = []

for i in range(10):
    for j in range(10):
        for k in range(10):
            key.append([i,j,k])
            
flag1 = 0
flag2 = 0
flag3 = 0
ans = 0



for i in range(len(key)):
    flag1 = 0
    flag2 = 0
    flag3 = 0
    
    flag1 = S.find(str(key[i][0]))
    
    if flag1 == -1:
        continue
        
    flag2 = S.find(str(key[i][1]),flag1+1)
    
    if flag2 == -1:
        continue
        
    flag3 = S.find(str(key[i][2]),flag2+1)
    
    if flag3 == -1:
        continue
                            
    if flag1 != -1 and flag2 != -1 and flag3 != -1:
        ans += 1
        
print(ans)
### BUGGY CODE ###

import numpy as np

N,M = list(map(int,input().split()))
Hlist = list(map(int,input().split()))
Mlist = [list(map(int,input().split())) for _ in range(M)]

adj = [[0 for _ in range(N)] for _ in range(N)]

for line in Mlist:
    adj[line[0]-1][line[1]-1] = 1
    adj[line[1]-1][line[0]-1] = 1

# for i in range(N):
#     adj[i][i] = 1

Hmatrix = [Hlist for _ in range(N)]
target = np.array(Hmatrix)*np.array(adj)
index_list = [i for i in range(len(adj)) if sum(adj[i]) != 0]

count = N - len(index_list)
for i in index_list:
    if max(target[i]) < Hlist[i]:
        count += 1
print(count)

### FIXED CODE ###

import numpy as np

N,M   = list(map(int,input().split()))
Hlist = list(map(int,input().split()))
Hdict = {i:Hlist[i] for i in range(len(Hlist))}
# adj = [[0 for _ in range(N)] for _ in range(N)]

# for line in Mlist:
bad_set = set()
for _ in range(M):
    line = list(map(int,input().split()))
    if Hdict[line[0]-1] <= Hdict[line[1]-1]:
        bad_set.add(line[0])
    if Hdict[line[1]-1] <= Hdict[line[0]-1]:
        bad_set.add(line[1])
print(N-len(bad_set))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def binary_search(ys,target,low,high,reverse=True):
    xs = sorted(ys)
    maxlen = len(xs)

    middle = 0
    #print("array => %s, target => %d" %(xs,target))
    while(low <= high):
        middle = (low + high) // 2
        #print("target %d, low %d, mid %d, high %d" %(target,low,middle,high))
        if xs[middle] == target:
             #print("find ",middle)
            if reverse == False:
                return middle
            else:
                return middle+1
        if xs[middle] > target:
            high = middle - 1
        elif xs[middle] < target:
            low = middle + 1

    middle = (low + high) // 2 +1
   # print("target %d, low %d, mid %d, high %d" %(target,low,middle,high))
    return middle
    


def snuke_festival(a,b,c):
    count = 0
    b_sorted = sorted(b)
    high = len(b)-1
    low = 0
    ab = 0
    bc = 0
    mid_a = 0
    mid_b = 0
    maxlen=len(b)
    for n in range(maxlen):
        mid_a = binary_search(a,b_sorted[n],mid_a,high,False)
        ab = mid_a
        mid_b = binary_search(c,b_sorted[n],low,mid_b,True)
        bc = maxlen - mid_b
        count += ab * bc
    return count

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    c = list(map(int,input().split()))

    print(snuke_festival(a,b,c))


### FIXED CODE ###

import sys
input = sys.stdin.readline
import bisect
    
def snuke_festival(a,b,c):
    count = 0
    a_sorted = sorted(a)
    b_sorted = sorted(b)
    c_sorted = sorted(c)
    maxlen=len(b)

    for target in b_sorted:
        #mid_a = binary_search_left(a_sorted,target)
        #mid_c = binary_search_right(c_sorted,target)
        mid_a = bisect.bisect_left(a_sorted,target)
        mid_c = bisect.bisect_right(c_sorted,target)
        count += mid_a * (maxlen - mid_c)
        #print("mid_a %d, mid_c %d, count %d" %(mid_a,maxlen - mid_c,count))
    return count

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    c = list(map(int,input().split()))

    print(snuke_festival(a,b,c))
### BUGGY CODE ###

import math
def div(s):
    i=1
    while(i<=math.sqrt(s)):
        if(s%i==0):
            if(s//i==i):
                if(i!=1):
                    if(i in d):
                        return False
                    else:
                        d[i]=1
            else:
                if(i!=1):
                    if(i in d):
                        return False
                    else:
                        d[i]=1
                if(s//i!=1):
                    if(s//i in d):
                        return False
                    else:
                        d[s//i]=1
        i+=1
    #print(d,s)
    return True
                

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

d=dict()

setwise=False
pairWise=True

for i in range(n):
    pairWise&=div(l[i])
val=math.gcd(l[0],l[1])
for i in range(2,n):
    val=math.gcd(val,l[i])
if(pairWise):
    print('pairwise coprime')
elif(val==1):
    print('setwise coprime')
else:
    print('not coprime')


### FIXED CODE ###

import math
def div(s):
    i=1
    while(i<=math.sqrt(s)):
        if(s%i==0):
            if(s//i==i):
                if(i!=1):
                    if(i in d):
                        return False
                    else:
                        d[i]=1
            else:
                if(i!=1):
                    if(i in d):
                        return False
                    else:
                        d[i]=1
                if(s//i!=1):
                    if(s//i in d):
                        return False
                    else:
                        d[s//i]=1
        i+=1
    #print(d,s)
    return True
                

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

d=dict()

setwise=False
pairWise=True
pairWise&=div(l[0])
pairWise&=div(l[1])
val=math.gcd(l[0],l[1])

for i in range(2,n):
    pairWise&=div(l[i])
    val=math.gcd(val,l[i])
if(pairWise):
    print('pairwise coprime')
elif(val==1):
    print('setwise coprime')
else:
    print('not coprime')
### BUGGY CODE ###

n,k=map(int,input().split())
s,p=list(input()),""
def proc(t):
	return ['B']+t[1:] if t[0]=='A' else ['A' if t[i]=='B' else 'B' for i in range(1,n)]+['A']
for i in range(2*n):
	s=proc(s)
	if i==k-1:
		print(''.join(s))
		break
else:
	if n%2==1 and k%2==1:
		s=proc(s)
	print(''.join(s))

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())*3
p=['A' if s[i]=='B' else 'B' for i in range(n)]*3
head,tail=0,n
for i in range(2*n):
	if s[head]=='A':
		s[head],p[head]='B','A'
	else:
		s,p=p,s
		head+=1
		s[tail],p[tail]='A','B'		
		tail+=1
	if i==k-1:
		print(''.join(s[head:tail]))
		break
else:
	if n%2==1 and k%2==1:
		if s[head]=='A':
			s[head],p[head]='B','A'
		else:
			s,p=p,s
			head+=1
			s[tail],p[tail]='A','B'		
			tail+=1
	print(''.join(s[head:tail]))
### BUGGY CODE ###

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

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


N = int(input())

uf = UnionFind(N)

xy = []
min_y = []
for i in range(N):
    x, y = map(int, input().split())
    xy.append((x, y, i))
    min_y.append(y)

xy.sort()

s = set()

for i in range(N):
    x, y, a = xy[i]
    s.add(i)

    remove = set()
    for j in s:
        if j == i:
            continue

        x2, y2, b = xy[j]

        if y2 < y:
            uf.union(b, a)
            root = uf.find(b)
            if min_y[root] > y:
                min_y[root] = y
                remove.add(j)
            else:
                remove.add(i)
    s -= remove

for i in range(N):
    print(uf.get_size(i))


### FIXED CODE ###

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

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


N = int(input())

uf = UnionFind(N)

xy = []
min_y = []
for i in range(N):
    x, y = map(int, input().split())
    xy.append((x, y, i))
    min_y.append(y)

xy.sort()

min_y = N+1

for i in range(N-1):
    x, y, a = xy[i]
    x1, y1, b = xy[i+1]
    min_y = min(min_y, y)
    if min_y != N - i:
        uf.union(a, b)

for i in range(N):
    print(uf.get_size(i))
### BUGGY CODE ###

n,k,l=map(int,input().split())
load=[[] for _ in range(n)]
train=[[] for _ in range(n)]
for _ in range(k):
  a,b=map(int,input().split())
  a-=1
  b-=1
  load[a].append(b)
  load[b].append(a)
for _ in range(l):
  a,b=map(int,input().split())
  a-=1
  b-=1
  train[a].append(b)
  train[b].append(a)

# 道路の連結グループ
load_grp_id=[-1]*n
for t0 in range(n):
  if load_grp_id[t0]!=-1:continue
  todo=[t0]
  seen=[0]*n
  load_grp_id[t0]=t0
  while todo:
    t=todo.pop()
    l=load[t]
    for li in l:
      if load_grp_id[li]==-1:
        load_grp_id[li]=t0
        todo.append(li)
# 鉄道の連結グループ
train_grp_id=[-1]*n
for t0 in range(n):
  if train_grp_id[t0]!=-1:continue
  todo=[t0]
  seen=[0]*n
  train_grp_id[t0]=t0
  while todo:
    t=todo.pop()
    l=train[t]
    for li in l:
      if train_grp_id[li]==-1:
        train_grp_id[li]=t0
        todo.append(li)

d={}
for i in range(n):
  lid=load_grp_id[i]
  tid=train_grp_id[i]
  if (lid,tid) in d:
    d[(lid,tid)]+=1
  else:
    d[(lid,tid)]=1
ans=[]
for i in range(n):
  lid=load_grp_id[i]
  tid=train_grp_id[i]
  ans.append(str(d[(lid,tid)]))
print(' '.join(ans))

### FIXED CODE ###

n,k,l=map(int,input().split())
load=[[] for _ in range(n)]
train=[[] for _ in range(n)]
for _ in range(k):
  a,b=map(int,input().split())
  a-=1
  b-=1
  load[a].append(b)
  load[b].append(a)
for _ in range(l):
  a,b=map(int,input().split())
  a-=1
  b-=1
  train[a].append(b)
  train[b].append(a)

# 道路の連結グループ
load_grp_id=[-1]*n
not_grp=set(range(n))
while not_grp:
  t0=not_grp.pop()
  todo=[t0]
  load_grp_id[t0]=t0
  while todo:
    t=todo.pop()
    l=load[t]
    for li in l:
      if load_grp_id[li]==-1:
        load_grp_id[li]=t0
        not_grp.discard(li)
        todo.append(li)
# 鉄道の連結グループ
train_grp_id=[-1]*n
not_grp=set(range(n))
while not_grp:
  t0=not_grp.pop()
  todo=[t0]
  train_grp_id[t0]=t0
  while todo:
    t=todo.pop()
    l=train[t]
    for li in l:
      if train_grp_id[li]==-1:
        train_grp_id[li]=t0
        not_grp.discard(li)
        todo.append(li)

d={}
for i in range(n):
  lid=load_grp_id[i]
  tid=train_grp_id[i]
  if (lid,tid) in d:
    d[(lid,tid)]+=1
  else:
    d[(lid,tid)]=1
ans=[]
for i in range(n):
  lid=load_grp_id[i]
  tid=train_grp_id[i]
  ans.append(str(d[(lid,tid)]))
print(' '.join(ans))
### BUGGY CODE ###

import copy

def main(N, L):
    L.sort(reverse=True)

    triangles = 0

    for i, P in enumerate(L):
        Q_list = copy.copy(L)
        del Q_list[:i + 1]
        for j, Q in enumerate(Q_list):
            if Q < P / 2:
                break
            minR = P - Q + 1
            R_list = copy.copy(Q_list)
            del R_list[:j + 1]
            for R in R_list:
                if R >= minR:
                    triangles += 1
                else:
                    break

    print(triangles)

if __name__ == '__main__':
    N = int(input())
    L = list(map(int, input().split()))
    main(N, L)


### FIXED CODE ###

import copy
import bisect

N = int(input())
L = sorted(list(map(int, input().split())))

triangles = 0

for i in range(N - 2):
    P = L[i]
    for j in range(i + 1, N - 1):
        Q = L[j]
        if P + Q <= L[j + 1]:
            continue
        maxR = P + Q - 1
        triangles += bisect.bisect_right(L, maxR) - (j + 1)

print(triangles)