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