#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int cnt[300001] = {-1}, aux;
vector<int> v;
ifstream f("nrtri.in");
ofstream g("nrtri.out");

int sum = 0;

int cautbin(int l, int r, int nr)
{
    int last = -1;
    while (l <= r)
    {
        int mid = l + (r - l) / 2;
        if (v[mid] == nr)
        {
            last = mid;
            l = mid + 1;
        }
        else if (nr < v[mid])
        {
            r = mid - 1;
        }
        else
        {
            l = mid + 1;
            last = mid;
        }
    }
    return last;
}
int main()
{
    int nr;
    f >> nr;
    int x = 0;
    for (int i = 0; i < nr; i++)
    {
        f >> aux;
        cnt[aux]++;

        v.push_back(aux);
    }

    sort(v.begin(), v.end());

    for (int i = 0; i < nr - 2; i++)
    {
        for (int j = i + 1; j < nr - 1; j++)
        {
            // cout << "coord:" << i << ' ' << j << "\n";
            int head = v[i] + v[j];
            int c = cautbin(j, nr - 1, head);
            if (c - j > 0)
            {
                sum += c - j;
            }
            //if (cnt[v[j]] > 0)
            //    j += cnt[v[j]] - 1;
            //  cout << "coord:" << i << ' ' << j << "\n\n";
        }
        // if (cnt[v[i]] > 0)
        //     i += cnt[v[i]] - 1;
    }
    g << sum;
}