#!/usr/bin/env python3
N = int(input())
L = sorted([int(s) for s in input().split()])


def check_search(middle, idx_short2, l_lng, l_lows):
    return l_lows[middle] + l_lows[idx_short2] > l_lng


l_lows = L[:2]
triangles = 0


for l_lng in L[2:]:
    for idx, l_low in enumerate(l_lows):
        left = 0
        right = len(l_lows) - 1 - idx
        end = right
        while (left < right):
            middle = (left + right) // 2
            if check_search(middle, len(l_lows) - 1 - idx, l_lng, l_lows):
                right = middle
            else:
                left = middle + 1
        triangles += (end - right)
    l_lows.append(l_lng)

print(triangles) N = int(input()) N int(input()) int input() input int(s) for s in input().split() for s in input().split() s input().split() ().split () input split for s in input().split() int(s) int s L = sorted([int(s) for s in input().split()]) L sorted([int(s) for s in input().split()]) sorted [int(s) for s in input().split()] def check_search(middle, idx_short2, l_lng, l_lows):
    return l_lows[middle] + l_lows[idx_short2] > l_lng check_search return l_lows[middle] + l_lows[idx_short2] > l_lng l_lows[middle] + l_lows[idx_short2] > l_lng l_lows[middle] + l_lows[idx_short2] l_lows[middle] l_lows middle l_lows[idx_short2] l_lows idx_short2 l_lng middle middle idx_short2 idx_short2 l_lng l_lng l_lows l_lows l_lows = L[:2] l_lows L[:2] L :2 2 triangles = 0 triangles 0 for l_lng in L[2:]:
    for idx, l_low in enumerate(l_lows):
        left = 0
        right = len(l_lows) - 1 - idx
        end = right
        while (left < right):
            middle = (left + right) // 2
            if check_search(middle, len(l_lows) - 1 - idx, l_lng, l_lows):
                right = middle
            else:
                left = middle + 1
        triangles += (end - right)
    l_lows.append(l_lng) l_lng L[2:] L 2: 2 for idx, l_low in enumerate(l_lows):
        left = 0
        right = len(l_lows) - 1 - idx
        end = right
        while (left < right):
            middle = (left + right) // 2
            if check_search(middle, len(l_lows) - 1 - idx, l_lng, l_lows):
                right = middle
            else:
                left = middle + 1
        triangles += (end - right)
     idx l_low enumerate(l_lows) enumerate l_lows left = 0 left 0 right = len(l_lows) - 1 - idx right len(l_lows) - 1 - idx len(l_lows) - 1 len(l_lows) len l_lows 1 idx end = right end right while (left < right):
            middle = (left + right) // 2
            if check_search(middle, len(l_lows) - 1 - idx, l_lng, l_lows):
                right = middle
            else:
                left = middle + 1
         left < right left right middle = (left + right) // 2 middle (left + right) // 2 left + right left right 2 if check_search(middle, len(l_lows) - 1 - idx, l_lng, l_lows):
                right = middle
            else:
                left = middle + 1
         check_search(middle, len(l_lows) - 1 - idx, l_lng, l_lows) check_search middle len(l_lows) - 1 - idx len(l_lows) - 1 len(l_lows) len l_lows 1 idx l_lng l_lows right = middle right middle left = middle + 1 left middle + 1 middle 1 triangles += (end - right) triangles end - right end right l_lows.append(l_lng) l_lows.append l_lows append l_lng print(triangles) print triangles right = len(l_lows) - 1 - idx len(l_lows) - 1 - idx right right = middle middle right triangles = 0 0 triangles N = int(input()) int(input()) N def check_search(middle, idx_short2, l_lng, l_lows):
    return l_lows[middle] + l_lows[idx_short2] > l_lng def check_search(middle, idx_short2, l_lng, l_lows):
    return l_lows[middle] + l_lows[idx_short2] > l_lng check_search left = middle + 1 middle + 1 left left = 0 0 left triangles += (end - right) end - right triangles L = sorted([int(s) for s in input().split()]) sorted([int(s) for s in input().split()]) L l_lows = L[:2] L[:2] l_lows end = right right end middle = (left + right) // 2 (left + right) // 2 middle
#!/usr/bin/env python3
N = int(input())
L = sorted([int(s) for s in input().split()])


def check_search(middle, idx_short2, l_lng, l_lows):
    return l_lows[middle] + l_lows[idx_short2] > l_lng


l_lows = L[:2]
triangles = 0


for l_lng in L[2:]:
    for idx, l_low in enumerate(l_lows):
        left = 0
        right = len(l_lows) - 1 - idx
        end = right
        while (left < right):
            middle = (left + right) // 2
            if check_search(middle, len(l_lows) - 1 - idx, l_lng, l_lows):
                right = middle
            else:
                left = middle + 1
        triangles += (end - right)
    l_lows.append(l_lng)

print(triangles)