#include <fstream>
#include <algorithm>
using namespace std;

ifstream cin ("nrtri.in");

ofstream cout ("nrtri.out");

const int L =9;
int v[801];

int main()

{
    int n;
    long long nr=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    int k;
    for(int i=1;i<=n;i++){
        k=i+1;
        int j;
        for(j=i+1;j<n;j++){
            while(k<=n&&v[k]<=v[i]+v[j]){
                k++;
            }

        if(k>j){
            nr=nr+k-j-1;
        }
        }
    }
    cout<<nr;
    return 0;

}