// triangles.cpp : This file contains the 'main' function. Program execution begins and ends there.
//how many triangles can we form with the sticks of lengths L (a triangle satisfies :  a < b + c , b < c + a , c = a+b
//by farah on 28/2/2020

#include <iostream>
#include <deque>
#include <vector>
using namespace std;

#define ll long long

const int N = 2e3;
int L[N] , ans = 0 , n ;
int i = 0 , j = 0;
//bool used[N];
vector<int> v;

bool valid() {
	//cout << v[0] << v[1] << v[2] <<endl;
	return ((v[0] < v[1] + v[2]) && (v[1] < v[0] + v[2]) && (v[2] < v[1] + v[0]));
}

void solve() {
	for (int i = 0; i < n; i++) {
		v.push_back(L[i]);
		int temp = i + 1;
		int j = temp;
		while (true) {
			v.push_back(L[j++]);
			if (v.size() == 3) {
				if (valid())
					ans++;
				v.pop_back();
			}
			if (j >= n && !((temp + 2) >= n)) {
				temp++;
				j = temp ;
				v.pop_back();
			}
			else if (j >= n && (temp + 2) >= n) { v.clear(); break; }
		}

	}
}

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> L[i];
	}

	solve();
	cout << ans;
}
