using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Runtime.CompilerServices;
using ll=System.Int64;

public class Contest
{
	static void Swap1<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
	static void Swap2<T>(ref T a, ref T b) where T : IComparable { if (a.CompareTo(b)==1) Swap1(ref a, ref b); }  // b の方が小さければ交換
	static bool Chmin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)== 1) { a = b; return true; } return false; }  // b の方が小さければ a を更新
	static bool Chmax<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)==-1) { a = b; return true; } return false; }  // b の方が大きければ a を更新
	static T[][] InitMat<T>(int len1, int len2, T val){ T[][] m = new T[len1][]; for (int i = 0; i < m.Length; i++) m[i] = Enumerable.Repeat(val, len2).ToArray(); return m; }
	static T[][][] InitMat<T>(int len1, int len2, int len3, T val){ T[][][] m = new T[len1][][]; for (int i = 0; i < m.Length; i++) m[i] = InitMat(len2,len3,val); return m; }
	public const long MOD1 = 1000000007; // 10^9+7

	public static void Main() {
		Solve_D();
 	}

	public static void Solve_A() {
		long  n, m;
		MyIO.ReadMulti(out n, out m);



		long ans = 0;

		MyIO.WriteMulti(ans);

	}
	public static void Solve_B() {
		long  n, m;
		MyIO.ReadMulti(out n, out m);



		long ans = 0;

		MyIO.WriteMulti(ans);


	}
	public static void Solve_C() {
		long  n, m;
		MyIO.ReadMulti(out n, out m);



		long ans = 0;

		MyIO.WriteMulti(ans);


	}
	public static void Solve_D() {
		int  n;
		MyIO.ReadMulti(out n);
		int[] l;
		MyIO.ReadArray(out l);

		Array.Sort(l);
		long cnt=0;
		Comparer<int> nor = Comparer<int>.Create((x,y)=>x-y);
		Comparer<int> rev = Comparer<int>.Create((x,y)=>y-x);
		for (int i = 0; i < n-2; i++)
		{
			for (int j = i+1; j < n-1; j++)
			{
				int lb = UpperBound(l,j+1,n,l[j]-l[i],nor);
				int ub = LowerBound(l,j+1,n,l[j]+l[i],nor);
				cnt+=ub-lb;
			}
		}


		MyIO.WriteMulti(cnt);


	}
	public static void Solve_E() {
		int  n, m, l,q;
		MyIO.ReadMulti(out n, out m, out l);
		VT<int,int,int>[] abcl;
		MyIO.ReadLines(m, out abcl);
		MyIO.ReadMulti(out q);
		VT<ll,ll>[] stl;
		MyIO.ReadLines(q, out stl);

		List<VT<int,int,int>> abcl2 = new List<VT<int,int,int>>();
		for (int i = 0; i < m; i++)
		{
			if(abcl[i].Item3<=l) abcl2.Add(new VT<int,int,int>(abcl[i].Item1-1,abcl[i].Item2-1,abcl[i].Item3));
		}
		VT<int,int,int>[] abcl3 = abcl2.ToArray();

		int[][] N;
		ll[][] G = WarshallFloyd(abcl3, n, out N);

		ll[] ans = new ll[q];
		for (int i = 0; i < q; i++)
		{
			if(G[stl[i].Item1-1][stl[i].Item2-1]==long.MaxValue){
				ans[i] = -1;
				continue;
			}
			ll cnt = 0;
			ll res = l;
			for (ll cur = stl[i].Item1-1; cur != stl[i].Item2-1; ){
				var nxt = N[cur][stl[i].Item2-1];
				var v = G[cur][nxt];
				if(res<v) {
					cnt++;
					res=l;
				}
				res-=v;
				cur = nxt;
			}
			ans[i] = cnt;			
		}

		MyIO.WriteLines(ans);


	}
	public static void Solve_F() {
		long  n, m;
		MyIO.ReadMulti(out n, out m);



		long ans = 0;

		MyIO.WriteMulti(ans);


	}


    public static int LowerBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer) {
        int mid;
        while (start < end) {
            mid = ((end - start) >> 1) + start;
            if (comparer.Compare(arr[mid], value) < 0)
            start = mid + 1;
            else
            end = mid;
        }
        return start;
    }
    //引数省略のオーバーロード
    public static int LowerBound<T>(T[] arr, T value) where T : IComparable => LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default);
    public static int UpperBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer) {
        int mid;
        while (start < end) {
            mid = ((end - start) >> 1) + start;
            if (comparer.Compare(arr[mid], value) <= 0)
            start = mid + 1;
            else
            end = mid;
        }
        return start;
    }
    //引数省略のオーバーロード
    public static int UpperBound<T>(T[] arr, T value) where T : IComparable => UpperBound(arr, 0, arr.Length, value, Comparer<T>.Default);

	
	public static long[][] WarshallFloyd(VT<int,int,int>[] inEdges, int V, out int[][] N) {
//		long[,] G = new long[V,V]; 
//		Buffer.BlockCopy(Enumerable.Repeat(long.MaxValue, G.Length).ToArray(), 0, G, 0, G.Length * sizeof(long));
		long[][] G = new long[V][]; 
		for(int i=0;i<V;i++) G[i] = Enumerable.Repeat(long.MaxValue, V).ToArray();
		
		for(int k = 0; k < V; k++) G[k][k] = 0;
		foreach(var e in inEdges){
			G[e.Item1][e.Item2] = e.Item3;
			G[e.Item2][e.Item1] = e.Item3;
		}
		
		N = new int[V][];	//経路復元用
		for (int i = 0; i < V; i++) N[i] = Enumerable.Range(0, V).ToArray();

		for(int k = 0; k < V; k++) {
			for(int i = 0; i < V; i++) {
				for(int j = 0; j < V; j++) {
					if(G[i][k] == long.MaxValue || G[k][j] == long.MaxValue) continue;
					if (G[i][k] + G[k][j] < G[i][j]) {
						G[i][j] = G[i][k] + G[k][j];
						N[i][j] = N[i][k];
					}  
				}
			}
		}
		

		return G;
	}











}


















#region MyIO

public struct VT<T, U>
{
	public T Item1; public U Item2;
    public VT(T a, U b) { Item1 = a; Item2 = b; }
}
public struct VT<T, U, V>
{
	public T Item1; public U Item2; public V Item3;
    public VT(T a, U b, V c) { Item1 = a; Item2 = b; Item3 = c; }
}
public struct VT<T, U, V, W>
{
	public T Item1; public U Item2; public V Item3; public W Item4;
    public VT(T a, U b, V c, W d) { Item1 = a; Item2 = b; Item3 = c; Item4 = d; }
}

public class Printer : System.IO.StreamWriter
{
	public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
	public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
	public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
}
public static class MyIO
{
	private static char[] splitter = new char[] {' '};
	private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
	private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
	private static T cv<T>(string s) =>
		eq<T, int>()    ? ct<T, int>(int.Parse(s))
	  : eq<T, long>()   ? ct<T, long>(long.Parse(s))
	  : eq<T, double>() ? ct<T, double>(double.Parse(s, System.Globalization.CultureInfo.InvariantCulture))
	  : eq<T, char>()   ? ct<T, char>(s[0])
						: ct<T, string>(s);
			
	public static string[] ReadMulti<T>(out T a) {
		var ar = Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries); 
		a = cv<T>(ar[0]);
		return ar;
	}
	public static string[] ReadMulti<T, U>(out T a, out U b) {
		var ar = ReadMulti<T>(out a); 
        b = cv<U>(ar[1]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
		var ar = ReadMulti<T, U>(out a, out b); 
        c = cv<V>(ar[2]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c, out W d) {
		var ar = ReadMulti<T, U, V>(out a, out b, out c); 
        d = cv<W>(ar[3]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
		var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d); 
        e = cv<X>(ar[4]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) {
		var ar = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e); 
        f = cv<Y>(ar[5]);
		return ar;
	}
	public static string[] ReadArray<T>(out T[] a) {		
		var ar = Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries);
		a = ar.Select(cv<T>).ToArray();
		return ar;
	}		
	public static string[][] ReadLines<T>(long n, out T[] a) {
		a = new T[n];
		string[][] arr = new string[n][];
		for(int i=0; i<n; i++) arr[i] = ReadMulti(out a[i]);
		return arr;
	}
	public static string[][] ReadLines<T, U>(long n, out VT<T, U>[] a) {
		a = new VT<T, U>[n];
		string[][] arr = new string[n][];
		for(int i=0; i<n; i++) {
			T o; U p;
			arr[i] = ReadMulti(out o, out p);
			a[i] = new VT<T, U>(o, p);
		}
		return arr;
	}
	public static string[][] ReadLines<T, U, V>(long n, out VT<T, U, V>[] a) {
		a = new VT<T, U, V>[n];
		string[][] arr = new string[n][];
		for(int i=0; i<n; i++) {
			T o; U p; V q;
			arr[i] = ReadMulti(out o, out p, out q);
			a[i] = new VT<T, U, V>(o, p, q);
		}
		return arr;
	}
	public static string[][] ReadLines<T, U, V, W>(long n, out VT<T, U, V, W>[] a) {
		a = new VT<T, U, V, W>[n];
		string[][] arr = new string[n][];
		for(int i=0; i<n; i++) {
			T o; U p; V q; W r;
			arr[i] = ReadMulti(out o, out p, out q, out r);
			a[i] = new VT<T, U, V, W>(o, p, q, r);
		}
		return arr;
	}
	public static string[][] ReadMatrix<T>(long n, out T[][] a) {
		a = new T[n][];
		string[][] arr = new string[n][];
		for(int i=0; i<n; i++) arr[i] = ReadArray(out a[i]);
		return arr;
	}

	private static void wwp(Action act){
		var sw = new Printer(Console.OpenStandardOutput()){AutoFlush = false};
		Console.SetOut(sw);
		act();
		Console.Out.Flush();
		sw.AutoFlush = true;
		Console.SetOut(sw);
	}
	private static string wfm(Type t) =>t.Equals(typeof(double)) ? "{0:F10}" : "{0}";
	public static void WriteMulti(params object[] a) {
		wwp(()=>{
			for(int i=0;i<a.Length;i++) {
				string fs = wfm(a[i].GetType()) + ((i<a.Length-1) ? " " : Environment.NewLine);
				Console.Write(fs, a[i]);
			}
		});
	}
	public static void WriteArray<T>(T[] a) {
		wwp(()=>{
			string fs = wfm(typeof(T));
			string fs1 = fs + " ";
			string fs2 = fs + Environment.NewLine;
			for(int i=0;i<a.Length;i++) Console.Write( ((i<a.Length-1) ? fs1 : fs2), a[i]);
		});
	}
	public static void WriteLines<T>(T[] a) {
		wwp(()=>{
			string fs = wfm(typeof(T)) + Environment.NewLine;
			foreach(T x in a) Console.Write(fs, x);
		});
	}


}

#endregion



Measured memory_bytes: 13548