import sys
from bisect import bisect_left, bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *L = map(int, read().split())

    L.sort()

    ans = 0
    for i in range(N):
        a = L[i]
        for j in range(i + 1, N):
            b = L[j]
            left = bisect_left(L, b, lo=j + 1)
            right = bisect_left(L, a + b, lo=j + 1)
            ans += right - left

    print(ans)
    return


if __name__ == '__main__':
    main() import sys sys from bisect import bisect_left, bisect_right read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 MOD = 1000000007 MOD 1000000007 def main():
    N, *L = map(int, read().split())

    L.sort()

    ans = 0
    for i in range(N):
        a = L[i]
        for j in range(i + 1, N):
            b = L[j]
            left = bisect_left(L, b, lo=j + 1)
            right = bisect_left(L, a + b, lo=j + 1)
            ans += right - left

    print(ans)
    return main N, *L = map(int, read().split()) N map(int, read().split()) map int read().split() ().split () read split *L L L.sort() L.sort L sort ans = 0 ans 0 for i in range(N):
        a = L[i]
        for j in range(i + 1, N):
            b = L[j]
            left = bisect_left(L, b, lo=j + 1)
            right = bisect_left(L, a + b, lo=j + 1)
            ans += right - left

     i range(N) range N a = L[i] a L[i] L i for j in range(i + 1, N):
            b = L[j]
            left = bisect_left(L, b, lo=j + 1)
            right = bisect_left(L, a + b, lo=j + 1)
            ans += right - left

     j range(i + 1, N) range i + 1 i 1 N b = L[j] b L[j] L j left = bisect_left(L, b, lo=j + 1) left bisect_left(L, b, lo=j + 1) bisect_left L b lo=j + 1 lo j + 1 j 1 right = bisect_left(L, a + b, lo=j + 1) right bisect_left(L, a + b, lo=j + 1) bisect_left L a + b a b lo=j + 1 lo j + 1 j 1 ans += right - left ans right - left right left print(ans) print ans return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readlines = sys.stdin.readlines sys.stdin.readlines readlines INF = 1 << 60 1 << 60 INF readline = sys.stdin.readline sys.stdin.readline readline def main():
    N, *L = map(int, read().split())

    L.sort()

    ans = 0
    for i in range(N):
        a = L[i]
        for j in range(i + 1, N):
            b = L[j]
            left = bisect_left(L, b, lo=j + 1)
            right = bisect_left(L, a + b, lo=j + 1)
            ans += right - left

    print(ans)
    return def main():
    N, *L = map(int, read().split())

    L.sort()

    ans = 0
    for i in range(N):
        a = L[i]
        for j in range(i + 1, N):
            b = L[j]
            left = bisect_left(L, b, lo=j + 1)
            right = bisect_left(L, a + b, lo=j + 1)
            ans += right - left

    print(ans)
    return main MOD = 1000000007 1000000007 MOD read = sys.stdin.read sys.stdin.read read
import sys
from bisect import bisect_left, bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *L = map(int, read().split())

    L.sort()

    ans = 0
    for i in range(N):
        a = L[i]
        for j in range(i + 1, N):
            b = L[j]
            left = bisect_left(L, b, lo=j + 1)
            right = bisect_left(L, a + b, lo=j + 1)
            ans += right - left

    print(ans)
    return


if __name__ == '__main__':
    main()
