import sys
input = sys.stdin.readline

def main():
    n = int(input())
    l = sorted(list(map(int, input().split())))
    ans = 0

    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            L = j
            R = n
            ij = l[i] + l[j]
            while R - L != 1:
                if ij <= l[j + 1]:
                    break
                now = (L + R)//2
                if ij > l[now]: #三角形になる
                    L = now
                else:
                    R = now
            ans += L - j

    print(ans)

main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    n = int(input())
    l = sorted(list(map(int, input().split())))
    ans = 0

    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            L = j
            R = n
            ij = l[i] + l[j]
            while R - L != 1:
                if ij <= l[j + 1]:
                    break
                now = (L + R)//2
                if ij > l[now]: #三角形になる
                    L = now
                else:
                    R = now
            ans += L - j

    print(ans) main n = int(input()) n int(input()) int input() input l = sorted(list(map(int, input().split()))) l sorted(list(map(int, input().split()))) sorted list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for i in range(n - 2):
        for j in range(i + 1, n - 1):
            L = j
            R = n
            ij = l[i] + l[j]
            while R - L != 1:
                if ij <= l[j + 1]:
                    break
                now = (L + R)//2
                if ij > l[now]: #三角形になる
                    L = now
                else:
                    R = now
            ans += L - j

     i range(n - 2) range n - 2 n 2 for j in range(i + 1, n - 1):
            L = j
            R = n
            ij = l[i] + l[j]
            while R - L != 1:
                if ij <= l[j + 1]:
                    break
                now = (L + R)//2
                if ij > l[now]: #三角形になる
                    L = now
                else:
                    R = now
            ans += L - j

     j range(i + 1, n - 1) range i + 1 i 1 n - 1 n 1 L = j L j R = n R n ij = l[i] + l[j] ij l[i] + l[j] l[i] l i l[j] l j while R - L != 1:
                if ij <= l[j + 1]:
                    break
                now = (L + R)//2
                if ij > l[now]: #三角形になる
                    L = now
                else:
                    R = now
             R - L != 1 R - L R L 1 if ij <= l[j + 1]:
                    break
                 ij <= l[j + 1] ij l[j + 1] l j + 1 j 1 break now = (L + R)//2 now (L + R)//2 L + R L R 2 if ij > l[now]: #三角形になる
                    L = now
                else:
                    R = now
             ij > l[now] ij l[now] l now L = now L now R = now R now ans += L - j ans L - j L j print(ans) print ans main() main def main():
    n = int(input())
    l = sorted(list(map(int, input().split())))
    ans = 0

    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            L = j
            R = n
            ij = l[i] + l[j]
            while R - L != 1:
                if ij <= l[j + 1]:
                    break
                now = (L + R)//2
                if ij > l[now]: #三角形になる
                    L = now
                else:
                    R = now
            ans += L - j

    print(ans) def main():
    n = int(input())
    l = sorted(list(map(int, input().split())))
    ans = 0

    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            L = j
            R = n
            ij = l[i] + l[j]
            while R - L != 1:
                if ij <= l[j + 1]:
                    break
                now = (L + R)//2
                if ij > l[now]: #三角形になる
                    L = now
                else:
                    R = now
            ans += L - j

    print(ans) main input = sys.stdin.readline sys.stdin.readline input
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    l = sorted(list(map(int, input().split())))
    ans = 0

    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            L = j
            R = n
            ij = l[i] + l[j]
            while R - L != 1:
                if ij <= l[j + 1]:
                    break
                now = (L + R)//2
                if ij > l[now]: #三角形になる
                    L = now
                else:
                    R = now
            ans += L - j

    print(ans)

main()