#include <fstream>
#include <vector>
using namespace std;

ifstream fin("nrtri.in");
ofstream fout("nrtri.out");

int main()
{
    int n, x;
    vector<int> v;
    fin >> n;
    for(int i = 0; i < n; i++)
        {
            fin >> x;
            v.push_back(x);
        }
    // sortez vectorul
    bool schimb = true;
    while (schimb)
    {
        schimb = false;
        for(int i = 0; i < n-1; i++)
            if(v[i] > v[i+1])
            {
                swap(v[i], v[i+1]);
                schimb = true;
            }
    }
    
    fout << endl;
    int count = 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++)
                count++;
    fout << count;
    return 0;
}