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