#include <iostream>
#include <fstream>
#include <queue>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
const int N = 801;
int v[N];
int main()
{
    int n, i, j, e, rasp;
    fin >> n;
    for(i = 0; i < n; i++)
        fin >> v[i];
    sort(v, v + n);
    rasp = 0;
    for(i = 0; i < n - 2; i++){
        queue <int> Q;
        for(j = i + 1; j < n; j++){
            while(!Q.empty() && v[i] + Q.front() < v[j])
                Q.pop();
            rasp += Q.size();
            Q.push(v[j]);
        }
    }
    fout << rasp;
    return 0;
}