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

import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


H, W, M = MI()
h = [0] * H
w = [0] * W
item_list = [[0, 0] for _ in range(M)]

for i in range(M):
    item_h, item_w = MI()
    item_h -= 1
    item_w -= 1
    h[item_h] += 1
    w[item_w] += 1
    item_list[i][0] = item_h
    item_list[i][1] = item_w
h_max = max(h)
w_max = max(w)

ans = h_max + w_max
index_num_h = [n for n, v in enumerate(h) if v == h_max]
index_num_w = [n for n, v in enumerate(w) if v == w_max]

cnt = 0
for item in item_list:
    if item[0] in index_num_h and item[1] in index_num_w:
        cnt += 1

x = len(index_num_h) * len(index_num_w)
if cnt == x:
    ans -= 1

print(ans)


### FIXED CODE ###

import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


H, W, M = MI()
h = [0] * H
w = [0] * W
item_list = [[0, 0] for _ in range(M)]

for i in range(M):
    item_h, item_w = MI()
    item_h -= 1
    item_w -= 1
    h[item_h] += 1
    w[item_w] += 1
    item_list[i][0] = item_h
    item_list[i][1] = item_w

h_max = max(h)
w_max = max(w)
h_cnt = h.count(h_max)
w_cnt = w.count(w_max)
ans = h_max + w_max

cnt = 0
for item in item_list:
    if h[item[0]] == h_max and w[item[1]] == w_max:
        cnt += 1

x = h_cnt * w_cnt
if cnt == x:
    ans -= 1

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

import numpy as np

N=int(input())
V=np.array(list(map(int,input().split())))
C=np.array(list(map(int,input().split())))
bit=[]
max=0
for i in range(2**N):
    bit=np.array([int(bin((i & (1 << j)) >> j), 0)  for j in range(N)])
    X=np.dot(V,bit)
    Y=np.dot(C,bit)
    if max<X-Y:
        max=X-Y
print(max)



### FIXED CODE ###

N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
dif=[]
count=0
for i in range(N):
    dif.append(int(V[i]-C[i]))

dif.sort(reverse=True)

i=0
for i in range(N):
    if dif[i]>=0:
        count=count+dif[i]
    else:
        break

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

#!/usr/bin/env python3
n = int(input())
ans = 0


def gcd(n, m):
    a, b = n, m
    if a > b:
        a, b = b, a
    while a != 0:
        a, b = b % a, a
    return b


for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            ans += gcd(k, gcd(i, j))
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
n = int(input())
ans = 0
# gcd_grid = [[0] * 201 for _ in range(201)]


def gcd(n, m):
    """if n <= 200 and m <= 200:
        if gcd_grid[n][m] != 0:
            return gcd_grid[n][m]"""
    a, b = n, m
    if a > b:
        a, b = b, a
    while a != 0:
        a, b = b % a, a
    # gcd_grid[n][m] = b
    # gcd_grid[m][n] = b
    return b


for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        for k in range(j + 1, n + 1):
            ans += 6 * gcd(k, gcd(i, j))
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        ans += 6 * gcd(i, j)
for i in range(n + 1):
    ans += i
print(ans)
### BUGGY CODE ###

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

mod = 10**9 + 7

ans = 0
for i in range(n):
    b = sum(arr_a[i+1:])
    b = b % mod
    ans += arr_a[i] * b
    ans = ans % mod

print(ans)


### FIXED CODE ###

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

mod = 10**9 + 7
memo = {}

for i in range(n):
    if i == 0:
        memo[n-i-1] = 0
    else:
        memo[n-i-1] = (memo[n-i] + arr_a[n-i]) % mod

ans = 0
for i in range(n):
    ans += arr_a[i] * memo[i]
    ans = ans % mod

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

MOD = 10**9+7
def fact(n):
    dict = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            dict[i] = cnt

    if temp!=1:
        dict[temp] = 1

    if dict=={}:
        dict[n] = 1

    return dict

def lcm(arr):
    # 素因数分解をもとにarr全体のLCMを求める
    lcm = 1
    factor = {}
    for a in arr:
        f = fact(a)
        for k,v in f.items():
            if k in factor:
                tmp = factor[k]
                factor[k] = max(factor[k],v)
                lcm *= pow(k,max(0, v-tmp),MOD)%MOD
            else:
                factor[k] = v
                lcm *= pow(k,v,MOD)%MOD

    return lcm

def main():
    N = int(input())
    A = list(map(int, input().split()))
    # 方針.A全体のlcmをLとすると、ans=Σ(i=[0,N])x/Ai
    ans = 0
    L = lcm(A)
    for a in A:
        ans += (L//a)%MOD
        ans %= MOD
    print(ans)

main()


### FIXED CODE ###

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def main():
    n=int(input())
    a=list(map(int,input().split()))
    mod=pow(10,9)+7
    lcma={}
    for ai in a:
      f=factorization(ai)
      for fi in f:
        if fi[0] in lcma:
          lcma[fi[0]]=max(lcma[fi[0]],fi[1])
        else:
          lcma[fi[0]]=fi[1]
    l=1
    for k,v in lcma.items():
      l*=pow(k,v,mod)
      l%=mod
    ans=0
    for ai in a:
      ans+=l*pow(ai,mod-2,mod)
      ans%=mod
    print(ans)

main()
### BUGGY CODE ###

def main():
    _ = input()
    li1 = [int(x) for x in input().split()]
    _ = input()
    li2 = [int(x) for x in input().split()]
    count = 0

    for l in li2:
        if binary_search(li1, l):
            count += 1

    print(count)


def binary_search(li, x):
    if len(li) == 0:
        return False
    
    mid = len(li)//2
    
    k = li[mid]
    if k == x:
        return True
    elif k > x:
        li = li[:mid]
    else:
        li = li[mid+1:]
        
    return binary_search(li, x)

if __name__=='__main__':
    main()


### FIXED CODE ###

import array

def main():
    n1 = int(input())
    li1 = array.array('l', [int(x) for x in input().split()])
    n2 = int(input())
    li2 = array.array('l', [int(x) for x in input().split()])
    count = 0

    for l in li2:
        if binary_search(li1, l):
            count += 1

    print(count)


def binary_search(li, x):
    if len(li) == 0:
        return False
    
    mid = len(li)//2
    
    k = li[mid]
    if k == x:
        return True
    elif k > x:
        li = li[:mid]
    else:
        li = li[mid+1:]
        
    return binary_search(li, x)

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

N = int(input())
f = True
for h in range(1,3501):
  for n in range(1,3501):
    w_ = (-(h+n)/(h*n) + 4/N)
    if w_ > 0:
      w = (1/w_)
      if w%1 == 0:
        print(h,n,int(w))
        f = False
        break
      if not f:
        break
  if not f:
    break

### FIXED CODE ###

N = int(input())
f = True
for h in range(1,3501):
  for n in range(1,3501):
    w_ = (-(h+n)/(h*n) + 4/N)
    if w_ > 0:
      w = (1/w_)
      if w%1 < 10E-8:
        print(h,n,int(w))
        f = False
        break
  if not f:
    break
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    print(a.count(i+1))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(0)
for i in a:
    b[i-1]+=1
for i in b:
    print(i)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
    print(a.count(i))


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(len(a)):
    b[a[i]-1]+=1
for i in b:
    print(i)
### BUGGY CODE ###

n=int(input())
lst=list(map(int,input().split()))
total=0
for i in range(n):
  temp=0
  for j in range(i+1, n):
    temp+=lst[j]
  total+=lst[i]*temp
print(total%(10**9+7))

### FIXED CODE ###

n=int(input())
lst=list(map(int,input().split()))
total=0
temp=0
for i in range(1, n):
  temp+=lst[i]
for j in range(n-1):
  total+=lst[j]*temp
  temp-=lst[j+1]
print(total%(10**9+7))
### BUGGY CODE ###

import sys

def findLCS(X, Y):
    C = [[0 for i in range(1001)] for j in range(1001)]
    X, Y = " " + X, " " + Y
    m, n, maxl = len(X), len(Y), 0

    for i in range(1, m):
        for j in range(1, n):
            if X[i] == Y[j]:
                C[i][j] = C[i - 1][j - 1] + 1
            else:
                C[i][j] = max(C[i - 1][j], C[i][j - 1])
            maxl = max(maxl, C[i][j])

    return maxl

lines = sys.stdin.readlines()
N = int(lines[0])

for i in range(N):
    X = lines[2 * i + 1].strip()
    Y = lines[2 * i + 2].strip()
    print findLCS(X, Y)

### FIXED CODE ###

import sys

def findLCS(X, Y):
    m, n = len(X), len(Y)
    C = [0] * (n + 1)

    for i in range(m):
        prev = C[:]
        for j in range(n):
            if X[i] == Y[j]:
                C[j + 1] = prev[j] + 1
            elif C[j + 1] < C[j]:
                C[j + 1] = C[j]

    return C[-1]

lines = sys.stdin.readlines()
N = int(lines[0])

for i in range(N):
    X = lines[2 * i + 1].strip()
    Y = lines[2 * i + 2].strip()
    print findLCS(X, Y)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

from collections import Counter
from copy import deepcopy
from bisect import insort


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

    #n = 3 * 10 ** 5
    #a = list(range(1, n + 1))

    c = Counter(a)
    c = list(c.values())
    c.sort()

    k_mx = len(c)

    for k in range(1, n + 1):
        if k > k_mx:
            print(0)
            continue

        cp = deepcopy(c)
        ans = 0

        while True:
            eat = cp[-k:]
            if eat[0] == 0:
                break

            cp = cp[:-k]
            for e in eat:
                left = e - eat[0]
                insort(cp, left)

            ans += eat[0]

        print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

from collections import Counter
from itertools import accumulate
from math import floor
from bisect import bisect_left


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

    c = Counter(a)
    c = list(c.values())

    d = Counter(c)
    d_li = [0] * (n + 1)
    for k, v in d.items():
        d_li[k] = v

    dk_acm = list(accumulate(d_li))

    kdk_acm = [0]
    for k, e in enumerate(d_li[1:], 1):
        kdk_acm.append(kdk_acm[-1] + k * e)

    def f(x):
        kdk_sm = kdk_acm[x]
        dk_sm = dk_acm[n] - dk_acm[x]

        return floor((kdk_sm + x * dk_sm) / x)

    fs = [float("inf")] + [f(x) for x in range(1, n + 1)]
    fs = fs[::-1]

    for k in range(1, n + 1):
        print(n - bisect_left(fs, k))


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

import sys
sys.setrecursionlimit(10000)

n=int(input())
a=[[0]*(n-1) for i in range(n)]
id=[[-1]*(n) for i in range(n)]
MAXV=n*(n-1)//2
to=[[]*(n) for i in range(MAXV)]
  
def toId(i,j):
  if (i>j):
    i,j=j,i
  return id[i][j]


visited=[False]*MAXV
calculated=[False]*MAXV
dp=[0]*MAXV
def dfs(v):
  if visited[v]:
    if not calculated[v]:
      return -1
    return dp[v]
  visited[v]=True
  dp[v]=1
  for u in to[v]:
    res = dfs(u)
    if res==-1:
      return -1
    dp[v]=max(dp[v], res+1)
  calculated[v]=True
  return dp[v]


def main():
  for i in range(n):
    a[i]=list(map(lambda x:int(x)-1,input().split()))
  v=0
  for i in range(n):
    for j in range(n):
      if i<j:
        id[i][j]=v
        v+=1
  for i in range(n):
    for j in range(n-1):
      a[i][j]=toId(i,a[i][j])
    for j in range(n-2):
      to[a[i][j+1]].append(a[i][j])
      
  ans=0
  for i in range(v):
    res=dfs(i)
    if res==-1:
      print(-1)
      exit(0)
    ans=max(ans, res)

  print(ans)
  
  
  
if __name__=='__main__':
  main()

### FIXED CODE ###

from collections import deque

def main():
  n=int(input())
  a=[0]*n
  for i in range(n):
    a[i]=deque(list(map(lambda x:int(x)-1,input().split())))
  q=deque([])
  tmp=set()
  for idx,i in enumerate(a):
    x=idx
    y=i[0]
    if x == a[y][0]:
      tmp.add(x)
      tmp.add(y)
  q=deque(tmp)
  for i in tmp:
    a[i].popleft()
  
  
  day=0
  while True:
    day+=1
    t=q.copy()
    q=deque()
    tmp=set()
    while t:
      x=t.popleft()
      if len(a[x])==0: continue;
      y=a[x][0]
      if x == a[y][0]:
        tmp.add(x)
        tmp.add(y)
    q=deque(tmp)
    for i in tmp:
      a[i].popleft()
    if len(q)==0: break;

  for i in range(n):
    if len(a[i])!=0:
      print(-1)
      exit()
  print(day)


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

N = int(input())
A = list(map(int, input().split()))
ans = 0
mod = 10**9+7
B = list(map(lambda x: x%mod, A))
for i in range(N-1):
    for j in range(N):
        if i < j:
            ans = ans%mod + (B[i]%mod)*(B[j]%mod)
print(ans%mod)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 0
hoge = 0
mod = 10**9+7
for i in range(N):
    hoge = hoge + A[i]
    hoge = hoge % mod

for i in range(N):
    hoge = hoge - A[i]
    if hoge < 0:
        hoge = hoge + mod
    ans = ans + A[i] * hoge
    ans = ans % mod

print(ans%mod)
### BUGGY CODE ###

s = input()
n = len(s)
ans = 0
for i in range(len(s) - 3):
  for j in range(i + 3, len(s) + 1):
    if int(s[i : i + 2]) % 2 == 1: break
    if int(s[i : j]) % 2019 == 0:
      ans += 1
print(ans)

### FIXED CODE ###

s = input()[::-1]
current = 0
a = [0] * 2019
a[0] = 1
digit = 1
for i in s:
  current += int(i) * digit
  digit *= 10
  digit %= 2019
  current %= 2019
  a[current] += 1
ans = 0
for i in a:
  ans += i * (i - 1) // 2
print(ans)
### BUGGY CODE ###

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

ans = 0
t = 0
S = [0]*30

def func(cur, S):
    cur_bi = list(format(cur, 'b'))
    cur_bi = list(reversed(cur_bi))
    flag = True
    for i in range(len(cur_bi)):
        if cur_bi[i] == '1' and S[i] == 1:
            flag = False
            break
    return flag

for s in range(n):
    while t < n and func(A[t], S):
        cur = A[t]
        cur_bi = list(format(cur, 'b'))
        cur_bi = list(reversed(cur_bi))
        for i in range(len(cur_bi)):
            if cur_bi[i] == '1':
                S[i] = 1
        t += 1
    ans += t-s
    if s == t:
        t += 1
    else:
        cur = A[s]
        cur_bi = list(format(cur, 'b'))
        cur_bi = list(reversed(cur_bi))
        for i in range(len(cur_bi)):
            if cur_bi[i] == '1':
                S[i] = 0

print(ans)

### FIXED CODE ###

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

ans = 0
t = 0
S = [0]*30

def func(cur, S):
    cur_bi = list(format(cur, 'b'))
    cur_bi = list(reversed(cur_bi))
    flag = True
    for i in range(len(cur_bi)):
        if cur_bi[i] == '1' and S[i] == 1:
            flag = False
            break
    return flag

for s in range(n):
    while t < n and func(A[t], S):
        cur = A[t]
        cur_bi = list(format(cur, 'b'))
        cur_bi = list(reversed(cur_bi))
        for i in range(len(cur_bi)):
            if cur_bi[i] == '1':
                S[i] = 1
        t += 1
    ans += t-s
    if s == t:
        t += 1
    else:
        cur = A[s]
        cur_bi = list(format(cur, 'b'))
        cur_bi = list(reversed(cur_bi))
        for i in range(len(cur_bi)):
            if cur_bi[i] == '1':
                S[i] = 0

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

class Node:
    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None

class BST:
    def __init__(self):
        self.root = None

    def insert(self,x):
        if self.root == None:
            self.root = Node(x)
        cur = self.root
        while True:
            if cur.value > x:
                if cur.left == None:
                    cur.left = Node(x)
                    break
                cur = cur.left
            elif cur.value < x:
                if cur.right == None:
                    cur.right = Node(x)
                    break
                cur = cur.right
            else:
                break

    def mprint(self):
        print '',
        print ' '.join(map(str, self.inorder(self.root)))
        print '',
        print ' '.join(map(str, self.preorder(self.root)))

    def inorder(self, cur):
        ret = []
        if cur.left != None:
            ret += self.inorder(cur.left)
        ret.append(cur.value)
        if cur.right != None:
            ret += self.inorder(cur.right)
        return ret

    def preorder(self, cur):
        ret = []
        ret.append(cur.value)
        if cur.left != None:
            ret += self.preorder(cur.left)
        if cur.right != None:
            ret += self.preorder(cur.right)
        return ret



m = int(raw_input())
tree = BST()
for _ in range(m):
    line = raw_input()
    if line[0] == 'i':
        num = int(line.split(' ')[1])
        tree.insert(num)
    elif line[0] == 'p':
        tree.mprint()
    else:
        raise Exception("Unknown command")

### FIXED CODE ###

def insert(tree,k):
    y = None
    x = tree
    z = {'key':k, 'parent':None, 'left':None, 'right':None}
    while x != None:
        y = x
        if x['key'] > k:
            x = x['left']
        else:
            x = x['right']
    z['parent'] = y
    if y == None:
        tree = z
    elif y['key'] > k:
        y['left'] = z
    else:
        y['right'] = z
    return tree

def middleorder(x):
    if x != None:
        middleorder(x['left'])
        print x['key'],
        middleorder(x['right'])

def preorder(x):
    if x != None:
        print x['key'],
        preorder(x['left'])
        preorder(x['right'])



tree = None
m = int(raw_input())
for i in range(m):
    c = raw_input().strip()
    if c[0] == 'i':
        tree = insert(tree, int(c[7:]))
    elif c[0] == 'p':
        print '',
        middleorder(tree)
        print
        print '',
        preorder(tree)
        print
### BUGGY CODE ###

N=int(input())
A=[int(x) for x in input().split()]
l=[0]
c=0

if 1 not in A:
    print(-1)
    exit()


for i in range(N-1):
    if A[i] in l or l[c]+1 != A[i]:
        continue

    for j in range(i+1,N):
        if A[i]>A[j]:
            if A[j] not in l:
                continue
        else:
            if A[i] in l:
                continue
            else:
                l.append(A[i])
                c+=1
if l[-1]+1 == A[-1]:
    l.append(A[-1])

print(N+1-len(l))


### FIXED CODE ###

N=int(input())
A=[int(x) for x in input().split()]
ne=1
c=0

if 1 not in A:
    print(-1)
    exit()


for i in range(N-1):
    if A[i]==ne:
        c+=1
        ne+=1
if A[-1]==ne:
    c+=1
print(N-c)
### BUGGY CODE ###

N, M = map(int,input().split())
L1 = [set() for k in range(3*(N+1))]
for k in range(M):
	u, v = map(int, input().split())
	L1[3*u].add(3*v+1)
	L1[3*u+1].add(3*v+2)
	L1[3*u+2].add(3*v)
S, T = map(int, input().split())
S = 3*S
T = set([3*T])

t = 0
sumi = set([S])
now = set([S])
flg = 0
while(len(now) != 0):
	t += 1
	pre = set()
	for n in now:
		pre = pre.union(L1[n])
	now = pre - sumi
	sumi = sumi.union(pre)
	if T <= pre:
		print(t//3)
		flg =1
		break
if flg == 0:
	print(-1)

### FIXED CODE ###

N, M = map(int,input().split())
L1 = [[] for k in range(3*(N+1))]
for k in range(M):
	u, v = map(int, input().split())
	L1[3*u].append(3*v+1)
	L1[3*u+1].append(3*v+2)
	L1[3*u+2].append(3*v)
S, T = map(int, input().split())
S = 3*S
T = 3*T

t = 0
sumi = [None for k in range(3*(N+1))]
sumi[T] = -1
now = [S]
flg = 0
while(len(now) != 0):
	t += 1
	pre = []
	for n in now:
		pre.extend(L1[n])
	now = []
	for p in pre:
		if sumi[p] == None:
			sumi[p] = t
			now.append(p)
		elif sumi[p] == -1:
			flg = 1
	if flg == 1:
		print(t//3)
		flg = 2
		break
if flg == 0:
	print(-1)
### BUGGY CODE ###

from fractions import gcd
N = int(input())

ll = [i for i in range(1,N+1)]   
ans = 0

def aaa(a):
    d = gcd(a[0],a[1])
    return gcd(d,a[2])

lll = []
for i in ll:
    for j in ll:
        for k in ll:
            lll.append((i ,j, k))

for ii in lll:
    ans += aaa(ii)
print(ans)

### FIXED CODE ###

K = int(input())
ans = 0
from math import gcd
for i in range(1,K+1):
    for k in range(1,K+1):
        for j in range(1,K+1):
            ans += gcd(gcd(i, k),j)
            
print(ans)
### BUGGY CODE ###

N, M= (int(i) for i in input().split())
A = [int(i) for i in input().split()]

B = [0] * M
C = [0] * M

for i in range(M):
    B_tmp, C_tmp = map(int, input().split())
    B[i] = B_tmp
    C[i] = C_tmp

for i in range(M):
  if min(A) <= C[i]:
    for j in range(B[i]):
      A_min_index = A.index(min(A))
      A[A_min_index] = C[i]

print(sum(A))


### FIXED CODE ###

N, M= (int(i) for i in input().split())
A = [int(i) for i in input().split()]
BC = [list(map(int, input().split())) for _ in range(M)]
count = 0

BC = sorted(BC, key=lambda x: x[1],reverse=True)
min_A = min(A)

for B,C in BC:
  if min_A >= C and count > N:
    break
  else:
    l = min(B, N-count)
    for i in range(l):
      count+=1
      A.append(C)

A.sort()

ans = sum(A[count:len(A)])

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

from itertools import combinations
from bisect import bisect_left, bisect_right

N = int(input()) #2*10**3
L_list = [int(e) for e in input().split()]
index_list = [i for i in range(N)]

L_list.sort(reverse=False)
#print(L_list)

ans = 0

for comb in combinations(index_list, 2): #(2*10*3)*(2*10*3 -1)/2 ≒ 2*10*6
    a = L_list[comb[0]]
    b = L_list[comb[1]]
    
    #a < b+c ∴a-b < c
    #b < c+a ∴b-a < c
    if a-b > 0:
        low_limit = a-b
    else:
        low_limit = b-a
    index_left = bisect_right(L_list, low_limit) #log(2*10**6)≒6.3

    #c < a+b
    index_right = bisect_left(L_list, a+b) #log(2*10**6)
    
    #print(a,b,low_limit,a+b)
    #print(L_list[index_left:index_right])
    
    OK_c = index_right - index_left
    
    if index_left <= comb[0] <= index_right:
        OK_c -= 1
    if index_left <= comb[1] <= index_right:
        OK_c -= 1
        
    #print(OK_c)
    ans += OK_c
    
print(ans//3)

### FIXED CODE ###

from itertools import combinations
from bisect import bisect_left, bisect_right

N = int(input()) #2*10**3
L_list = [int(e) for e in input().split()]
index_list = [i for i in range(N)]

L_list.sort(reverse=False)
#print(L_list)

ans = 0

for comb in combinations(index_list, 2): #(2*10*3)*(2*10*3 -1)/2 ≒ 2*10*6
    a = L_list[comb[0]]
    b = L_list[comb[1]]
    
    #a < b+c ∴a-b < c
    #b < c+a ∴b-a < c
    if a-b > 0:
        low_limit = a-b
    else:
        low_limit = b-a
    index_left = bisect_right(L_list, low_limit) #log(2*10**6)≒6.3

    #c < a+b
    index_right = bisect_left(L_list, a+b) #log(2*10**6)
    
    #print(a,b,low_limit,a+b)
    #print(L_list[index_left:index_right])
    
    OK_c = index_right - index_left
    
    if index_left <= comb[0] <= index_right:
        OK_c -= 1
    if index_left <= comb[1] <= index_right:
        OK_c -= 1
        
    #print(OK_c)
    ans += OK_c
    
print(ans//3)