Help me in solving MAX_DIFF problem

My issue

My code

T = int(input())
for i in range(T):
    N, S = map(int, input().split())
    print(N-(S-N))

Problem Link: CodeChef: Practical coding for everyone

t = int(input())
while t !=0:
t-=1
arr = list(map(int, input().split()))
not_g_then_s = arr[0]
s = arr[-1]

if not_g_then_s >= s:
    print(s)
elif s > not_g_then_s:
    print(not_g_then_s - (s-not_g_then_s))