#include <fstream>
#include <algorithm>
using namespace std;
ifstream in ("nrtri.in");
ofstream out ("nrtri.out");
int main()
{
    int n,nr=0,mid,s;
    in>>n;
    int v[9002]={0};
    for (int i=1;i<=n;i++)
        in>>v[i];
    sort(v+1,v+n+1);
    for (int i=1;i<=n-2;i++)
        for (int k=i+1;k<=n-1;k++)
        {
            s=v[i]+v[k];
            if (v[k+1]<=s)
            {
                int left=k+1;
                int right=n;
                while (left<=right)
                {
                  mid =(right+left)/2;
                  if (v[mid]<=s && left<n)
                        left=mid+1;
                  if (v[mid]>s)
                        right=mid-1;
                  if (right==n and left==n)
                    right--;
                }
                 nr+=left-k;
                 if (v[left]>s)
                    nr--;
            }
        }
    out<<nr;
    return 0;
}