#include <bits/stdc++.h>
#define File_Test if(fopen("test.inp","r")){ freopen("test.inp","r",stdin);freopen("test.out","w",stdout);}
#define ll long long
using namespace std;

const ll MAX = 1e6 +5;

ll n,q,res,x,a[MAX], mx[MAX];

ll tknp(ll d, ll c, ll i, ll j)
{
    ll res = d;
    while(d <= c)
    {
        ll g = (d + c) / 2;
        if(a[g] < a[i] + a[j])  res = g, d = g + 1;
        else c = g - 1;
    }
    return res;
}

int main()
{
    File_Test;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(ll i = 1; i <= n; i ++) cin >> a[i];
    sort(a + 1, a + 1 + n);
    for(ll i = 1; i <= n - 1; i ++)
        for(ll j = i + 1; j <= n; j ++)
        {
            res += (tknp(j, n, i, j) - j);
        }
    cout << res;
}