#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int v[800],put;

int serch(int n, int i, int j){
    int poz = 0;
    for (int bit = put; bit > 0; bit /= 2) {
        if (poz + bit < n && v[poz + bit] <= v[i] + v[j]) {
            poz += bit;
        }
    }
    return poz;
}
int main()
{
    ifstream f("nrtri.in");
    ofstream g("nrtri.out");
    int n, i, j, u, cnt;
    f>>n;
    for(i=0; i<n; i++){
        f>>v[i];
    }
    sort(v, v+n);
    // precalc
    put = 1;
    while (put <= n) {
        put *= 2;
    }
    // la terminarea whileului put > n
    // vrem expres cea mai mare putere a lui 2 <= n
    put /= 2;
    cnt=0;
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            u=serch(n,i,j);
            if(u>j){
                cnt+=u-j;
            }
        }
    }
    g<<cnt<<'\n';



    f.close();
    g.close();
    return 0;
}