#include <algorithm>
#include <fstream>
#include <cstdint>
int a[800];
int main() {
  std::ifstream is{"nrtri.in"};
  int n;
  is >> n;
  for (auto i = 0; i < n; ++i)
    is >> a[i];
  std::sort(a, a + n);
  std::int64_t s{};
  for (auto i = 0; i < n - 2; ++i)
    for (auto j = i + 1; j < n - 1; ++j)
      for (auto k = j + 1; k < n; ++k)
        if (a[i] + a[j] >= a[k])
          ++s;
        else
          break;
  std::ofstream{"nrtri.out"} << s;
}