#include <bits/stdc++.h>
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
int n,a[900],s=0;
int main()
{
    in >> n;
    for(int i=1; i<=n; i++)
        in >> a[i];
    sort(a+1,a+n+1);
    for(int i=1; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            int sum = a[i] + a[j];
            int x = 0, b = 1024;
            while(b>0){
                if(b+x <= n && a[b+x]<=sum)
                    x+=b;
                b/=2;
            }
            s+=x-j;
        }
    }
    out << s;
    return 0;
}