// Arup Guha
// 3/22/2015
// Solution to December 2013 USACO Bronze Problem: Cow Baseball

import java.util.*;
import java.io.*;

public class baseball {

	final public static long MAX = 3000L;

	public static void main(String[] args) throws Exception {

		// Sort cow positions.
		Scanner stdin = new Scanner(new File("baseball.in"));
		int n = stdin.nextInt();
		int[] vals = new int[n];
		for (int i=0; i<n; i++)
			vals[i] = stdin.nextInt();
		Arrays.sort(vals);

		// Try all pairs of X and Y...
		int result = 0;
		for (int i=0; i<n; i++)
			for (int j=i+1; j<n; j++)
				result += search(vals, i, j);
		stdin.close();

		// Write out the result.
		BufferedWriter fout = new BufferedWriter(new FileWriter("baseball.out"));
		fout.write(result+"\n");
		fout.close();
	}

	public static int search(int[] values, int x, int y) {
		int min = 2*values[y] - values[x];
		int max = 3*values[y] - 2*values[x];
		return binSearch(values, max) - binSearch(values, min-1);
	}

	// Returns the number of items in the array <= item.
	public static int binSearch(int[] values, int item) {

		int low = 0, high = values.length-1;

		// Finding the highest index less than or equal to item.
		while (low < high-1) {
			int mid = (low+high)/2;
			if (values[mid] <= item)
				low = mid;
			else
				high = mid;
		}

        // Walk through the last steps.
		while (high >= 0 && values[high] > item) high--;
		return high+1;
	}
}
