import sys
from bisect import bisect_left

input = sys.stdin.readline


def solve(N, L):
    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            c = bisect_left(L, L[a] + L[b]) - 1
            ans += c - b
    return ans


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

    ans = solve(N, L)
    print(ans)


if __name__ == "__main__":
    main() import sys sys from bisect import bisect_left input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def solve(N, L):
    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            c = bisect_left(L, L[a] + L[b]) - 1
            ans += c - b
    return ans solve L.sort() L.sort L sort ans = 0 ans 0 for a in range(N - 2):
        for b in range(a + 1, N - 1):
            c = bisect_left(L, L[a] + L[b]) - 1
            ans += c - b
     a range(N - 2) range N - 2 N 2 for b in range(a + 1, N - 1):
            c = bisect_left(L, L[a] + L[b]) - 1
            ans += c - b
     b range(a + 1, N - 1) range a + 1 a 1 N - 1 N 1 c = bisect_left(L, L[a] + L[b]) - 1 c bisect_left(L, L[a] + L[b]) - 1 bisect_left(L, L[a] + L[b]) bisect_left L L[a] + L[b] L[a] L a L[b] L b 1 ans += c - b ans c - b c b return ans ans N N L L def main():
    N = int(input())
    L = list(map(int, input().split()))

    ans = solve(N, L)
    print(ans) main 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 ans = solve(N, L) ans solve(N, L) solve N L print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def solve(N, L):
    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            c = bisect_left(L, L[a] + L[b]) - 1
            ans += c - b
    return ans def solve(N, L):
    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            c = bisect_left(L, L[a] + L[b]) - 1
            ans += c - b
    return ans solve def main():
    N = int(input())
    L = list(map(int, input().split()))

    ans = solve(N, L)
    print(ans) def main():
    N = int(input())
    L = list(map(int, input().split()))

    ans = solve(N, L)
    print(ans) main input = sys.stdin.readline sys.stdin.readline input
import sys
from bisect import bisect_left

input = sys.stdin.readline


def solve(N, L):
    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            c = bisect_left(L, L[a] + L[b]) - 1
            ans += c - b
    return ans


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

    ans = solve(N, L)
    print(ans)


if __name__ == "__main__":
    main()
