# -*- coding: utf-8 -*-

import bisect

import sys

input = sys.stdin.readline

 

 

def main():

    n = int(eval(input()))

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

    l = sorted(l)

 

    result = 0

    for i in range(n-2):

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

            result += bisect.bisect_left(l[j+1:], l[i] + l[j])

 

    print(result)

 

 

if __name__ == '__main__':

    main()
# -*- coding: utf-8 -*-

import bisect

import sys

input = sys.stdin.readline

 

 

def main():

    n = int(eval(input()))

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

    l = sorted(l)

 

    result = 0

    for i in range(n-2):

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

            result += bisect.bisect_left(l, l[i] + l[j]) - (j + 1)

 

    print(result)

 

 

if __name__ == '__main__':

    main()
# -*- coding: utf-8 -*-
import bisect
import sys

input = sys.stdin.readline


def main():
    n = int(eval(input()))
    l = list(map(int, input().split()))
    l = sorted(l)
    result = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            result += bisect.bisect_left(l[j + 1 :], l[i] + l[j])
    print(result)


if __name__ == "__main__":
    main()

# -*- coding: utf-8 -*-
import bisect
import sys

input = sys.stdin.readline


def main():
    n = int(eval(input()))
    l = list(map(int, input().split()))
    l = sorted(l)
    result = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            result += bisect.bisect_left(l, l[i] + l[j]) - (j + 1)
    print(result)


if __name__ == "__main__":
    main()

-            result += bisect.bisect_left(l[j + 1 :], l[i] + l[j]) +            result += bisect.bisect_left(l, l[i] + l[j]) - (j + 1)