#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int n, i, j, t, st, dr, mij, a[805];
int main()
{
    f >> n;
    for(i = 0; i < n; i++)
        f >> a[i];
    f.close();
    sort(a + 0, a + n);
    t = 0;
    for(i = 0; i < n - 2; i++)
        for(j = i + 1; j < n - 1; j++)
        {
            st = j + 1;
            dr = n - 1;
            while(st <= dr)
            {
                mij = (st + dr) / 2;
                if(a[mij] <= a[i] + a[j] && (mij == n - 1 || a[mij + 1] > a[i] + a[j]))
                    break;
                else
                    if(a[mij] <= a[i] + a[j])
                        st = mij + 1;
                    else
                        dr = mij - 1;
            }
            if(st <= dr)
                t += mij - j;
        }
    g << t << '\n';
    g.close();
    return 0;
}