import math

import collections

import fractions

import itertools

import functools

import operator

import bisect



def solve():

    n = int(eval(input()))

    l = list(map(int, input().split()))

    l.sort()

    res = 0

    for i in range(n):

        for j in range(i+1, n):

            k = bisect.bisect_left(l, l[i]+l[j])

            res += max(k-(j+1), 0)

    print(res)

    return 0



if __name__ == "__main__":

    solve()
import math

import collections

import fractions

import itertools

import functools

import operator

import bisect



def solve():

    n = int(eval(input()))

    l = list(map(int, input().split()))

    l.sort()

    res = 0

    for i in range(n):

        k = i

        for j in range(i+1, n):

            while(k < n and l[k] < l[i]+l[j]):

                k += 1

            res += k - (j+1)

    print(res)

    return 0



if __name__ == "__main__":

    solve()
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect


def solve():
    n = int(eval(input()))
    l = list(map(int, input().split()))
    l.sort()
    res = 0
    for i in range(n):
        for j in range(i + 1, n):
            k = bisect.bisect_left(l, l[i] + l[j])
            res += max(k - (j + 1), 0)
    print(res)
    return 0


if __name__ == "__main__":
    solve()

import math
import collections
import fractions
import itertools
import functools
import operator
import bisect


def solve():
    n = int(eval(input()))
    l = list(map(int, input().split()))
    l.sort()
    res = 0
    for i in range(n):
        k = i
        for j in range(i + 1, n):
            while k < n and l[k] < l[i] + l[j]:
                k += 1
            res += k - (j + 1)
    print(res)
    return 0


if __name__ == "__main__":
    solve()

+        k = i -            k = bisect.bisect_left(l, l[i] + l[j]) -            res += max(k - (j + 1), 0) +            while k < n and l[k] < l[i] + l[j]: +                k += 1 +            res += k - (j + 1)