#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
#define DIM 1810
int v[DIM];
int main()
{
    ifstream fin("nrtri.in");
    ofstream fout("nrtri.out");
    int n,c=0;
    fin>>n;
    for(int i=1;i<=n;i++){
        fin>>v[i];
    }
    sort(v,v+n+1);
    for(int i=1;i<=n-2;i++){
        for(int j=i+1;j<=n-1;j++){
            for(int k=j+1;k<=n;k++){
                if(v[i]+v[j]>=v[k]){
                    c++;
                }
                else{
                    k=n+1;
                }
            }
        }
    }
    fout<<c;
    return 0;
}