#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int main()
{
    int n;
    fin >> n;
    vector<int> v(n);
    int cnt = 0;
    for(auto &it:v)
        fin >> it;
    sort(v.begin(), v.end());
    for(int i = 0; i <= n - 3; ++i)
        for(int j = i + 1; j <= n - 2; ++j)
            for(int k = j + 1; k < n; ++k)
                if(v[i] + v[j] >= v[k])
                    cnt++;
                else
                    break;
    fout << cnt;
    return 0;
}