#include <bits/stdc++.h>
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
int N,sol;
int v[802];
void Read(){
    in >> N;
    for(int i = 1; i <= N; ++i)
        in >> v[i];
    sort(v+1,v+N+1);
}
bool triunghi(int a, int b, int c){
    return (a+b >= c) && (a+c >= b) && (b+c >= a);
}
int main(){
    Read();
    for(int i = 1; i <= N-2; i++)
        for(int j = i + 1; j <= N-1; j++)
            for(int k = j + 1; k <= N && triunghi(v[i],v[j],v[k]); k++)sol++;
    out << sol;
    out.close();
    return 0;
}