#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    FILE * fin = fopen("nrtri.in", "r");
    FILE * fout = fopen("nrtri.out", "w");
    int v[801], n=0;
    fscanf(fin, "%d", &n);
    for (int i=0; i<n; i++)
        fscanf(fin, "%d", &v[i]);
    sort(v, v+n);
    int tri=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 && (v[i]+v[j]>=v[k]); k++){
                tri++;
            }
        }
    }
    fprintf(fout, "%d", tri);
    fclose(fin);
    fclose(fout);
}