#include <bits/stdc++.h>
using namespace std;


int main()
{
    ifstream in("nrtri.in");
    ofstream out("nrtri.out");

    int n;
    in >> n;

    vector <int> v(n);
    for (auto & i : v)
        in >> i;

    sort(v.begin(), v.end());

    int ans = 0;

    for (int i = 0; i < (int)v.size(); i++) {
        for (int j = 0; j < i; j++) {
            for (int k = j - 1; k >= 0; k--) {
                if (v[j] + v[k] >= v[i])
                    ans++;
                else
                    break;    
            }
        }
    }
    out << ans << '\n';

    return 0;
}