using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            //ここから

            var N = IO.ReadLineToInt();
            var L = IO.ReadLineToIntArray();

            L = L.OrderBy(l => l).ToArray();

            var sum = 0;

            for(int i = 0; i < N - 2; i++)
            {
                for(int j = i + 1; j < N - 1; j++)
                {
                    if (L[i] + L[j] <= L[j + 1]) { continue; }

                    var min = j + 1;
                    var max = N - 1;

                    int med;
                    int k = min;

                    while (true)
                    {
                        med = (min + max) / 2;
                        if (L[i] + L[j] > L[med])
                        {
                            if (med >= N - 1 || L[med + 1] >= L[i] + L[j])
                            {
                                k = med;
                                break;
                            }
                            else
                            {
                                min = med + 1;
                            }
                        }
                        else
                        {
                            max = med;
                        }
                    }

                    sum += k-j;
                    
                }
            }

            //ここまで
            Console.WriteLine(sum);
            Console.ReadKey();
        }
    }

    static class Func
    {
        static long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringArray() { return Console.ReadLine().Split(' ').ToList(); }
        static public int[] ReadLineToIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
}

Measured memory_bytes: 13396