### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def bin_search(arr,ls,c):
    l=ls-1
    r = len(arr)
    while (r-l) > 1:
        m = l + (r-l)//2
        if arr[m] >= c:
            r = m
        else:
            l = m
    return l-ls+1

def resolve():
    readline=sys.stdin.readline

    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    arr.sort()
    ans=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            c = arr[i] + arr[j]
            ans += bin_search(arr,j+1,c)
    print(ans)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ---------------- import sys sys from io import StringIO import unittest unittest def yn(b):
    print("Yes" if b==1 else "No")
    return yn print("Yes" if b==1 else "No") print "Yes" if b==1 else "No" b==1 b 1 "Yes" "No" return b b def bin_search(arr,ls,c):
    l=ls-1
    r = len(arr)
    while (r-l) > 1:
        m = l + (r-l)//2
        if arr[m] >= c:
            r = m
        else:
            l = m
    return l-ls+1 bin_search l=ls-1 l ls-1 ls 1 r = len(arr) r len(arr) len arr while (r-l) > 1:
        m = l + (r-l)//2
        if arr[m] >= c:
            r = m
        else:
            l = m
     (r-l) > 1 r-l r l 1 m = l + (r-l)//2 m l + (r-l)//2 l (r-l)//2 r-l r l 2 if arr[m] >= c:
            r = m
        else:
            l = m
     arr[m] >= c arr[m] arr m c r = m r m l = m l m return l-ls+1 l-ls+1 l-ls l ls 1 arr arr ls ls c c def resolve():
    readline=sys.stdin.readline

    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    arr.sort()
    ans=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            c = arr[i] + arr[j]
            ans += bin_search(arr,j+1,c)
    print(ans)
    return resolve readline=sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline n=int(readline()) n int(readline()) int readline() readline arr=list(map(int, readline().rstrip().split())) arr list(map(int, readline().rstrip().split())) list map(int, readline().rstrip().split()) map int readline().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () readline rstrip split arr.sort() arr.sort arr sort ans=0 ans 0 for i in range(n-2):
        for j in range(i+1,n-1):
            c = arr[i] + arr[j]
            ans += bin_search(arr,j+1,c)
     i range(n-2) range n-2 n 2 for j in range(i+1,n-1):
            c = arr[i] + arr[j]
            ans += bin_search(arr,j+1,c)
     j range(i+1,n-1) range i+1 i 1 n-1 n 1 c = arr[i] + arr[j] c arr[i] + arr[j] arr[i] arr i arr[j] arr j ans += bin_search(arr,j+1,c) ans bin_search(arr,j+1,c) bin_search arr j+1 j 1 c print(ans) print ans return if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ---------------- 'doTest' not in globals() 'doTest' globals() globals resolve() resolve sys.exit() sys.exit sys exit def bin_search(arr,ls,c):
    l=ls-1
    r = len(arr)
    while (r-l) > 1:
        m = l + (r-l)//2
        if arr[m] >= c:
            r = m
        else:
            l = m
    return l-ls+1 def bin_search(arr,ls,c):
    l=ls-1
    r = len(arr)
    while (r-l) > 1:
        m = l + (r-l)//2
        if arr[m] >= c:
            r = m
        else:
            l = m
    return l-ls+1 bin_search def yn(b):
    print("Yes" if b==1 else "No")
    return def yn(b):
    print("Yes" if b==1 else "No")
    return yn def resolve():
    readline=sys.stdin.readline

    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    arr.sort()
    ans=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            c = arr[i] + arr[j]
            ans += bin_search(arr,j+1,c)
    print(ans)
    return def resolve():
    readline=sys.stdin.readline

    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    arr.sort()
    ans=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            c = arr[i] + arr[j]
            ans += bin_search(arr,j+1,c)
    print(ans)
    return resolve
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def bin_search(arr,ls,c):
    l=ls-1
    r = len(arr)
    while (r-l) > 1:
        m = l + (r-l)//2
        if arr[m] >= c:
            r = m
        else:
            l = m
    return l-ls+1

def resolve():
    readline=sys.stdin.readline

    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    arr.sort()
    ans=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            c = arr[i] + arr[j]
            ans += bin_search(arr,j+1,c)
    print(ans)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------
