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