import sys
input = sys.stdin.readline
import bisect


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n = int(input())
    l = sorted(input_list())
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            ans += bisect.bisect_left(l, l[a]+l[b]) - (b+1)
    print(ans)

def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline import bisect bisect def main():
    n = int(input())
    l = sorted(input_list())
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            ans += bisect.bisect_left(l, l[a]+l[b]) - (b+1)
    print(ans) main n = int(input()) n int(input()) int input() input l = sorted(input_list()) l sorted(input_list()) sorted input_list() input_list ans = 0 ans 0 for a in range(n):
        for b in range(a+1, n):
            ans += bisect.bisect_left(l, l[a]+l[b]) - (b+1)
     a range(n) range n for b in range(a+1, n):
            ans += bisect.bisect_left(l, l[a]+l[b]) - (b+1)
     b range(a+1, n) range a+1 a 1 n ans += bisect.bisect_left(l, l[a]+l[b]) - (b+1) ans bisect.bisect_left(l, l[a]+l[b]) - (b+1) bisect.bisect_left(l, l[a]+l[b]) bisect.bisect_left bisect bisect_left l l[a]+l[b] l[a] l a l[b] l b b+1 b 1 print(ans) print ans def input_list():
    return list(map(int, input().split())) input_list return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def input_list_str():
    return list(map(str, input().split())) input_list_str return list(map(str, input().split())) list(map(str, input().split())) list map(str, input().split()) map str input().split() ().split () input split if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def input_list_str():
    return list(map(str, input().split())) def input_list_str():
    return list(map(str, input().split())) input_list_str def main():
    n = int(input())
    l = sorted(input_list())
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            ans += bisect.bisect_left(l, l[a]+l[b]) - (b+1)
    print(ans) def main():
    n = int(input())
    l = sorted(input_list())
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            ans += bisect.bisect_left(l, l[a]+l[b]) - (b+1)
    print(ans) main input = sys.stdin.readline sys.stdin.readline input def input_list():
    return list(map(int, input().split())) def input_list():
    return list(map(int, input().split())) input_list
import sys
input = sys.stdin.readline
import bisect


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n = int(input())
    l = sorted(input_list())
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            ans += bisect.bisect_left(l, l[a]+l[b]) - (b+1)
    print(ans)

def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()
