#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int v[2000],put;

int main(){
    ifstream f("nrtri.in");
    ofstream g("nrtri.out");

    int n, i, j, k, cnt;
    f>>n;
    for(i=0; i<n; i++)
    {
        f>>v[i];
    }
    sort(v, v+n);
    cnt = 0;

    for (k = n - 1; k >= 2; k--) {
        i = 0;
        j = k - 1;
        while (i < j) {
            if (v[i] + v[j] >= v[k]) {
                cnt += j - i;
                j--;
            }
            else {
                i++;
            }
        }
    }
    g << cnt << '\n';
    f.close();
    g.close();
    return 0;
}