#!/usr/bin/env python3
import sys


def solve(N: int, L: "List[int]"):
    from itertools import combinations
    from bisect import bisect_left as bl
    L = sorted(L)
    ans = 0
    for ai, a in enumerate(L):
        for bi, b in enumerate(L[ai+1:-1], ai+1):
            ci = bl(L, a+b)
            ans += ci - bi - 1
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, L))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main() import sys sys def solve(N: int, L: "List[int]"):
    from itertools import combinations
    from bisect import bisect_left as bl
    L = sorted(L)
    ans = 0
    for ai, a in enumerate(L):
        for bi, b in enumerate(L[ai+1:-1], ai+1):
            ci = bl(L, a+b)
            ans += ci - bi - 1
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools solve from itertools import combinations from bisect import bisect_left as bl L = sorted(L) L sorted(L) sorted L ans = 0 ans 0 for ai, a in enumerate(L):
        for bi, b in enumerate(L[ai+1:-1], ai+1):
            ci = bl(L, a+b)
            ans += ci - bi - 1
     ai a enumerate(L) enumerate L for bi, b in enumerate(L[ai+1:-1], ai+1):
            ci = bl(L, a+b)
            ans += ci - bi - 1
     bi b enumerate(L[ai+1:-1], ai+1) enumerate L[ai+1:-1] L ai+1:-1 ai+1 ai 1 -1 ai+1 ai 1 ci = bl(L, a+b) ci bl(L, a+b) bl L a+b a b ans += ci - bi - 1 ans ci - bi - 1 ci - bi ci bi 1 return ans ans N: int N L: "List[int]" L def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, L)) main def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
     iterate_tokens for line in sys.stdin:
            for word in line.split():
                yield word
     line sys.stdin sys stdin for word in line.split():
                yield word
     word line.split() line.split line split yield word word tokens = iterate_tokens() tokens iterate_tokens() iterate_tokens N = int(next(tokens)) N int(next(tokens)) int next(tokens) next tokens int(next(tokens)) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(next(tokens)) int next(tokens) next tokens L = [int(next(tokens)) for _ in range(N)] L [int(next(tokens)) for _ in range(N)] print(solve(N, L)) print solve(N, L) solve N L def test():
    import doctest
    doctest.testmod() test import doctest doctest doctest.testmod() doctest.testmod doctest testmod if __name__ == '__main__':
    #test()
    main() __name__ == '__main__' __name__ '__main__' main() main def test():
    import doctest
    doctest.testmod() def test():
    import doctest
    doctest.testmod() test def solve(N: int, L: "List[int]"):
    from itertools import combinations
    from bisect import bisect_left as bl
    L = sorted(L)
    ans = 0
    for ai, a in enumerate(L):
        for bi, b in enumerate(L[ai+1:-1], ai+1):
            ci = bl(L, a+b)
            ans += ci - bi - 1
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools def solve(N: int, L: "List[int]"):
    from itertools import combinations
    from bisect import bisect_left as bl
    L = sorted(L)
    ans = 0
    for ai, a in enumerate(L):
        for bi, b in enumerate(L[ai+1:-1], ai+1):
            ci = bl(L, a+b)
            ans += ci - bi - 1
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools solve def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, L)) def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, L)) main
#!/usr/bin/env python3
import sys


def solve(N: int, L: "List[int]"):
    from itertools import combinations
    from bisect import bisect_left as bl
    L = sorted(L)
    ans = 0
    for ai, a in enumerate(L):
        for bi, b in enumerate(L[ai+1:-1], ai+1):
            ci = bl(L, a+b)
            ans += ci - bi - 1
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, L))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()
