n = int(input())
l_ls = list(map(int, input().split()))
l_ls.sort()
stick_count = [0] * (10**3+1)
stick_csum = [0] * (10**3+1)
for i in range(n):
    stick_count[l_ls[i]] += 1
now = 0
for i in range(10**3+1):
    now += stick_count[i]
    stick_csum[i] = now

ans = 0
for first_i in range(n):
    for second_i in range(first_i+1, n):
        #境界は含まない
        greater_than = abs(l_ls[first_i] - l_ls[second_i])
        smaller_than = min(10**3+1,l_ls[first_i] + l_ls[second_i])
        num_canmake = max(0, stick_csum[smaller_than-1] - stick_csum[greater_than])
        if greater_than < l_ls[first_i] < smaller_than:
            num_canmake -= 1
        if greater_than < l_ls[second_i] < smaller_than:
            num_canmake -= 1
        num_canmake = max(0,num_canmake)
        ans += num_canmake
print(ans//3)

 n = int(input()) n int(input()) int input() input l_ls = list(map(int, input().split())) l_ls list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split l_ls.sort() l_ls.sort l_ls sort stick_count = [0] * (10**3+1) stick_count [0] * (10**3+1) [0] 0 10**3+1 10**3 10 3 1 stick_csum = [0] * (10**3+1) stick_csum [0] * (10**3+1) [0] 0 10**3+1 10**3 10 3 1 for i in range(n):
    stick_count[l_ls[i]] += 1 i range(n) range n stick_count[l_ls[i]] += 1 stick_count[l_ls[i]] stick_count l_ls[i] l_ls i 1 now = 0 now 0 for i in range(10**3+1):
    now += stick_count[i]
    stick_csum[i] = now i range(10**3+1) range 10**3+1 10**3 10 3 1 now += stick_count[i] now stick_count[i] stick_count i stick_csum[i] = now stick_csum[i] stick_csum i now ans = 0 ans 0 for first_i in range(n):
    for second_i in range(first_i+1, n):
        #境界は含まない
        greater_than = abs(l_ls[first_i] - l_ls[second_i])
        smaller_than = min(10**3+1,l_ls[first_i] + l_ls[second_i])
        num_canmake = max(0, stick_csum[smaller_than-1] - stick_csum[greater_than])
        if greater_than < l_ls[first_i] < smaller_than:
            num_canmake -= 1
        if greater_than < l_ls[second_i] < smaller_than:
            num_canmake -= 1
        num_canmake = max(0,num_canmake)
        ans += num_canmake first_i range(n) range n for second_i in range(first_i+1, n):
        #境界は含まない
        greater_than = abs(l_ls[first_i] - l_ls[second_i])
        smaller_than = min(10**3+1,l_ls[first_i] + l_ls[second_i])
        num_canmake = max(0, stick_csum[smaller_than-1] - stick_csum[greater_than])
        if greater_than < l_ls[first_i] < smaller_than:
            num_canmake -= 1
        if greater_than < l_ls[second_i] < smaller_than:
            num_canmake -= 1
        num_canmake = max(0,num_canmake)
        ans += num_canmake second_i range(first_i+1, n) range first_i+1 first_i 1 n greater_than = abs(l_ls[first_i] - l_ls[second_i]) greater_than abs(l_ls[first_i] - l_ls[second_i]) abs l_ls[first_i] - l_ls[second_i] l_ls[first_i] l_ls first_i l_ls[second_i] l_ls second_i smaller_than = min(10**3+1,l_ls[first_i] + l_ls[second_i]) smaller_than min(10**3+1,l_ls[first_i] + l_ls[second_i]) min 10**3+1 10**3 10 3 1 l_ls[first_i] + l_ls[second_i] l_ls[first_i] l_ls first_i l_ls[second_i] l_ls second_i num_canmake = max(0, stick_csum[smaller_than-1] - stick_csum[greater_than]) num_canmake max(0, stick_csum[smaller_than-1] - stick_csum[greater_than]) max 0 stick_csum[smaller_than-1] - stick_csum[greater_than] stick_csum[smaller_than-1] stick_csum smaller_than-1 smaller_than 1 stick_csum[greater_than] stick_csum greater_than if greater_than < l_ls[first_i] < smaller_than:
            num_canmake -= 1
         greater_than < l_ls[first_i] < smaller_than greater_than < l_ls[first_i] greater_than l_ls[first_i] l_ls first_i smaller_than num_canmake -= 1 num_canmake 1 if greater_than < l_ls[second_i] < smaller_than:
            num_canmake -= 1
         greater_than < l_ls[second_i] < smaller_than greater_than < l_ls[second_i] greater_than l_ls[second_i] l_ls second_i smaller_than num_canmake -= 1 num_canmake 1 num_canmake = max(0,num_canmake) num_canmake max(0,num_canmake) max 0 num_canmake ans += num_canmake ans num_canmake print(ans//3) print ans//3 ans 3 num_canmake -= 1 1 num_canmake stick_count = [0] * (10**3+1) [0] * (10**3+1) stick_count ans = 0 0 ans smaller_than = min(10**3+1,l_ls[first_i] + l_ls[second_i]) min(10**3+1,l_ls[first_i] + l_ls[second_i]) smaller_than greater_than = abs(l_ls[first_i] - l_ls[second_i]) abs(l_ls[first_i] - l_ls[second_i]) greater_than num_canmake -= 1 1 num_canmake now += stick_count[i] stick_count[i] now n = int(input()) int(input()) n ans += num_canmake num_canmake ans stick_csum = [0] * (10**3+1) [0] * (10**3+1) stick_csum num_canmake = max(0, stick_csum[smaller_than-1] - stick_csum[greater_than]) max(0, stick_csum[smaller_than-1] - stick_csum[greater_than]) num_canmake now = 0 0 now num_canmake = max(0,num_canmake) max(0,num_canmake) num_canmake l_ls = list(map(int, input().split())) list(map(int, input().split())) l_ls
n = int(input())
l_ls = list(map(int, input().split()))
l_ls.sort()
stick_count = [0] * (10**3+1)
stick_csum = [0] * (10**3+1)
for i in range(n):
    stick_count[l_ls[i]] += 1
now = 0
for i in range(10**3+1):
    now += stick_count[i]
    stick_csum[i] = now

ans = 0
for first_i in range(n):
    for second_i in range(first_i+1, n):
        #境界は含まない
        greater_than = abs(l_ls[first_i] - l_ls[second_i])
        smaller_than = min(10**3+1,l_ls[first_i] + l_ls[second_i])
        num_canmake = max(0, stick_csum[smaller_than-1] - stick_csum[greater_than])
        if greater_than < l_ls[first_i] < smaller_than:
            num_canmake -= 1
        if greater_than < l_ls[second_i] < smaller_than:
            num_canmake -= 1
        num_canmake = max(0,num_canmake)
        ans += num_canmake
print(ans//3)


