#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin("nrtri.in");
ofstream cout("nrtri.out");
int n, a[1005], sol;
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n - 2; i++)
        for(int j = i + 1; j <= n - 1; j++)
            for(int r = j + 1; r <= n and (a[i] + a[j] >= a[r]) and (a[i] + a[r] >= a[j]) and (a[j] + a[r] >= a[i]); r++)
                    sol++;
    cout << sol;
    return 0;
}