#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,d = 0;
struct T
{
    ll a,b,c;
}q[5000];
ll a[5000];
void r(ll &x)
{
    x=0;
    char a;
    a=getchar();
    for (;a>='0'&&a<='9';a=getchar())
    {
        x = x*10 + a - '0';
    }
}
void w(ll x)
{
    if (x>9) w(x/10);
    putchar(x%10+48);
}
ll Bsearch(ll key,ll l,ll r)
{
    while (l<=r)
    {
        ll mid = (l+r)/2;
        if (q[mid+1].a>=key&&key>q[mid].a)
        {
            return mid;
        }
        else if (q[mid].a>=key)
        {
            r = mid - 1;
        }
        else if (q[mid].a<key)
        {
            l = mid + 1;
        }
    }
    return -1;
}
int main()
{
    freopen("BAI2_18.inp","r",stdin);
    freopen("BAI2_18.out","w",stdout);
    r(n);
    for (ll i = 0; i<n;i++)
    {
        r(a[i]);
    }
    sort(a,a+n);
    q[0].a=a[0];
    q[0].b++;
    ll t=0;
    for (ll i = 1;i < n ; i++)
    {
        if (a[i]==a[i-1])
        {
            q[t].b++;
        }
        else
        {
            t++;
            q[t].a=a[i];
            q[t].b++;
        }
    }
    t++;
    q[t].a=10000000000;q[t].b++;
    n=t+1;
    q[0].c=q[0].b;
    for (ll i=1;i<n;i++)
    {
        q[i].c= q[i].b + q[i-1].c;
    }
    d=0;
    for (ll i=0;i<n-1;i++)
    {
        for (ll j=i+1;j<n;j++)
        {
            ll ahihi = Bsearch(q[i].a+q[j].a,j+1,n);
            if (ahihi!=-1)
            {
                d = d + q[ahihi].c - q[j].c;
            }
        }
    }
    cout<<d;
    //w(d);
}
