#include <bits/stdc++.h>
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
#define Maxn 1000000 + 10
using namespace std;
int N;
int len[Maxn];
int result = 0;
int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> len[i];
    sort(len,len+N);
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            int a=len[i];
            int b=len[j];
            int k=lower_bound(len,len+N,a+b)-len;
            result+=k-j-1;
        }
    }
    cout<<result<<endl;
}
