#include <fstream>
#include <algorithm>

using namespace std;

ifstream cin ("nrtri.in");
ofstream cout ("nrtri.out");

const int LMAX = 805;
int v[LMAX], n, ans;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> v[i];

    sort(v + 1, v + n + 1);
    for (int i = 1; i <= n - 2; ++i)
    {
        int k = i + 1;
        for (int j = k; j <= n; ++j)
        {
            while (k <= n && v[k] <= v[i] + v[j])
                k++;
            if (k > j)
                ans += k - j - 1;
        }
    }
    cout << ans;
    return 0;
}