Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, stderr
from itertools import groupby, permutations, combinations
import numpy as np


def main():
    N = int(input())
    L = np.sort(np.array([int(x) for x in input().split()]))

    ret = 0
    # print(L, file=stderr)
    for ij in combinations(range(N - 1), 2):
        i, j = ij
        c = L[i] + L[j]
        k = np.searchsorted(L, c, side='right')
        if L[k - 1] == c:
            k = np.searchsorted(L, c, side='left')
        # print(L[i], L[j], k, ret, file=stderr)
        ret += k - j - 1

    # for i in range(N - 2):
    #     for j in range(i + 1, N - 1):
    #         k = np.searchsorted(L, L[i] + L[j], side='right')
    #         if L[k - 1] == L[i] + L[j]:
    #             k = np.searchsorted(L, L[i] + L[j], side='left')
    #         # print(L[i], L[j], k, ret, file=stderr)
    #         ret += k - j - 1
    return ret


if __name__ == "__main__":
    print(main())


Fixed submission:
from sys import stdin, stderr
from itertools import groupby, permutations, combinations
from bisect import bisect_right
import numpy as np


def main():
    N = int(input())
    L = sorted([int(x) for x in input().split()])
    ret = 0
    # print(L, file=stderr)
    # for ij in combinations(range(N - 1), 2):
    #     i, j = ij
    #     c = L[i] + L[j] - 1
    #     k = bisect_right(L, c)
    # #     k = np.searchsorted(L, c, side='right')
    #     ret += k - j - 1

    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            c = L[i] + L[j] - 1
            # k = np.searchsorted(L, c, side='right')
            k = bisect_right(L, c)
            # print(L[i], L[j], k, ret, file=stderr)
            ret += k - j - 1
    return ret


if __name__ == "__main__":
    print(main())

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, stderr
from itertools import groupby, permutations
import numpy as np


def main():
    N = int(input())
    L = np.sort(np.array([int(x) for x in input().split()]))

    ret = 0
    # print(L, file=stderr)
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            k = np.searchsorted(L, L[i] + L[j], side='right')
            if L[k - 1] == L[i] + L[j]:
                k = np.searchsorted(L, L[i] + L[j], side='left')
            # print(L[i], L[j], k, ret, file=stderr)
            ret += k - j - 1
    return ret


if __name__ == "__main__":
    print(main())


Fixed submission:
from sys import stdin, stderr
from itertools import groupby, permutations, combinations
from bisect import bisect_right
import numpy as np


def main():
    N = int(input())
    L = sorted([int(x) for x in input().split()])
    ret = 0
    # print(L, file=stderr)
    # for ij in combinations(range(N - 1), 2):
    #     i, j = ij
    #     c = L[i] + L[j] - 1
    #     k = bisect_right(L, c)
    # #     k = np.searchsorted(L, c, side='right')
    #     ret += k - j - 1

    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            c = L[i] + L[j] - 1
            # k = np.searchsorted(L, c, side='right')
            k = bisect_right(L, c)
            # print(L[i], L[j], k, ret, file=stderr)
            ret += k - j - 1
    return ret


if __name__ == "__main__":
    print(main())