#include <iostream>
#include <algorithm>
using namespace std;
FILE * fin, * fout;
int v[800];
int main(){
    fin = fopen("nrtri.in","r");
    fout = fopen("nrtri.out","w");
    int N;
    fscanf(fin,"%d",&N);
    for ( int i = 0; i < N; i++ ){
        fscanf(fin,"%d",v+i);
    }
    std::sort(v, v+N);
    int cases = 0;
    for( int i = 0; 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])
                    cases++;
                else
                    break;
            }
        }
    }
    //cout << cases;
    fprintf(fout,"%d",cases);
    fclose(fin);
    fclose(fout);
    return 0;
}