#D - Triangles

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

L_sorted = sorted(L, reverse = False)#昇順

def judge(A,B,x):#cが三角形になるか判定する関数
    if A + B <= L_sorted[x]:#a + b = cの時はfinを持ってくる
        return 'high'
    else :
        return 'low'

count = 0
for i in range(N):#aの選び方
    for j in range(i+1,N):#bの選び方
        a = L_sorted[i]
        b = L_sorted[j]#b <= c < a+b
        sta = 0
        fin = N#Lの個数+1
        while fin > sta + 1:#cの選び方
            m = ((fin - sta) // 2) + sta
            if judge(a,b,m) == 'high':
                fin = m
            elif judge(a,b,m) == 'low':
                sta = m
        count += sta  - j    
print(count) N = input() N input() input N = int(N) N int(N) int N L = list(map(int,input().split())) L list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split L_sorted = sorted(L, reverse = False) L_sorted sorted(L, reverse = False) sorted L reverse = False reverse False def judge(A,B,x):#cが三角形になるか判定する関数
    if A + B <= L_sorted[x]:#a + b = cの時はfinを持ってくる
        return 'high'
    else :
        return 'low' judge if A + B <= L_sorted[x]:#a + b = cの時はfinを持ってくる
        return 'high'
    else :
        return 'low' A + B <= L_sorted[x] A + B A B L_sorted[x] L_sorted x return 'high' 'high' return 'low' 'low' A A B B x x count = 0 count 0 for i in range(N):#aの選び方
    for j in range(i+1,N):#bの選び方
        a = L_sorted[i]
        b = L_sorted[j]#b <= c < a+b
        sta = 0
        fin = N#Lの個数+1
        while fin > sta + 1:#cの選び方
            m = ((fin - sta) // 2) + sta
            if judge(a,b,m) == 'high':
                fin = m
            elif judge(a,b,m) == 'low':
                sta = m
        count += sta  - j     i range(N) range N for j in range(i+1,N):#bの選び方
        a = L_sorted[i]
        b = L_sorted[j]#b <= c < a+b
        sta = 0
        fin = N#Lの個数+1
        while fin > sta + 1:#cの選び方
            m = ((fin - sta) // 2) + sta
            if judge(a,b,m) == 'high':
                fin = m
            elif judge(a,b,m) == 'low':
                sta = m
        count += sta  - j     j range(i+1,N) range i+1 i 1 N a = L_sorted[i] a L_sorted[i] L_sorted i b = L_sorted[j] b L_sorted[j] L_sorted j sta = 0 sta 0 fin = N fin N while fin > sta + 1:#cの選び方
            m = ((fin - sta) // 2) + sta
            if judge(a,b,m) == 'high':
                fin = m
            elif judge(a,b,m) == 'low':
                sta = m
         fin > sta + 1 fin sta + 1 sta 1 m = ((fin - sta) // 2) + sta m ((fin - sta) // 2) + sta (fin - sta) // 2 fin - sta fin sta 2 sta if judge(a,b,m) == 'high':
                fin = m
            elif judge(a,b,m) == 'low':
                sta = m
         judge(a,b,m) == 'high' judge(a,b,m) judge a b m 'high' fin = m fin m elif judge(a,b,m) == 'low':
                sta = m
         judge(a,b,m) == 'low' judge(a,b,m) judge a b m 'low' sta = m sta m count += sta  - j count sta  - j sta j print(count) print count b = L_sorted[j] L_sorted[j] b a = L_sorted[i] L_sorted[i] a fin = N N fin sta = 0 0 sta N = int(N) int(N) N L_sorted = sorted(L, reverse = False) sorted(L, reverse = False) L_sorted def judge(A,B,x):#cが三角形になるか判定する関数
    if A + B <= L_sorted[x]:#a + b = cの時はfinを持ってくる
        return 'high'
    else :
        return 'low' def judge(A,B,x):#cが三角形になるか判定する関数
    if A + B <= L_sorted[x]:#a + b = cの時はfinを持ってくる
        return 'high'
    else :
        return 'low' judge sta = m m sta count += sta  - j sta  - j count fin = m m fin L = list(map(int,input().split())) list(map(int,input().split())) L m = ((fin - sta) // 2) + sta ((fin - sta) // 2) + sta m N = input() input() N count = 0 0 count
#D - Triangles

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

L_sorted = sorted(L, reverse = False)#昇順

def judge(A,B,x):#cが三角形になるか判定する関数
    if A + B <= L_sorted[x]:#a + b = cの時はfinを持ってくる
        return 'high'
    else :
        return 'low'

count = 0
for i in range(N):#aの選び方
    for j in range(i+1,N):#bの選び方
        a = L_sorted[i]
        b = L_sorted[j]#b <= c < a+b
        sta = 0
        fin = N#Lの個数+1
        while fin > sta + 1:#cの選び方
            m = ((fin - sta) // 2) + sta
            if judge(a,b,m) == 'high':
                fin = m
            elif judge(a,b,m) == 'low':
                sta = m
        count += sta  - j    
print(count)