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

def is_ok(n, su):
    return l[n] > su

def binary_search(left, right, su):
    while (abs(right - left) > 1):
        mid = (left + right) // 2
        if is_ok(mid, su):  right = mid
        else:  left = mid
    return right

l = sorted(l)
ans = 0
for i in range(2, N):
    for j in range(1, i):
        left = j
        right = -1
        ret = binary_search(right, left, l[i] - l[j])
        if ret != right:  ans += j - ret
print(ans) 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 def is_ok(n, su):
    return l[n] > su is_ok return l[n] > su l[n] > su l[n] l n su n n su su def binary_search(left, right, su):
    while (abs(right - left) > 1):
        mid = (left + right) // 2
        if is_ok(mid, su):  right = mid
        else:  left = mid
    return right binary_search while (abs(right - left) > 1):
        mid = (left + right) // 2
        if is_ok(mid, su):  right = mid
        else:  left = mid
     abs(right - left) > 1 abs(right - left) abs right - left right left 1 mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 if is_ok(mid, su):  right = mid
        else:  left = mid
     is_ok(mid, su) is_ok mid su return right right left left right right su su l = sorted(l) l sorted(l) sorted l ans = 0 ans 0 for i in range(2, N):
    for j in range(1, i):
        left = j
        right = -1
        ret = binary_search(right, left, l[i] - l[j])
        if ret != right:  ans += j - ret i range(2, N) range 2 N for j in range(1, i):
        left = j
        right = -1
        ret = binary_search(right, left, l[i] - l[j])
        if ret != right:  ans += j - ret j range(1, i) range 1 i left = j left j right = -1 right -1 ret = binary_search(right, left, l[i] - l[j]) ret binary_search(right, left, l[i] - l[j]) binary_search right left l[i] - l[j] l[i] l i l[j] l j if ret != right:  ans += ret != right ret right print(ans) print ans ret = binary_search(right, left, l[i] - l[j]) binary_search(right, left, l[i] - l[j]) ret l = list(map(int,input().split())) list(map(int,input().split())) l left = j j left right = -1 -1 right l = sorted(l) sorted(l) l ans = 0 0 ans def is_ok(n, su):
    return l[n] > su def is_ok(n, su):
    return l[n] > su is_ok N = int(input()) int(input()) N def binary_search(left, right, su):
    while (abs(right - left) > 1):
        mid = (left + right) // 2
        if is_ok(mid, su):  right = mid
        else:  left = mid
    return right def binary_search(left, right, su):
    while (abs(right - left) > 1):
        mid = (left + right) // 2
        if is_ok(mid, su):  right = mid
        else:  left = mid
    return right binary_search
N = int(input())
l = list(map(int,input().split()))

def is_ok(n, su):
    return l[n] > su

def binary_search(left, right, su):
    while (abs(right - left) > 1):
        mid = (left + right) // 2
        if is_ok(mid, su):  right = mid
        else:  left = mid
    return right

l = sorted(l)
ans = 0
for i in range(2, N):
    for j in range(1, i):
        left = j
        right = -1
        ret = binary_search(right, left, l[i] - l[j])
        if ret != right:  ans += j - ret
print(ans)