#include <iostream>
#include <algorithm>
#include <fstream>
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
int main() {
    int n, v[900], i, j, k, nr = 0;
    in>>n;
    for( i = 1; i <= n; i++)
        in>>v[i];
    sort(v+1, v+1+n);
    for( j = 1; j <= n - 2; j++){
        for( k = j + 1 ; k <= n - 1; k++){
            for(i = k + 1 ; i <= n; i++){
                if(v[j] + v[k] >= v[i]){
                    nr++;
                }
                else
                    break;
            }
        }
    }
    out<<nr;
    return 0;
}