# Binary Indexed Tree (Fenwick Tree)
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)


N = int(input())
L = list(map(int, input().split()))
L.sort()
bit = BIT(L[-1]*2+1)
bit.add(L[0]+L[1], 1)
total = 1
ans = 0
for k in range(2, N):
  ans += total - bit.sum(L[k])
  for j in range(k):
    bit.add(L[j]+L[k], 1)
    total += 1

print(ans)   class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i) BIT def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
     __init__ self.n = n self.n self n n self.data = [0]*(n+1) self.data self data [0]*(n+1) [0] 0 n+1 n 1 self.el = [0]*(n+1) self.el self el [0]*(n+1) [0] 0 n+1 n 1 self self n n def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
     sum s = 0 s 0 while i > 0:
            s += self.data[i]
            i -= i & -i
         i > 0 i 0 s += self.data[i] s self.data[i] self.data self data i i -= i & -i i i & -i i -i i return s s self self i i def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
     add self.el[i] += x self.el[i] self.el self el i x while i <= self.n:
            self.data[i] += x
            i += i & -i
     i <= self.n i self.n self n self.data[i] += x self.data[i] self.data self data i x i += i & -i i i & -i i -i i self self i i x x def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i) get if j is None:
            return self.el[i]
         j is None j None return self.el[i] self.el[i] self.el self el i return self.sum(j) - self.sum(i) self.sum(j) - self.sum(i) self.sum(j) self.sum self sum j self.sum(i) self.sum self sum i self self i i j=None j None N = int(input()) N int(input()) int input() input L = list(map(int, input().split())) L list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split L.sort() L.sort L sort bit = BIT(L[-1]*2+1) bit BIT(L[-1]*2+1) BIT L[-1]*2+1 L[-1]*2 L[-1] L -1 2 1 bit.add(L[0]+L[1], 1) bit.add bit add L[0]+L[1] L[0] L 0 L[1] L 1 1 total = 1 total 1 ans = 0 ans 0 for k in range(2, N):
  ans += total - bit.sum(L[k])
  for j in range(k):
    bit.add(L[j]+L[k], 1)
    total += 1 k range(2, N) range 2 N ans += total - bit.sum(L[k]) ans total - bit.sum(L[k]) total bit.sum(L[k]) bit.sum bit sum L[k] L k for j in range(k):
    bit.add(L[j]+L[k], 1)
    total += 1 j range(k) range k bit.add(L[j]+L[k], 1) bit.add bit add L[j]+L[k] L[j] L j L[k] L k 1 total += 1 total 1 print(ans) print ans class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i) class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i) BIT ans = 0 0 ans total += 1 1 total bit = BIT(L[-1]*2+1) BIT(L[-1]*2+1) bit total = 1 1 total L = list(map(int, input().split())) list(map(int, input().split())) L N = int(input()) int(input()) N ans += total - bit.sum(L[k]) total - bit.sum(L[k]) ans
# Binary Indexed Tree (Fenwick Tree)
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)


N = int(input())
L = list(map(int, input().split()))
L.sort()
bit = BIT(L[-1]*2+1)
bit.add(L[0]+L[1], 1)
total = 1
ans = 0
for k in range(2, N):
  ans += total - bit.sum(L[k])
  for j in range(k):
    bit.add(L[j]+L[k], 1)
    total += 1

print(ans)  
