#include <bits/stdc++.h>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int v[801], i, j, k, n, cnt;
int main()
{
    f >> n;
    for(i = 1; i <= n; ++ i)
        f >> v[i];
    sort(v + 1, v + n + 1);
    for(i = 1; i <= n - 2; ++ i)
        for(j = i + 1; j <= n - 1; ++ j)
            for(k = j + 1; k <= n; ++ k)
                if(v[k] <= v[i] + v[j]) cnt ++;
                else break;
    g << cnt;
    return 0;
}