#include <fstream>
#include <algorithm>
#define nmax 801
using namespace std;
ifstream cin("nrtri.in");
ofstream cout("nrtri.out");
int main(){
    int n, v[nmax], cnt = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> v[i];
    }
    sort(v + 1, v + n + 1);
    for(int i = 1; i <= n - 2; ++i){
        for(int j = i + 1; j <= n - 1; ++j){
            int st = j + 1, dr = n, mij, gasit = 0;
            while(st <= dr && gasit == 0){
                mij = (st + dr) / 2;
                if(v[mij] <= v[i] + v[j]){
                    st = mij + 1;
                }
                else{
                    dr = mij - 1;
                }
            }
            cnt += dr - j;
        }
    }
    cout << cnt << " ";
    return 0;
}