from bisect import bisect_right

n=int(eval(input()))

L=[int(i) for i in input().split()]

L.sort()





ans=0

for i in range(n-2):

  for j in range(i+1,n-1):

    c=L[i]+L[j]-1

    ans+=bisect_right(L,c)-j-1

    

print(ans)
n=int(eval(input()))

L=[int(i) for i in input().split()]

L.sort(reverse=True)



def binary(a,b,mid):

  if  L[mid]+L[j]>L[i]:

    return True

  else:

    return False



ans=0

for i in range(n-2):

  for j in range(i+1,n-1):

    l=j

    r=n

    while r-l>1:

      mid=(r+l)//2

      if binary(i,j,mid):

        l=mid

      else:

        r=mid

    ans+=l-j

print(ans)

        

from bisect import bisect_right

n = int(eval(input()))
L = [int(i) for i in input().split()]
L.sort()
ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        c = L[i] + L[j] - 1
        ans += bisect_right(L, c) - j - 1
print(ans)

n = int(eval(input()))
L = [int(i) for i in input().split()]
L.sort(reverse=True)


def binary(a, b, mid):
    if L[mid] + L[j] > L[i]:
        return True
    else:
        return False


ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        l = j
        r = n
        while r - l > 1:
            mid = (r + l) // 2
            if binary(i, j, mid):
                l = mid
            else:
                r = mid
        ans += l - j
print(ans)

-from bisect import bisect_right - -L.sort() +L.sort(reverse=True) + + +def binary(a, b, mid): +    if L[mid] + L[j] > L[i]: +        return True +    else: +        return False + + -        c = L[i] + L[j] - 1 -        ans += bisect_right(L, c) - j - 1 +        l = j +        r = n +        while r - l > 1: +            mid = (r + l) // 2 +            if binary(i, j, mid): +                l = mid +            else: +                r = mid +        ans += l - j