Not able to understand why i am getting run time error

I was attempting this question which has code RRSUM (Sum Queries). I am not sure why I am getting run-time error specifically in the second test case.
Below is my code. Any help will be appreciated.

n, m = map(int, input().split())
arr_1 = [item for item in range(1, n+1)]
arr_2 = [item for item in range(n+1, 2*n+1)]
mean = ((arr_1[0] + arr_2[0]) + (arr_1[-1] + arr_2[-1]))//2
for _ in range(m):
    q = int(input())
    diff = max(mean-q, q-mean)
    print(n-diff) if n-diff > 0 else print(0)