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

def main():
    import numpy as np
    n = int(input())
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    d_alpha = {j: i for i, j in enumerate(alphabet)}
    s = input()
    s = np.array([d_alpha[i] for i in s], dtype=np.int8)
    m = 0
    for i in range(1, n):
        cnt_m = 0
        cnt = 0
        for j, k in zip(s[:n-i], s[i:]):
            if j == k:
                cnt = min(cnt+1, i)
            else:
                cnt_m = max(cnt, cnt_m)
                cnt = 0
        m = max(cnt, cnt_m, m)
    print(m)


main()

### FIXED CODE ###

def main():
    n=int(input())
    s=input()
    m=0
    for i in range(1,n):
        cnt_m=0
        cnt=0
        for j in range(i,n):
            if s[j-i]==s[j]:
                cnt=min(cnt+1,i)
            else:
                cnt_m=max(cnt,cnt_m)
                cnt=0
        m=max(cnt,cnt_m,m)
    print(m)

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

N = int(input())
li = input().split()
ans = []
if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0:
            ans.append(li[i])
        if i % 2 == 1:
            ans.insert(0,li[i])
else:
    for i in range(N):
        if i % 2 == 0:
            ans.insert(0,li[i])
        if i % 2 == 1:
            ans.append(li[i])
for i in range(N):
    print(ans[i],end=' ')

### FIXED CODE ###

from collections import deque

N = int(input())
li = input().split()
ans = deque()
if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0:
            ans.append(li[i])
        elif i % 2 == 1:
            ans.appendleft(li[i])
else:
    for i in range(N):
        if i % 2 == 0:
            ans.appendleft(li[i])
        elif i % 2 == 1:
            ans.append(li[i])
for i in range(N):
    print(ans[i],end=' ')
### BUGGY CODE ###

a,b=map(int,input().split())
def c(n):
  s=set([1])
  if n%2==0:
    s.add(2)
    while n%2==0:
      n//=2
  i=1
  while n>1:
    i+=2
    if n%i==0:
      s.add(i)
      while n%i==0:
        n//=i
  return s
s=c(a)
l=list(s)
for x in l:
  if b%x!=0:
    s.remove(x)
print(len(s))

### FIXED CODE ###

a,b=map(int,input().split())
def p(n):
    a = set([1])
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a
s=p(a)
l=list(s)
for x in l:
  if b%x!=0:
    s.remove(x)
print(len(s))
### BUGGY CODE ###

def calc(cum, p1, p2, p3):
    arr = [0]*4
    arr[0] = cum[p1]
    arr[1] = cum[p2] - cum[p1]
    arr[2] = cum[p3] - cum[p2]
    arr[3] = cum[-1] - cum[p3]
    return max(arr) - min(arr)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    for i in range(n-1):
        a[i+1] += a[i]
    ans = float("inf")
    for i in range(1, n-2):
        p2 = i
        v = a[i]
        L, R = 0, p2
        while L+1 < R:
            P = (L+R)//2
            if a[P] <= v//2:
                L = P
            else:
                R = P
        p1 = L
        L, R = -1, p2-1
        while L+1 < R:
            P = (L+R+1)//2
            if a[P] <= v//2:
                L = P
            else:
                R = P
        p1_ = R
        L, R = p2+1, n-1
        while L+1 < R:
            P = (L+R)//2
            if a[P]-v <= (a[-1]-v)//2:
                L = P
            else:
                R = P
        p3 = L
        L, R = p2, n-2
        while L+1 < R:
            P = (L+R+1)//2
            if a[P]-v <= (a[-1]-v)//2:
                L = P
            else:
                R = P
        p3_ = R
        arr = [0]*4
        arr[0] = calc(a, p1, p2, p3)
        arr[1] = calc(a, p1_, p2, p3)
        arr[2] = calc(a, p1, p2, p3_)
        arr[3] = calc(a, p1_, p2, p3_)
        x = min(arr)
        if x < ans:
            ans = x
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def calc(cum, p1, p2, p3):
    arr = [0]*4
    arr[0] = cum[p1]
    arr[1] = cum[p2] - cum[p1]
    arr[2] = cum[p3] - cum[p2]
    arr[3] = cum[-1] - cum[p3]
    return max(arr) - min(arr)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    for i in range(n-1):
        a[i+1] += a[i]
    ans = float("inf")
    for i in range(1, n-2):
        p2 = i
        v = a[i]
        L, R = 0, p2
        while L+1 < R:
            P = (L+R)//2
            if a[P] <= v//2:
                L = P
            else:
                R = P
        p1 = L
        L, R = -1, p2-1
        while L+1 < R:
            P = (L+R+1)//2
            if a[P] <= v//2:
                L = P
            else:
                R = P
        p1_ = R
        L, R = p2+1, n-1
        while L+1 < R:
            P = (L+R)//2
            if a[P]-v <= (a[-1]-v)//2:
                L = P
            else:
                R = P
        p3 = L
        L, R = p2, n-2
        while L+1 < R:
            P = (L+R+1)//2
            if a[P]-v <= (a[-1]-v)//2:
                L = P
            else:
                R = P
        p3_ = R
        arr = [0]*4
        arr[0] = calc(a, p1, p2, p3)
        arr[1] = calc(a, p1_, p2, p3)
        arr[2] = calc(a, p1, p2, p3_)
        arr[3] = calc(a, p1_, p2, p3_)
        x = min(arr)
        if x < ans:
            ans = x
    print(ans)

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

# input
h, w = [int(i) for i in input().split()]
ary = []
for y in range(h):
    ary.append([None if i == '.' else 0 for i in input()])


update_list = set((y, x) for y, line in enumerate(ary) for x, elem in enumerate(line) if elem == 0)

from copy import copy
def update(ary, update_list):
    for pos in copy(update_list):
        y, x = pos
        if x > 0:
            uy, ux = y, x-1
            if ary[uy][ux] is None:
                ary[uy][ux] = ary[y][x] + 1
                update_list.add((uy, ux))
        if x < w-1:
            uy, ux = y, x+1
            if ary[uy][ux] is None:
                ary[uy][ux] = ary[y][x] + 1
                update_list.add((uy, ux))
        if y > 0:
            uy, ux = y-1, x
            if ary[uy][ux] is None:
                ary[uy][ux] = ary[y][x] + 1
                update_list.add((uy, ux))
        if y < h-1:
            uy, ux = y+1, x
            if ary[uy][ux] is None:
                ary[uy][ux] = ary[y][x] + 1
                update_list.add((uy, ux))
        update_list.remove((y, x))
    return ary, update_list


black_count = len(update_list)
while black_count < w * h:
    ary, update_list = update(ary, update_list)
    black_count += len(update_list)


print(max(elem for line in ary for elem in line))


### FIXED CODE ###

# input
h, w = [int(i) for i in input().split()]
ary = []
for y in range(h):
    ary.append([None if i == '.' else 0 for i in input()])


from collections import deque

update_q = deque((y, x) for y, line in enumerate(ary) for x, elem in enumerate(line) if elem == 0)

def update(ary, update_q):
    for _ in range(len(update_q)):
        pos = update_q.popleft()
        y, x = pos
        if x > 0:
            uy, ux = y, x-1
            if ary[uy][ux] is None:
                ary[uy][ux] = ary[y][x] + 1
                update_q.append((uy, ux))
        if x < w-1:
            uy, ux = y, x+1
            if ary[uy][ux] is None:
                ary[uy][ux] = ary[y][x] + 1
                update_q.append((uy, ux))
        if y > 0:
            uy, ux = y-1, x
            if ary[uy][ux] is None:
                ary[uy][ux] = ary[y][x] + 1
                update_q.append((uy, ux))
        if y < h-1:
            uy, ux = y+1, x
            if ary[uy][ux] is None:
                ary[uy][ux] = ary[y][x] + 1
                update_q.append((uy, ux))
    return ary, update_q


black_count = len(update_q)
update_count = 0
while black_count < w * h:
    ary, update_q = update(ary, update_q)
    black_count += len(update_q)
    update_count += 1


print(update_count)
### BUGGY CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
for k in range(K):
    imos = [0] * (N+1)
    for i,a in enumerate(A):
        l = max(0, i-a)
        r = min(N, i+1+a)
        imos[l] += 1
        imos[r] -= 1
    imos[0] = min(N, imos[0])
    for i in range(N):
        imos[i+1] = min(N, imos[i] + imos[i+1])
    A = imos[:-1]
    if all(a==N for a in A):
        break
print(*A)

### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
for k in range(K):
    imos = [0] * (N+1)
    for i,a in enumerate(A):
        l = max(0, i-a)
        r = min(N, i+1+a)
        imos[l] += 1
        imos[r] -= 1
    imos[0] = min(N, imos[0])
    for i in range(N):
        imos[i+1] = min(N, imos[i] + imos[i+1])
    A = imos[:-1]
    if all(a==N for a in A):
        break
print(*A)
### BUGGY CODE ###

wb = input()
li = [i for i in wb]
j = [i for i in range(len(li))]
count = 0
while 'BW' in wb:
    for i in j:
        #print('i:',i)
        if i != j[-1]:
            if li[i] == 'B' and li[i+1] == 'W':
                #print('i:',li[i],'i+1:',li[i+1])
                li[i] = 'W'
                li[i+1] = 'B'
                count +=1
                wb = ''.join(li)
                #print('wb:',wb)
#print('li:',li)
print(count)

### FIXED CODE ###

wb = input()
li = [i for i in wb]
b = 0
count = 0
for i in li:
    if i =='B':
        b+=1
    else:
        count += b
print(count)
### BUGGY CODE ###

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

A = [a for i, a in enumerate(A) if a <= i+1]
A = [a for i, a in enumerate(A) if a <= i+1]
k = 0

while k < len(A):
    if A[k] != k+1:
        A.pop(k)
    else:
        k += 1

if len(A) == 0:
    print(-1)
else:
    print(N - len(A))

### FIXED CODE ###

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

A = [a for i, a in enumerate(A) if a <= i+1]

k = 0
for a in A:
    if a == k+1:
        k += 1
    

if k == 0:
    print(-1)
else:
    print(N - k)
### BUGGY CODE ###

N,M=map(int,input().split())
PY=[]
for i in range(M):
    PY.append(list(map(int,input().split()))+[i+1])
    PY.sort(key=lambda x:(x[0],x[1]))
id=[]
l=[]
while len(PY)>0:
    p=PY[0][0]
    i=0
    while PY[i][0]==p:
        i+=1
        id.append('0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(i)))+str(i))
        l.append(PY[i-1][2])
        if i+1>len(PY):
            break
    del PY[:i]
for i in range(1,M+1):
    print(id[l.index(i)])

### FIXED CODE ###

N,M = map(int,input().split())
PY=[list(map(int,input().split()))+[0] for _ in range(M)]
sort_PY=sorted(PY,key=lambda x:x[1])
c={}
for i in range(M):
    p=sort_PY[i][0]
    if(p in c):
        c[p]+=1
    else:
        c[p]=1
    sort_PY[i][2]=c[p]
for p,y,z in PY:
    print(str(p).zfill(6)+str(z).zfill(6))
### BUGGY CODE ###

def shakerSort(A):
	cnt=0
	left=0
	sh=0
	right=len(A)-1
	while left<right:
		for i in range(left,right):
			if A[i]>A[i+1]:
				A[i],A[i+1]=A[i+1],A[i]
				sh=i
				cnt+=1
		right=sh
		for j in range(right,left,-1):
			if A[j]<A[j-1]:
				A[j],A[j-1]=A[j-1],A[j]
				sh=j
				cnt+=1
		left=sh
	return cnt

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


### FIXED CODE ###

global cnt
cnt=0

def merge(A,left,mid,right):
    L=A[left:mid]
    R=A[mid:right]
    L.append(float("inf"))
    R.append(float("inf"))
    
    i=0
    j=0
    for k in range(left,right):
        global cnt
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1
            cnt+=mid-left-i

def mergeSort(A,left,right):
    if left+1<right:
        mid=(int)((left+right)/2)
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

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

mergeSort(S,0,n)
print(cnt)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
    if a==b:
      return a
    else:
      a,b=max(a,b),min(a,b)
      if a%b==0:
        return b
      else:
        return gcd(b,a%b)
def gcd_for_list(L):
    if len(L)==1:
      return L[0]
    for i in range(len(L)):
      if i==0:
        tmp=gcd(L[i],L[i+1])
      elif i==1:
        pass
      else:
        tmp=gcd(tmp,L[i])
    return tmp
ans=0
for i in range(0,n):
  if i==0:
    ans=max(ans,gcd_for_list(a[i+1:]))
  elif i==n-1:
    ans=max(ans,gcd_for_list(a[0:i]))
  else:
    l_r=a[0:i]
    l_l=a[i+1:]
    ans=max(ans,gcd(gcd_for_list(l_r),gcd_for_list(l_l)))
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
    if a==b:
      return a
    else:
      a,b=max(a,b),min(a,b)
      if a%b==0:
        return b
      else:
        return gcd(b,a%b)
R=[]
L=[]
for i in range(n):
  if i==0:
    L.append(a[i])
    R.append(a[-i-1])
  else:
    vl,vr=gcd(a[i],L[-1]),gcd(a[-i-1],R[-1])
    L.append(vl)
    R.append(vr)
ans=0
for i in range(n):
  if i==0:
    ans=max(ans,R[-i-2])
  elif i==n-1:
    ans=max(ans,L[i-1])
  else:
    ans=max(ans,gcd(L[i-1],R[-i-2]))
print(ans)
### BUGGY CODE ###

import fractions
import itertools

k = int(input())

gcd_map = [[-1 for i in range(1,k+1)]for j in range(1,k+1)]

ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            if gcd_map[a-1][b-1]==-1:
                gab = fractions.gcd(a,b)
                gcd_map[a-1][b-1] = gab
                gcd_map[b-1][a-1] = gab
            
            else:
                gab = gcd_map[a-1][b-1]
            
            if gcd_map[gab-1][c-1]==-1:
                gbc = fractions.gcd(gab,c)
                gcd_map[gab-1][c-1] = gbc
                gcd_map[c-1][gab-1] = gbc

            else:
                gbc = gcd_map[gab-1][c-1]

            ans+=gbc
print(ans)
            


### FIXED CODE ###

import math

k = int(input())
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        g = math.gcd(a,b)
        for c in range(1,k+1):
            ans += math.gcd(g,c)
print(ans)
### BUGGY CODE ###

def aaa():
    N, W = map(int, input().split())
    
    dp = [0] * (W+1) # DP枠_重さ’0’～'W'まで準備
    
    for i in range(N):
        w, v = map(int, input().split()) # 商品, 各々重さと価値
        tmp =tuple(dp[:]) # ひとつ前の商品までのDP枠を参照用にコピー
        for j in range(1, W+1): # 各商品のDP枠への落とし込み
            if j  >= w and tmp[j] < tmp[j-w] + v: # 商品の重さよりDP枠の重さが重い場合で...
                dp[j] = tmp[j-w] + v # この商品を加え, 合計価値が up する場合は replace
            else: # 商品の重さよりDP枠の重さが軽い場合と, ↑で価値が up しない場合は...
                dp[j] = tmp[j] # ↑ 参照データをそのままコピー
        
    print(dp[-1])

aaa()

### FIXED CODE ###

N, W = map(int, input().split())

w, v = [0] * N, [0] * N

for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
	for j in range(W + 1):
		if j - w[i] >= 0:
			dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
		else:
		    dp[i + 1][j] = dp[i][j] 

print(dp[N][W])
### BUGGY CODE ###

from functools import reduce

from operator import mul

N=int(input())

list=list(map(int,input().split()))
a=reduce(mul,list)

if 10**18>=a:
	print(a)
else:
  	print("-1")

### FIXED CODE ###

def main ():
	N = int(input())
	A = list(map(int,input(). split ()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)

main ()
### BUGGY CODE ###

import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
parent = [i for i in range(n)]

def unite(a, b):
    root_a = find_root(a)
    parent[a] = root_a
    root_b = find_root(b)
    parent[b] = root_b
    if root_a != root_b:
        parent[root_b] = root_a

def find_root(a):
    while parent[a] != a:
        a = parent[a]
    return a


for i in range(m):
    x, y, z = [int(i) for i in sys.stdin.readline().split()]
    x -= 1
    y -= 1
    unite(x, y)

_set = set()
for i in range(n):
    _set.add(find_root(i))
print(len(_set))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
n, m = [int(i) for i in sys.stdin.readline().split()]
parent = [i for i in range(n)]

def unite(a, b):
    root_a = find_root(a)
    parent[a] = root_a
    root_b = find_root(b)
    parent[b] = root_b
    if root_a != root_b:
        parent[root_b] = root_a

def find_root(a):
    ls = []
    while parent[a] != a:
        ls.append(a)
        a = parent[a]
    for l in ls:
        parent[l] = a
    return a


for i in range(m):
    x, y, z = [int(i) for i in sys.stdin.readline().split()]
    x -= 1
    y -= 1
    unite(x, y)

_set = set()
for i in range(n):
    _set.add(find_root(i))
print(len(_set))
### BUGGY CODE ###

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

import sys
import math
from decimal import Decimal, ROUND_DOWN
from collections import deque
from itertools import combinations
import copy

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]
    a = [int(e) for e in lines[1].split(' ')]


    return (n, a)


def solve(n, a):

   
    total = 0
    m = int(10**9 + 7)
    for i in range(n-1):
        for j in range(i+1, n):
            total = total + a[i] * a[j]
            total = total % m
            


    return total
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	


### FIXED CODE ###

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

import sys
import math
from decimal import Decimal, ROUND_DOWN
from collections import deque
from itertools import combinations
import copy

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]
    a = [int(e) for e in lines[1].split(' ')]


    return (n, a)


def solve(n, a):

   
    total = 0
    m = int(10**9 + 7)
    s = sum(a)
    s_current = 0
    for i in range(n):
        s_current = s_current + a[i]
        total = (total + a[i] * (s - s_current)) % m

    total = total % m


    return total
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
### BUGGY CODE ###

a,b,x = map(int, input().split())
s =[]
cnt=0
for i in range(a,b+1):
  s.append(i)
for j in s:
  if j %x==0:
    cnt +=1
print(cnt)

### FIXED CODE ###

a,b,x = map(int, input().split())
if a %x==0:
  print(b//x - a//x+1)
else:
  print(b//x - a//x)
### BUGGY CODE ###

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

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

before_sum = sum(a)

for i in range(n - 1):
    while a[i] + a[i + 1] > x:
        a[i + 1] -= 1

after_sum = sum(a)

print(before_sum - after_sum)


### FIXED CODE ###

n, x = map(int, input().split())
a = list(map(int, input().split()))

cnt, a[0] = sum(a), min(a[0], x)
for i in range(1, n):
    if a[i - 1] + a[i] > x:
        a[i] = x - a[i - 1]
print(cnt - sum(a))
### BUGGY CODE ###

from bisect import bisect

N,Q=map(int,input().split())
XST=[]
for i in range(N):
    S,T,X=map(int,input().split())
    XST.append([X,S,T])
XST.sort()
D=[[int(input()),i] for i in range(Q)]

ans=[-1]*Q
for X,S,T in XST:
    s,t=S-X,T-X
    left=bisect(D,[s])
    right=bisect(D,[t])
    
    for i in range(left,right):
        ans[D[i][1]]=X
    D=D[:left]+D[right:]
    
for u in ans:
    print(u)

### FIXED CODE ###

from bisect import bisect,bisect_left
import sys
input=sys.stdin.readline

def main():
    n,q=map(int,input().split())
    xst=[]
    for i in range(n):
        s,t,x=map(int,input().split())
        xst.append([x,s-x,t-x])
    xst.sort()
    d=[None]*q
    for i in range(q):
        d[i]=int(input())
    ans=[-1]*q
    skip=[-1]*q
    for u in xst:
        x ,left ,right = u
        a=bisect_left(d,left)
        b=bisect_left(d,right)
        while a < b:
            if skip[a] == -1:
                ans[a]=x
                skip[a]=b
                a+=1
            else:
                a=skip[a]
    for u in ans:
        print(u)

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

mod = 1000000007
eps = 10**-9
val = 0

def main():
    import sys
    input = sys.stdin.readline

    # ABC174-F

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

    Bsize = int(N ** 0.5) + 1
    query = []
    for q in range(Q):
        l, r = map(int, input().split())
        query.append((l - 1, r - 1, q))
    query.sort(key=lambda x: x[1])
    query.sort(key=lambda x: x[0] // Bsize)

    # [l, r)での求める値を管理するための変数たち
    # 問題によって変える
    cnt = [0] * (N + 1)

    # 区間の伸縮操作
    # 問題によって変える
    def add(i):
        global val
        cnt[A[i]] += 1
        if cnt[A[i]] == 1:
            val += 1

    def rem(i):
        global val
        cnt[A[i]] -= 1
        if cnt[A[i]] == 0:
            val -= 1

    # init
    l, r, _ = query[0]
    for i in range(l, r + 1):
        add(i)

    # process
    ans = [0] * Q
    for l_new, r_new, q in query:
        if r < r_new:
            for i in range(r + 1, r_new + 1):
                add(i)
        elif r > r_new:
            for i in range(r, r_new, -1):
                rem(i)
        if l < l_new:
            for i in range(l, l_new):
                rem(i)
        elif l > l_new:
            for i in range(l - 1, l_new - 1, -1):
                add(i)
        l = l_new
        r = r_new
        ans[q] = val

    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


### FIXED CODE ###

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    class Bit:
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x):
            while i <= self.size:
                self.tree[i] += x
                i += i & -i

        def lower_bound(self, w):
            if w <= 0:
                return 0
            x = 0
            k = 1 << (self.size.bit_length() - 1)
            while k:
                if x + k <= self.size and self.tree[x + k] < w:
                    w -= self.tree[x + k]
                    x += k
                k >>= 1
            return x + 1

    N, Q = map(int, input().split())
    C = list(map(int, input().split()))
    query = []
    for q in range(Q):
        query.append(list(map(int, input().split())))
        query[-1].append(q)
    query.sort(key=lambda x: x[1])

    last = [0] * (N+1)
    for i, c in enumerate(C):
        if i > query[0][1]-1:
            break
        last[c] = i+1

    bit = Bit(N)
    for i in range(1, N+1):
        if last[i]:
            bit.add(last[i], 1)
    r_prev = query[0][1]
    ans = [0] * Q
    for l, r, q in query:
        if r > r_prev:
            for i in range(r_prev+1, r+1):
                j = last[C[i-1]]
                if j:
                    bit.add(j, -1)
                last[C[i-1]] = i
                bit.add(i, 1)
            r_prev = r
        ans[q] = bit.sum(r) - bit.sum(l-1)

    for a in ans:
        print(a)


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

from itertools import combinations
n = int(input())
l = list(int(i) for i in input().split())

cnt = 0

for bars in combinations(l, 3):
    a,b,c = bars[0], bars[1], bars[2]
    if a < b + c and b < a + c and c < b + a:
        cnt+=1

print(cnt)




### FIXED CODE ###

import bisect


def main():
    n = int(input())
    l = sorted(list(int(i) for i in input().split()))

    cnt = 0

    for i in range(n - 2):
        a = l[i]
        for j in range(i + 1, n-1):
            b = l[j]
            cnt += bisect.bisect_left(l, a+b)-(j+1)

    print(cnt)


if __name__ == "__main__":
    main()