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

# a, bをfixしてcを探索
# n*n*logn
# c_i < a+b をにぶたん
def binary_search(list, item):
    # listからitem未満の最大のindexを取得
    low = 0
    high = len(list) - 1
    if list[high] < item:
        return high+1
    if list[low] >= item:
        return low
    while True:
        mid = (low + high) //2
        guess = list[mid]
        if high - low <= 1:
            return high
        if guess >= item:
            high = mid
        else:
            low = mid

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        a = l[i]
        b = l[j]
        c = binary_search(l, b+a)
        ans += c-(j+1)
print(ans) 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 l.sort() l.sort l sort def binary_search(list, item):
    # listからitem未満の最大のindexを取得
    low = 0
    high = len(list) - 1
    if list[high] < item:
        return high+1
    if list[low] >= item:
        return low
    while True:
        mid = (low + high) //2
        guess = list[mid]
        if high - low <= 1:
            return high
        if guess >= item:
            high = mid
        else:
            low = mid binary_search low = 0 low 0 high = len(list) - 1 high len(list) - 1 len(list) len list 1 if list[high] < item:
        return high+1
     list[high] < item list[high] list high item return high+1 high+1 high 1 if list[low] >= item:
        return low
     list[low] >= item list[low] list low item return low low while True:
        mid = (low + high) //2
        guess = list[mid]
        if high - low <= 1:
            return high
        if guess >= item:
            high = mid
        else:
            low = mid True mid = (low + high) //2 mid (low + high) //2 low + high low high 2 guess = list[mid] guess list[mid] list mid if high - low <= 1:
            return high
         high - low <= 1 high - low high low 1 return high high if guess >= item:
            high = mid
        else:
            low = mid guess >= item guess item high = mid high mid low = mid low mid list list item item ans = 0 ans 0 for i in range(n-2):
    for j in range(i+1, n-1):
        a = l[i]
        b = l[j]
        c = binary_search(l, b+a)
        ans += c-(j+1) i range(n-2) range n-2 n 2 for j in range(i+1, n-1):
        a = l[i]
        b = l[j]
        c = binary_search(l, b+a)
        ans += c-(j+1) j range(i+1, n-1) range i+1 i 1 n-1 n 1 a = l[i] a l[i] l i b = l[j] b l[j] l j c = binary_search(l, b+a) c binary_search(l, b+a) binary_search l b+a b a ans += c-(j+1) ans c-(j+1) c j+1 j 1 print(ans) print ans n = int(input()) int(input()) n l = list(map(int, input().split())) list(map(int, input().split())) l c = binary_search(l, b+a) binary_search(l, b+a) c b = l[j] l[j] b ans += c-(j+1) c-(j+1) ans a = l[i] l[i] a ans = 0 0 ans def binary_search(list, item):
    # listからitem未満の最大のindexを取得
    low = 0
    high = len(list) - 1
    if list[high] < item:
        return high+1
    if list[low] >= item:
        return low
    while True:
        mid = (low + high) //2
        guess = list[mid]
        if high - low <= 1:
            return high
        if guess >= item:
            high = mid
        else:
            low = mid def binary_search(list, item):
    # listからitem未満の最大のindexを取得
    low = 0
    high = len(list) - 1
    if list[high] < item:
        return high+1
    if list[low] >= item:
        return low
    while True:
        mid = (low + high) //2
        guess = list[mid]
        if high - low <= 1:
            return high
        if guess >= item:
            high = mid
        else:
            low = mid binary_search
n = int(input())
l = list(map(int, input().split()))
l.sort()

# a, bをfixしてcを探索
# n*n*logn
# c_i < a+b をにぶたん
def binary_search(list, item):
    # listからitem未満の最大のindexを取得
    low = 0
    high = len(list) - 1
    if list[high] < item:
        return high+1
    if list[low] >= item:
        return low
    while True:
        mid = (low + high) //2
        guess = list[mid]
        if high - low <= 1:
            return high
        if guess >= item:
            high = mid
        else:
            low = mid

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        a = l[i]
        b = l[j]
        c = binary_search(l, b+a)
        ans += c-(j+1)
print(ans)
