Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j)
        ans += ri - j - 1

print(ans)

Fixed submission:
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j)
        ans += ri - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j + 1)
        ans += ri - j - 1
print(ans)

Fixed submission:
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j)
        ans += ri - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = set()
for i in range(N - 1):
    for j in range(i + 1, N):
        r = L[i] + L[j]

        ri = bisect.bisect_left(L, r, lo=j)
        for k in range(j+1, ri):
            if k == i or k == j: continue
            ans.add((L[i], L[j], L[k]))

print(len(ans))


Fixed submission:
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j)
        ans += ri - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = set()
for i in range(N - 1):
    for j in range(i + 1, N):
        r = L[i] + L[j]

        ri = bisect.bisect_left(L, r, lo=j)
        for k in range(j+1, ri):
            if k == i or k == j: continue
            ans.add((L[i], L[j], L[k]))

print(len(ans))


Fixed submission:
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j)
        ans += ri - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = set()
for i in range(N - 1):
    for j in range(i + 1, N):
        l = abs(L[i] - L[j])
        r = L[i] + L[j]

        if l < L[i]:
            li = bisect.bisect(L, l, hi=i)
        else:
            li = bisect.bisect(L, l, lo=i, hi=j)

        ri = bisect.bisect_left(L, r, lo=j)
        for k in range(li, ri):
            if k == i or k == j: continue
            if k < i:
                ans.add((L[k], L[i], L[j]))
            elif k < j:
                ans.add((L[i], L[k], L[j]))
            else:
                ans.add((L[i], L[j], L[k]))

print(len(ans))


Fixed submission:
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j)
        ans += ri - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = set()
for i in range(N - 1):
    for j in range(i + 1, N):
        l = abs(L[i] - L[j])
        r = L[i] + L[j]

        if l < L[i]:
            li = bisect.bisect(L, l, hi=i)
        else:
            li = bisect.bisect(L, l, lo=i, hi=j)

        ri = bisect.bisect_left(L, r, lo=j)
        for k in range(li, ri):
            if k == i or k == j: continue
            if k < i:
                ans.add((L[k], L[i], L[j]))
            elif k < j:
                ans.add((L[i], L[k], L[j]))
            else:
                ans.add((L[i], L[j], L[k]))

print(len(ans))


Fixed submission:
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j)
        ans += ri - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = set()
for i in range(N - 1):
    for j in range(i + 1, N):
        l = abs(L[i] - L[j])
        r = L[i] + L[j]
        li = bisect.bisect(L,l)
        ri = bisect.bisect_left(L,r)
        for k in range(li, ri):
            if k == i or k == j: continue
            if k < i:
                ans.add((L[k], L[i], L[j]))
            elif k < j:
                ans.add((L[i], L[k], L[j]))
            else:
                ans.add((L[i], L[j], L[k]))

print(len(ans))


Fixed submission:
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j)
        ans += ri - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = set()
for i in range(N - 1):
    for j in range(i + 1, N):
        l = abs(L[i] - L[j])
        r = L[i] + L[j]
        li = bisect.bisect(L,l)
        ri = bisect.bisect_left(L,r)
        for k in range(li, ri):
            if k == i or k == j: continue
            if k < i:
                ans.add((L[k], L[i], L[j]))
            elif k < j:
                ans.add((L[i], L[k], L[j]))
            else:
                ans.add((L[i], L[j], L[k]))

print(len(ans))


Fixed submission:
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j)
        ans += ri - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [int(_) for _ in input().split()]

memo = [[0] * (N+1) for _ in range(N+1)]
for i in range(N - 1):
    for j in range(i + 1, N):
        memo[i][j] = (abs(L[i] - L[j]), L[i] + L[j])

ans = set()
for i in range(N - 2):
    l1 = L[i]
    for j in range(i + 1, N - 1):
        l2 = L[j]
        for k in range(j + 1, N):
            l3 = L[k]
            if memo[j][k][0] < l1 < memo[j][k][1]:
                ans.add(tuple(sorted([l1, l2, l3])))

print(len(ans))

Fixed submission:
import bisect

N = int(input())
L = [int(_) for _ in input().split()]
L.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        r = L[i] + L[j]
        # 同じ長さでも違う棒はOK
        ri = bisect.bisect_left(L, r, lo=j)
        ans += ri - j - 1

print(ans)