#include<bits/stdc++.h>
using namespace std;
const int nmax = 805;
int n, x,y;
int v[nmax];
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
void citire()
{
    fin >> n;
    for(int i = 1; i <= n; i ++)
        fin >> v[i];
}
int cautBinar(int st, int dr, int x)
{
    int mij;
    int poz = 0;

    while(st <= dr)
    {
    mij = (st + dr ) / 2;
      if(v[mij] <= x){
         poz = mij;
         st = mij + 1;
      }
      else{
        dr = mij - 1;
      }
    }
return poz;
}


void rezolva()
{
    int k;
    int sol = 0;
    sort(v + 1, v + 1 + n);
    for(int i = 1; i <= n; i ++){
        for(int j = i + 1; j <= n; j ++)
        {
          k = cautBinar(j + 1, n,v[i] + v[j]);
            if(k != 0)
            {
                sol = sol + k - j;
            }
        }
    }
    fout << sol;
}


int main()
{
    citire();
    rezolva();

    return 0;
}