// By Stefan Radu
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
ifstream cin("nrtri.in");
ofstream cout("nrtri.out");
#define sz(x) (int)(x).size()
typedef pair < int, int > pii;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;
vector < int > aib(70001);
void update(int val, int index) {
  while (index < sz(aib)) {
    aib[index] += val;
    index += index & (-index);
  }
}
int query(int index) {
  if (index < 0) return 0;
  int ret = 0;
  while (index) {
    ret += aib[index];
    index -= index & (-index);
  }
  return ret;
}
int main() {
#ifdef STEF
  freopen("input", "r", stdin);
  freopen("output", "w", stdout);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  int n; cin >> n;
  vector < int > lengths(n);
  for (int i = 0; i < n; ++ i) {
    cin >> lengths[i];
    update(1, lengths[i]);
  }
  int cnt = 0;
  for (int i = 0; i < n; ++ i) {
    update(-1, lengths[i]);
    for (int j = i + 1; j < n; ++ j) {
      update(-1, lengths[j]);
      cnt += query(lengths[i] + lengths[j]) - query(abs(lengths[i] - lengths[j]) - 1);
      update(1, lengths[j]);
    }
    update(1, lengths[i]);
  }
  cout << cnt / 3 << '\n';
}