#include <iostream>
#include <fstream>
#include <algorithm>

int main() {

    std :: ifstream fin ("nrtri.in");
    std :: ofstream fout ("nrtri.out");

    int n, v[805];
    fin >> n;
    for (int i = 0; i < n; ++i) {
        fin >> v[i];
    }

    std :: sort (v, v+n);

    int triunghi = 0;
    for (int i = 0; i < n-2; ++i) {
        for (int j = i+1; j < n-1; ++j) {
            for (int k = j+1; k < n and v[i]+v[j] >= v[k]; ++k) {
                triunghi++;
            }
        }
    }
    fout << triunghi;

    return 0;
}