#!/usr/bin/env python3

#import
import math
#import numpy as np
N = int(input())
L = list(map(int, input().split()))

L.sort()

def is_ok(arg, cmin, cmax):
    return L[arg] > cmin and L[arg] < cmax

def meguru_bisect(ok, ng, cmin, cmax):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid, cmin, cmax):
            ok = mid
        else:
            ng = mid
    return ok

ans = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        a = L[i]
        b = L[j]
        cmin = b - a
        cmax = a + b
        t = meguru_bisect(j, N, cmin, cmax)
        ans += t - j

print(ans) import math math N = int(input()) N int(input()) int input() input 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.sort() L.sort L sort def is_ok(arg, cmin, cmax):
    return L[arg] > cmin and L[arg] < cmax is_ok return L[arg] > cmin and L[arg] < cmax L[arg] > cmin and L[arg] < cmax L[arg] > cmin L[arg] L arg cmin L[arg] < cmax L[arg] L arg cmax arg arg cmin cmin cmax cmax def meguru_bisect(ok, ng, cmin, cmax):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid, cmin, cmax):
            ok = mid
        else:
            ng = mid
    return ok meguru_bisect while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid, cmin, cmax):
            ok = mid
        else:
            ng = mid
     abs(ok - ng) > 1 abs(ok - ng) abs ok - ng ok ng 1 mid = (ok + ng) // 2 mid (ok + ng) // 2 ok + ng ok ng 2 if is_ok(mid, cmin, cmax):
            ok = mid
        else:
            ng = mid
     is_ok(mid, cmin, cmax) is_ok mid cmin cmax ok = mid ok mid ng = mid ng mid return ok ok ok ok ng ng cmin cmin cmax cmax ans = 0 ans 0 for i in range(N - 2):
    for j in range(i + 1, N - 1):
        a = L[i]
        b = L[j]
        cmin = b - a
        cmax = a + b
        t = meguru_bisect(j, N, cmin, cmax)
        ans += t - j i range(N - 2) range N - 2 N 2 for j in range(i + 1, N - 1):
        a = L[i]
        b = L[j]
        cmin = b - a
        cmax = a + b
        t = meguru_bisect(j, N, cmin, cmax)
        ans += t - j j range(i + 1, N - 1) range i + 1 i 1 N - 1 N 1 a = L[i] a L[i] L i b = L[j] b L[j] L j cmin = b - a cmin b - a b a cmax = a + b cmax a + b a b t = meguru_bisect(j, N, cmin, cmax) t meguru_bisect(j, N, cmin, cmax) meguru_bisect j N cmin cmax ans += t - j ans t - j t j print(ans) print ans L = list(map(int, input().split())) list(map(int, input().split())) L ans += t - j t - j ans t = meguru_bisect(j, N, cmin, cmax) meguru_bisect(j, N, cmin, cmax) t a = L[i] L[i] a cmin = b - a b - a cmin def is_ok(arg, cmin, cmax):
    return L[arg] > cmin and L[arg] < cmax def is_ok(arg, cmin, cmax):
    return L[arg] > cmin and L[arg] < cmax is_ok def meguru_bisect(ok, ng, cmin, cmax):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid, cmin, cmax):
            ok = mid
        else:
            ng = mid
    return ok def meguru_bisect(ok, ng, cmin, cmax):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid, cmin, cmax):
            ok = mid
        else:
            ng = mid
    return ok meguru_bisect N = int(input()) int(input()) N b = L[j] L[j] b ans = 0 0 ans cmax = a + b a + b cmax
#!/usr/bin/env python3

#import
import math
#import numpy as np
N = int(input())
L = list(map(int, input().split()))

L.sort()

def is_ok(arg, cmin, cmax):
    return L[arg] > cmin and L[arg] < cmax

def meguru_bisect(ok, ng, cmin, cmax):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid, cmin, cmax):
            ok = mid
        else:
            ng = mid
    return ok

ans = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        a = L[i]
        b = L[j]
        cmin = b - a
        cmax = a + b
        t = meguru_bisect(j, N, cmin, cmax)
        ans += t - j

print(ans)