#include<fstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;
int n;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int main()
{
    vector<int> a;
    f >> n;
    for (int i = 1; i <= n; i++)
    {
        int x;
        f>> x;
        a.push_back(x);
    }
    sort(begin(a), end(a));
    int total = 0;
    for (vector<int>::iterator i = begin(a); i != end(a) - 2; i++)
        for (vector<int>::iterator j = i + 1; j != end(a) - 1; j++)
        {
            vector<int>::iterator it = upper_bound(j + 1, end(a), *i + *j);
            if ((*(it - 1) <= *i + *j) && j != it - 1)
            {
                total += it - j - 1;
               // << *i << " " << *j << " " << *(it - 1) << " ---- " << total << endl;
            }
        }
    g << total;
    return 0;
}