import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;
 
void main()
{
    int n;
    readf("%s", &n);
    readln;

    auto arr = readln.chomp.split.map!(to!int).array;

    arr.sort();
    
    struct fwtr {
        immutable int MX = 10 ^^ 3 + 23;
        int[MX] f;
        
        void add(int v) {
            while (v < MX) { 
                f[v] += 1;
                v += (v & (-v));
            }
        }
        
        int sm(int v) {
            int ret = 0;
            while (v > 0) {
                ret += f[v];
                v -= (v & (-v));
            }
            
            return ret;
        }
    }
    
    fwtr t;
    
    auto ans = 0L;
    foreach (i; 0 .. n) {
        foreach  (j; i+1 .. n) {
            int search = arr[j] - arr[i];
            
            ans += i - t.sm(search);
        }
        
        t.add(arr[i]);
    }
    
    ans.writeln;
}