#include <bits/stdc++.h>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int n, k, i, j, ans, a[805];
int main() {
    fin >> n;
    for (int i=1;i<=n;i++){
        fin >> a[i];
    }
    sort(a+1,a+n+1);
    for (i=1;i<=n-2;i++){
        k = i+2;
        for (j=i+1;j<=n-1;j++){
            while(k<=n && a[k] <= a[i] + a[j])
                ++k;
            if (k>j)
                ans += k - j-1;
        }
    }

    fout << ans << '\n';
    return 0;
}