#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin ("nrtri.in");
ofstream cout ("nrtri.out");
int v[801];
int main()
{
    int n, c = 0, i, i2, i3;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> v[i];
    sort(v, v + n);
    for (i = 0; i < n - 2; i++)
    {
        for (i2 = i + 1; i2 < n - 1; i2++)
        {
            for (i3 = i2 + 1; i3 < n; i3++)
            {
                if (v[i] + v[i2] < v[i3])
                    break;
                else c++;
            }
        }
    }
    cout << c;
    return 0;
}