Buggy python submission (verdict: Runtime Error):
N = int(input())
a_i = list(map(int, input().split('')))
 
x = []
y = []
 
if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
X = sum(x)
Y = sum(y)
 
 
if X >= Y:
    print(X - Y)
 
else:
    print(Y - X)

Fixed submission:
N = int(input())
a_i = list(map(int, input().split(" ")))
 
x = []
y = []
 
if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
X = sum(x)
Y = sum(y)
 
 
if X >= Y:
    print(X - Y)
 
else:
    print(Y - X)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a_i = []
for i in range(N):
    a_i.append(int(input()))

x = []
y = []

if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))

else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))

X = sum(x)
Y = sum(y)


if X >= Y:
    print(X - Y)

else:
    print(Y - X)

Fixed submission:
N = int(input())
a_i = list(map(int, input().split(" ")))
 
x = []
y = []
 
if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
X = sum(x)
Y = sum(y)
 
 
if X >= Y:
    print(X - Y)
 
else:
    print(Y - X)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a_i = []
for i in range(N):
    a_i.append(int(input()))

x = []
y = []

if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))

else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))

X = sum(x)
Y = sum(y)


if X >= Y:
    print(X - Y)

else:
    print(Y - X)

Fixed submission:
N = int(input())
a_i = list(map(int, input().split(" ")))
 
x = []
y = []
 
if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
X = sum(x)
Y = sum(y)
 
 
if X >= Y:
    print(X - Y)
 
else:
    print(Y - X)