#include <bits/stdc++.h>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int n,nr;
int a[801];
void Citire()
{
    f>>n;
    for(int i=1;i<=n;++i)
        f>>a[i];
    f.close();
}
void Solve()
{
    sort(a+1,a+1+n);
    for(int i=1;i<=n-2;++i)
        for(int j=i+1;j<=n-1;++j)
            for(int k=j+1;k<=n;++k)
                if(a[i] + a[j] >= a[k]) ++nr;
                else break; //daca nu e mai mare decat a[k], nu e nici mai mare decat a[k+1], vectorul fiind sortat
}
void Afisare()
{
    g<<nr;
    g.close();
}
int main()
{
    Citire();
    Solve();
    Afisare();
    return 0;
}