#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int n, v[3001], s, i, j, st, dr, sol, mid;
int main() {
    fin >> n;
    for (i=1; i<=n; i++)
        fin >> v[i];
    sort(v + 1, v + n + 1);
    for (i=1; i<=n-2; i++){
        for (j=i+1; j<=n-1; j++){
            s = v[i] + v[j];
            st = j + 1;
            dr = n;
            while (st <= dr){
                mid = (st + dr)/2;
                if (s >= v[mid])
                    st = mid + 1;
                else
                    dr = mid - 1;
            }
            sol = sol + dr - j;
        }
    }
    fout << sol;
    return 0;
}