#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 5005
ll a[maxn];
ll n, i, j, k, tmp, res, tong;
int main()
{
cin >> n;
for (i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
for (i = 0; i < n - 2; i++)
{
for (j = i+1; j < n - 1; j++)
{
tmp = lower_bound(a + j + 1, a + n, a[i] + a[j]) - a;
res = res + (tmp - j-1);
}
}
cout << res;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgbWF4biA1MDA1CmxsIGFbbWF4bl07CmxsIG4sIGksIGosIGssIHRtcCwgcmVzLCB0b25nOwppbnQgbWFpbigpCnsKICAgIAogICAgICAgIGNpbiA+PiBuOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBuOyBpKyspCiAgICAgICAgICAgICAgICBjaW4gPj4gYVtpXTsKICAgICAgICBzb3J0KGEsIGEgKyBuKTsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbiAtIDI7IGkrKykKICAgICAgICB7CiAgICAgICAgICAgICAgICBmb3IgKGogPSBpKzE7IGogPCBuIC0gMTsgaisrKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICB0bXAgPSBsb3dlcl9ib3VuZChhICsgaiArIDEsIGEgKyBuLCBhW2ldICsgYVtqXSkgLSBhOwogICAgICAgICAgICAgICAgICAgICAgICByZXMgPSByZXMgKyAodG1wIC0gai0xKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgY291dCA8PCByZXM7Cn0K