#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    int N, length[801], rezult = 0, aux, ok;
    freopen("nrtri.in", "rt", stdin);
    freopen("nrtri.out", "wt", stdout);
    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> length[i];
    if(N == 1 || N == 2)
        cout << 0;
    else{
        do{
            ok = 0;
            for(int i = 0; i < N - 1; i++)
                if(length[i] < length[i+1]){
                    aux = length[i];
                    length[i] = length[i+1];
                    length[i+1] = aux;
                    ok = 1;
                }
        }while(ok == 1);
        for(int i = 0; i < N - 2; i++)
            for(int j = i + 1; j < N - 1; j++)
                for(int l = j + 1; l < N && (length[i] <= length[j] + length[l]); l++)
                    rezult++;
        cout << rezult;
    }
    return 0;
}