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