import bisect

def binary_search(items, a, b, i, j):
    def c_is_x(c):
        is1 = c > max(a - b, b - a)
        is2 = c < a + b

        if is1 and is2:
            return 0
        elif is1:
            return 1
        else:
            return 2

    low = j+1
    high = len(items) - 1

    while low <= high:
        mid = (low + high) // 2
        ans = items[mid]
        c_type = c_is_x(ans)
        if c_type == 0 and mid != i and mid != j:
            return mid
        elif c_type == 1:
            low = mid + 1
        else:
            high = mid - 1

    return None


N = int(input())
L = list(map(int, input().split()))

L.sort()
# print(L)
count = 0
for i in range(N):
    for j in range(i+1, N):
        # i = N - i - 1
        # j = N - j - 1
        a = L[i]
        b = L[j]
        k = bisect.bisect_left(L, a+b, lo=j) - 1

        if k < N:
            c = L[k]
            # print(a, b, c, a+b)
            # print(i, j, k)
            count += max(k - j, 0)


print(count)

 import bisect bisect def binary_search(items, a, b, i, j):
    def c_is_x(c):
        is1 = c > max(a - b, b - a)
        is2 = c < a + b

        if is1 and is2:
            return 0
        elif is1:
            return 1
        else:
            return 2

    low = j+1
    high = len(items) - 1

    while low <= high:
        mid = (low + high) // 2
        ans = items[mid]
        c_type = c_is_x(ans)
        if c_type == 0 and mid != i and mid != j:
            return mid
        elif c_type == 1:
            low = mid + 1
        else:
            high = mid - 1

    return None binary_search def c_is_x(c):
        is1 = c > max(a - b, b - a)
        is2 = c < a + b

        if is1 and is2:
            return 0
        elif is1:
            return 1
        else:
            return 2

     c_is_x is1 = c > max(a - b, b - a) is1 c > max(a - b, b - a) c max(a - b, b - a) max a - b a b b - a b a is2 = c < a + b is2 c < a + b c a + b a b if is1 and is2:
            return 0
        elif is1:
            return 1
        else:
            return 2

     is1 and is2 is1 is2 return 0 0 elif is1:
            return 1
         is1 return 1 1 return 2 2 c c low = j+1 low j+1 j 1 high = len(items) - 1 high len(items) - 1 len(items) len items 1 while low <= high:
        mid = (low + high) // 2
        ans = items[mid]
        c_type = c_is_x(ans)
        if c_type == 0 and mid != i and mid != j:
            return mid
        elif c_type == 1:
            low = mid + 1
        else:
            high = mid - 1

     low <= high low high mid = (low + high) // 2 mid (low + high) // 2 low + high low high 2 ans = items[mid] ans items[mid] items mid c_type = c_is_x(ans) c_type c_is_x(ans) c_is_x ans if c_type == 0 and mid != i and mid != j:
            return mid
        elif c_type == 1:
            low = mid + 1
        else:
            high = mid - 1

     c_type == 0 and mid != i and mid != j c_type == 0 and mid != i c_type == 0 c_type 0 mid != i mid i mid != j mid j return mid mid elif c_type == 1:
            low = mid + 1
         c_type == 1 c_type 1 low = mid + 1 low mid + 1 mid 1 high = mid - 1 high mid - 1 mid 1 return None None items items a a b b i i j j 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 count = 0 count 0 for i in range(N):
    for j in range(i+1, N):
        # i = N - i - 1
        # j = N - j - 1
        a = L[i]
        b = L[j]
        k = bisect.bisect_left(L, a+b, lo=j) - 1

        if k < N:
            c = L[k]
            # print(a, b, c, a+b)
            # print(i, j, k)
            count += max(k - j, 0) i range(N) range N for j in range(i+1, N):
        # i = N - i - 1
        # j = N - j - 1
        a = L[i]
        b = L[j]
        k = bisect.bisect_left(L, a+b, lo=j) - 1

        if k < N:
            c = L[k]
            # print(a, b, c, a+b)
            # print(i, j, k)
            count += max(k - j, 0) j range(i+1, N) range i+1 i 1 N a = L[i] a L[i] L i b = L[j] b L[j] L j k = bisect.bisect_left(L, a+b, lo=j) - 1 k bisect.bisect_left(L, a+b, lo=j) - 1 bisect.bisect_left(L, a+b, lo=j) bisect.bisect_left bisect bisect_left L a+b a b lo=j lo j 1 if k < N:
            c = L[k]
            # print(a, b, c, a+b)
            # print(i, j, k)
            count += max(k - j, 0) k < N k N c = L[k] c L[k] L k count += max(k - j, 0) count max(k - j, 0) max k - j k j 0 print(count) print count N = int(input()) int(input()) N count += max(k - j, 0) max(k - j, 0) count def binary_search(items, a, b, i, j):
    def c_is_x(c):
        is1 = c > max(a - b, b - a)
        is2 = c < a + b

        if is1 and is2:
            return 0
        elif is1:
            return 1
        else:
            return 2

    low = j+1
    high = len(items) - 1

    while low <= high:
        mid = (low + high) // 2
        ans = items[mid]
        c_type = c_is_x(ans)
        if c_type == 0 and mid != i and mid != j:
            return mid
        elif c_type == 1:
            low = mid + 1
        else:
            high = mid - 1

    return None def binary_search(items, a, b, i, j):
    def c_is_x(c):
        is1 = c > max(a - b, b - a)
        is2 = c < a + b

        if is1 and is2:
            return 0
        elif is1:
            return 1
        else:
            return 2

    low = j+1
    high = len(items) - 1

    while low <= high:
        mid = (low + high) // 2
        ans = items[mid]
        c_type = c_is_x(ans)
        if c_type == 0 and mid != i and mid != j:
            return mid
        elif c_type == 1:
            low = mid + 1
        else:
            high = mid - 1

    return None binary_search L = list(map(int, input().split())) list(map(int, input().split())) L b = L[j] L[j] b count = 0 0 count a = L[i] L[i] a k = bisect.bisect_left(L, a+b, lo=j) - 1 bisect.bisect_left(L, a+b, lo=j) - 1 k c = L[k] L[k] c
import bisect

def binary_search(items, a, b, i, j):
    def c_is_x(c):
        is1 = c > max(a - b, b - a)
        is2 = c < a + b

        if is1 and is2:
            return 0
        elif is1:
            return 1
        else:
            return 2

    low = j+1
    high = len(items) - 1

    while low <= high:
        mid = (low + high) // 2
        ans = items[mid]
        c_type = c_is_x(ans)
        if c_type == 0 and mid != i and mid != j:
            return mid
        elif c_type == 1:
            low = mid + 1
        else:
            high = mid - 1

    return None


N = int(input())
L = list(map(int, input().split()))

L.sort()
# print(L)
count = 0
for i in range(N):
    for j in range(i+1, N):
        # i = N - i - 1
        # j = N - j - 1
        a = L[i]
        b = L[j]
        k = bisect.bisect_left(L, a+b, lo=j) - 1

        if k < N:
            c = L[k]
            # print(a, b, c, a+b)
            # print(i, j, k)
            count += max(k - j, 0)


print(count)


