#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;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgRmlsZV9UZXN0IGlmKGZvcGVuKCJ0ZXN0LmlucCIsInIiKSl7IGZyZW9wZW4oInRlc3QuaW5wIiwiciIsc3RkaW4pO2ZyZW9wZW4oInRlc3Qub3V0IiwidyIsc3Rkb3V0KTt9CiNkZWZpbmUgbGwgbG9uZyBsb25nCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBsbCBNQVggPSAxZTYgKzU7CgpsbCBuLHEscmVzLHgsYVtNQVhdLCBteFtNQVhdOwoKbGwgdGtucChsbCBkLCBsbCBjLCBsbCBpLCBsbCBqKQp7CiAgICBsbCByZXMgPSBkOwogICAgd2hpbGUoZCA8PSBjKQogICAgewogICAgICAgIGxsIGcgPSAoZCArIGMpIC8gMjsKICAgICAgICBpZihhW2ddIDwgYVtpXSArIGFbal0pICByZXMgPSBnLCBkID0gZyArIDE7CiAgICAgICAgZWxzZSBjID0gZyAtIDE7CiAgICB9CiAgICByZXR1cm4gcmVzOwp9CgppbnQgbWFpbigpCnsKICAgIEZpbGVfVGVzdDsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgICBjaW4udGllKDApOwogICAgY291dC50aWUoMCk7CiAgICBjaW4gPj4gbjsKICAgIGZvcihsbCBpID0gMTsgaSA8PSBuOyBpICsrKSBjaW4gPj4gYVtpXTsKICAgIHNvcnQoYSArIDEsIGEgKyAxICsgbik7CiAgICBmb3IobGwgaSA9IDE7IGkgPD0gbiAtIDE7IGkgKyspCiAgICAgICAgZm9yKGxsIGogPSBpICsgMTsgaiA8PSBuOyBqICsrKQogICAgICAgIHsKICAgICAgICAgICAgcmVzICs9ICh0a25wKGosIG4sIGksIGopIC0gaik7CiAgICAgICAgfQogICAgY291dCA8PCByZXM7Cn0=