#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int nmax=805;
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define rc(x)  return cout<<x<<"\n",0
#define sz(s)  (int) s.size()
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define PI 3.14159265358979
using namespace std;
ll t,a[nmax],nr,n;
int cb(int x, int y) {
	ll l=x,r=n;
	ll mid,ans;
	while (l<=r) {
      	mid=(l+r)/2;
		if (a[x]+a[y]<a[mid]) {
			r=mid-1;
		}
		else  {
			l=mid+1;
			ans=mid;
		}	
	}
	return ans;
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ifstream cin("nrtri.in");
	ofstream cout("nrtri.out");
	cin >> n;
	for (int i=1; i<=n; i++) {
		cin >> a[i];
	}
	sort(a+1,a+n+1);
	for (int i=1; i<n-1; i++) {
		for (int j=i+1; j<n; j++) {
			ll u=cb(i,j);
			if (u>j) {
				nr+=u-j;
			}
		}
	}
	cout << nr << '\n';
}