#include <algorithm>
#include <cstdio>
int main() {
  freopen("nrtri.in", "r", stdin);
  freopen("nrtri.out", "w", stdout);
  int n;
  scanf("%d", &n);
  int len[2 + n];
  for (int i = 1; i <= n; i++)
    scanf("%d", &len[i]);
  std::sort(len + 1, len + n + 1);
  int sol = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      for (int k = j + 1; k <= n && len[i] + len[j] >= len[k]; k++)
        sol++;
  printf("%d", sol);
  return 0;
}