#include <bits/stdc++.h>
using namespace std;
int a[1000], n, ans, l3;
int cautbin(int x){
    int st = 0, dr = n-1;
    int mid;
    while(st <= dr){
        mid = (st+dr)/2;
        if(a[mid] <= x)
            st = mid+1;
        else dr = mid - 1;
    }
    return dr;
}
int main(){
    ifstream cin("nrtri.in");
    ofstream cout("nrtri.out");
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a, a+n);
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            l3 = cautbin(a[i]+a[j]);
            ans += l3 - j;
        }
    }
    cout<<ans;
    return 0;
}