#include <iostream>
#include <algorithm>
#include <fstream>
#define MAX 800
using namespace std;
int main(){
 ifstream in("nrtri.in");
 ofstream out("nrtri.out");
 int nr, i, j, k, arr[MAX];
 in >> nr;
 for (i = 0; i != nr; i++){
    in >>arr[i];
 }
 sort(arr, arr + nr);
 int sum = 0;
 for (i = 0 ;i < nr; i++){
    for (j = i + 1 ;j < nr; j++){
        for (k = j + 1 ;k < nr; k++){
          if(arr[i] + arr[j] >= arr[k] && arr[i] + arr[k] >= arr[j] && arr[k] + arr[j] >= arr[i] ) {
                sum++;
          }
          else break;
        }
    }
 }
 out <<sum << endl;
}