#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin ("nrtri.in");
ofstream cout ("nrtri.out");
int n, v[8005], ans;
int caut_bin(int st, int dr, int val)
{
    int mj;
    while(st <= dr)
    {
        mj = (st + dr) / 2;
        if(val < v[mj])
            dr = mj - 1;
        else
            st = mj + 1;
    }
    return dr;
}
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; ++i)
        for(int j = i + 1; j <= n; ++j)
        {
            ans += caut_bin(j + 1, n, v[i] + v[j]) - j;
        }
    cout << ans;
    return 0;
}