Problem:


Score: 200 points

Problem Statement

We have N cards. A number a_i is written on the i-th card.

Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.

The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

Constraints

N is an integer between 1 and 100 (inclusive).

a_i \ (1 \leq i \leq N) is an integer between 1 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:  

N
a_1 a_2 a_3 ... a_N

Output

Print Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.

Sample Input 1

2
3 1

Sample Output 1

2

First, Alice will take the card with 3. Then, Bob will take the card with 1.
The difference of their scores will be 3 - 1 = 2.

Sample Input 2

3
2 7 4

Sample Output 2

5

First, Alice will take the card with 7. Then, Bob will take the card with 4. Lastly, Alice will take the card with 2. The difference of their scores will be 7 - 4 + 2 = 5. The difference of their scores will be 3 - 1 = 2.

Sample Input 3

4
20 18 2 18

Sample Output 3

18



Sample input:
2
3 1


Sample output:
2

Submission status: Runtime Error

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
print(sum(a[::2]-sum(a[1::2]))

Submission status: Runtime Error

Solution code:
N = int(input())
a = map(int, input().split())
a.sort()
print(sum(a[0::2])-sum(a[1::2]))

Submission status: Runtime Error

Solution code:
n = int(input())
L = list(map(int,input().split()))
L = soterd(L,reverse=True)
a,b = 0,0
for i in range(len(L)):
  if i%2 == 0:
    a += L[i]
  else:
    b += L[i]
print(a-b)

Submission status: Runtime Error

Solution code:
input()
li = list(map(int, input().split()))
li.sort(reverse=True)
alice = [i for index,i in enumerate(li) if index % 2 == 0]
ans = alice * 2 - sum(li)
print(alice)

Submission status: Runtime Error

Solution code:
N = input()
a = sorted(list(map(int,input().split())), reverse=True)

print(sum(a[::2]) - a[1::2] )

Submission status: Runtime Error

Solution code:
N = int(input())
B = list(map(int, input().split()))

one =[]
two =[]
count = 0
if N%2 ==0:
  while count <= N:
    one.append(max(B))
    B.remove(max(B))
    two.append(max(B))
    B.remove(max(B))
    count +=2
else:
  while count <= N-2:
    one.append(max(B))
    B.remove(max(B))
    two.append(max(B))
    B.remove(max(B))
    count +=2
  one.append(max(B))
  B.remove(max(B))

print(sum(one)-sum(two))

Submission status: Runtime Error

Solution code:
N = int(input())
B = list(map(int, input().split()))

one =[]
two =[]
count = 0
if N%2 ==0:
  while count <= N:
    one.append(max(B))
    B.remove(max(B))
    two.append(max(B))
    B.remove(max(B))
    count +=2
else:
  while count <= N-2:
    one.append(max(B))
    B.remove(max(B))
    two.append(max(B))
    B.remove(max(B))
    count +=2
  one.append(max(B))
  B.remove(max(B))
print(one)
print(two)
print(sum(one)-sum(two))

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

Alice = Sum(a[::2])
Bob = Sum(a[1::2])

print(Alice - Bob)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

Alice = a[0::2]
Bob = a[1::2]

print(Alice - Bob)

Submission status: Runtime Error

Solution code:
n = int(input())
lis = [int(x) for x in input().split(" ")]
lis.sort(reverse=True)
lis_Alice = []
lis_Bob = []

for a in range(0, n, 2):
  lis_Alice.append(lis[a])

for b in range(1, n+1, 2):
  lis_Bob.append(lis[b])

print(sum(lis_Alice) - sum(lis_Bob))

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(1, N + 1):
  if i % 2 == 1:
    s += a[-i]
  else:
    s -= a[-i]
print(s)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(N):
  if i % 2 == 1:
    s += a[-i]
  else:
    s -= a[-i]
print(s)

Submission status: Runtime Error

Solution code:
li = list(map(int, input().split()))
li.sort(reverse = True)
i = 0
while i <= len(li): 
    a = li[i]
    i += 2
i = 1
while i <= len(li):
    b = li[i]
    i += 2
print(a -b)

Submission status: Runtime Error

Solution code:
li = list(map(int, input().split()))
li.sort(*, key = None, reverse = True)
i = 0
while i <= len(li): 
    a = li[i]
    i += 2
i = 1
while i <= len(li):
    b = li[i]
    i += 2
print(a -b)

Submission status: Runtime Error

Solution code:
li = list(map(int, input().split()))
li.sort(*, key = None, reverse = True)
for i in range(len(li)):
    a = li[i]
    b = li[i +1]
print(a -b)

Submission status: Runtime Error

Solution code:
li = list(map(int, input().split()))
li.sort(*, key = None, reverse = True)
for i in range(len(li)):
    a = li[i]
    b = li[i +1]]
print(a -b)

Submission status: Runtime Error

Solution code:
N=int(input())
A=[map(int,input().split())]
A_sort=sorted(A)
Alice=[]
Bob=[]
if N%2==0:
    for i in range(int(N/2)):
        Alice.append(A_sort(2*i+1))
        Bob.append(A_sort(2*i))
else:
    for i in range(int(N/2+1)):
        Alice.append(A_sort(2*i))
    for i in range(int(N/2)):
        Bob.append(A_sort(2*i+1))
Alice_sum=sum(Alice)
Bob_sum=sum(Bob)
ans=Alice_sum-Bob_sum
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a, b = map(int, input().split())
# print("a:{}, b:{}, c:{}".format(n, a, b))
data = sorted(list([n,a,b]), reverse=True)
count_A = 0
count_B = 0

for i, d in enumerate(data):
    if i%2 == 0:
        count_A += d
    else:
        count_B += d
        
print(count_A - count_B)

Submission status: Runtime Error

Solution code:
N = int(input())
n, a, b = map(int, input().split())
# print("a:{}, b:{}, c:{}".format(n, a, b))
data = sorted(list([n,a,b]), reverse=True)
count_A = 0
count_B = 0

for i, d in enumerate(data):
    if i%2 == 0:
        count_A += d
    else:
        count_B += d
        
print(count_A - count_B)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
# print("a:{}, b:{}, c:{}".format(n, a, b))
data = sorted(list([n,a,b]), reverse=True)
count_A = 0
count_B = 0

for i, d in enumerate(data):
    if i%2 == 0:
        count_A += d
    else:
        count_B += d
        
print(count_A - count_B)

Submission status: Runtime Error

Solution code:
n = int(input())

print((n(n-1)//2))

Submission status: Runtime Error

Solution code:
n = int(input())
AS = list(map(int,input().split()))

points = [0,0]#alice,bob
i = 0
while AS:
  point = max(AS)
  points[i] += point
  AS.remove(point)
  i = 1-i
print(point[0]-point[1])

Submission status: Runtime Error

Solution code:
n = int(input())
list = list(map(int, input().split()))
list.sort()
list.reverse()

a = 0
b = 0

for i in list:
  if i % 2 == 0:
    a += list[i]
  else:
    b += list[i]

print(a - b)

Submission status: Runtime Error

Solution code:
from functools import reduce 
from operator import add
 
n = int(input())
arr = map(int, input().split())
 
pt_a = 0
pt_b = 0
 
arr.sort(reverse=True)
 
for ind, num in enumerate(arr):
  if ind % 2 == 0:
    pt_a += num
  else:
    pt_b += num
 
print(pt_a - pt_b)

Submission status: Runtime Error

Solution code:
from functools import reduce 
from operator import add

n = int(input())
arr = map(int, input().split())

pt_a = 0
pt_b = 0

arr = arr.sort(reverse=True)

for ind, num in enumerate(arr):
  if ind % 2 == 0:
    pt_a += num
  else:
    pt_b += num

print(pt_a - pt_b)

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(map(int,input().split()))
a = 0
b = 0
l.sort(reverser=True)
for i in range(n):
  if i % 2 == 0:
    a += l[i]
  else:
    b += l[i]
print(a-b)

Submission status: Runtime Error

Solution code:
input()
l=sorted(map(int,input().split()))[::-1]
pritn(sum(l[::2])-sum(l[1::2]))

Submission status: Runtime Error

Solution code:
n = int(input())
cardList = [int(input()) for i in range(n)]

cardList = cardList.sort(reverse=True)

alice = 0
bob = 0
turn = True
for c in cardList:  
  if turn:
    alice+= c
    turn = False
  else:
    bob +=c
    turn =True
    
print(alice-bob)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N;
	cin >> N;
	vector <int> vec( N );
	rep( i, 0, N )  cin >> vec[ i ];
	sort_desc( vec );
	int alice = 0;
	int bob = 0;
	rep( i, 0, N ){
		if (i % 2 == 0)
			alice += vec[ i ];
		else
			bob += vec[ i ];
	}
	cout << abs( alice - bob ) << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(input().split())
a.sort(reverse=True)
print(sum(a[0::2]) - sum(a[1::2]))

Submission status: Runtime Error

Solution code:
input()
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(s[::2]) - sum(s[1::2]))

Submission status: Runtime Error

Solution code:
n = int(input())
ais = input().split()
ais_sort = sort(ais)
alice = 0
bob = 0
if n % 2 == 0:
  for i in range(n):
    if i % 2 == 1:
      alice += int(ais_sort[i])
    else:
      bob += int(ais_sort[i])
else:
  for j in range(n):
    if i % 2 == 0:
      alice += int(ais_sort[i])
    else:
      bob += int(ais_sort[i])
print(alice - bob)

Submission status: Runtime Error

Solution code:
N = int(input())
a = [110]
a = list(map(int, input().sprit()))
a.sort(reverse=True)
 
Alis = 0
Bob = 0
for j in range(N):
  if j % 2 == 0:
    Alis += a[j]
  else:
    Bob += a[j]
 
print(Alis-Bob)

Submission status: Runtime Error

Solution code:
N = input()
a = [110]
for i in range(N):
  a[1] = input()
a.sort(reverse=True)

int Alis = 0
int Bob = 0
for j in range(N):
  if j % 2 == 0:
    Alis += a[j]
  else:
    Bob += [j]

print(Alis-Bob)

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split())).sort()
for i in range(n):
    if i%2==1:
        l[i]=(-1)*l[i]
print(sum(l))

Submission status: Runtime Error

Solution code:


fn main() {
    let n: i32 = read();
    let mut a: Vec<i32> = Vec::new();
    for i in 0..n {
        a.push(read());
    }
    a.sort();

    let mut Al = 0;
    let mut Bo = 0;
    for i in 0..n {
        if i % 2 == 0 {
            Al += a.pop().unwrap();
        } else {
            Bo += a.pop().unwrap();
        }
    } 
    let ans = Al - Bo;
    println!("{}", ans);
}

// 以下関数


use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2]) - sum(a[1::2])))

Submission status: Runtime Error

Solution code:
N = int(input())
a = sorted[int(N) for N input().split()]

alice = 0
bob = 0

alice = sum(a[1::2])
bob = sum(a[0::2])

print(alice - bob)

Submission status: Runtime Error

Solution code:
N = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)

A = 0
B = 0
idx = 0
for card in cards:
    if idx % 2 == 0:
        A += card
    else:
        B += card
    idx += 1


print(str(A-B))
~

Submission status: Runtime Error

Solution code:
yandy
N = input()
a = list(map(int, input().split()))

a.sort(reverse=True)

Alice = a[0::2]
Bob = a[1::2]

print(sum(Alice) - sum(Bob))

Submission status: Runtime Error

Solution code:
N = int(input())
li = [int(input()) for x in range(N)]
lili = sorted(li)
lili.reverse()
score = 0
isA = 1
for i in lili:
    if isA % 2 == 1:
        score += i
    else:
        score -= i
    isA += 1
print(score)

Submission status: Runtime Error

Solution code:
-*- coding: utf-8 -*- 
a = int(input())  # Nを入力 
b = input()  # a1,a2...anを入力 
b = map(int, b.split())  # a1,a2...anをint型でリストに入れる 
b = sorted(b)  # 大きい順に並べる b = b[::-1]  # リストの要素の順番を逆転する 
c = b[::2]  # Aliceのとる要素を抽出 
c_number = len(c) 
d = b[1::2]  # Bobのとる要素を抽出 
d_number = len(d) 
c_sum = 0 
d_sum = 0 
for i in range(c_number):
    c_sum += c[i] # Aliceのとる要素の合計  
for g in range(d_number):
　　d_sum += d[g]  # Bobのとる要素の合計  
print(c_sum - d_sum)  # 差分を出力

Submission status: Runtime Error

Solution code:
n = int(input())
List = list(map(int,input().split()))
A = []
B = []
List = sorted(List,reverse=True)
for i in range(len(List)):
  if i%2 == 0:
    A.append(item)
  else:
    B.append(item)
Answer = sum(A) - sum(B)
print(Answer)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = []
for i in range(0,N,2):
  B.append(A[i])
print(abs(A-sum(B)*2))

Submission status: Runtime Error

Solution code:
#coding:utf-8

n = int(input())

nums = list(map(int,input()))
sorted(nums, reverse=True)
diff = 0
for i in range(n):
  if i % 2 == 0:
    diff += num[i]
  else:
    diff -= num[i]
print(diff)

Submission status: Runtime Error

Solution code:
# coding=utf-8
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)  
alice=a[::2]　　
bob=a[1::2]　　　
print(sum(alice)-sum(bob))

Submission status: Runtime Error

Solution code:
num = []
A = 0
B = 0
for i in range(int(input())):
    num.append(int(input()))
num = sorted(num)
while num != []:
    A += pop(num[0])
    if num != []:
        B += pop(num[0])

print(A - B)

Submission status: Runtime Error

Solution code:
n=int(input())
a = [int(i) for i in input().split()] 
A=0
B=0
C=0
k=0
for i in range(n):
  if i%2==0:
    k=max(a)
    A += k
    del a(a.index(k))
  else :
    k=max(a)      
    B += k
    del a(a.index(k))   
  
C=A-B          
print(C)

Submission status: Runtime Error

Solution code:
n=int(input())
a = [int(i) for i in input().split()] 
A=0
B=0
C=0
k=0
for i in range(n):
  if i%2==0:
    k=max(a)
    A += k
    del a(a.index(k)
  else :
    k=max(a)      
    B += k
    del a(a.index(k)      
  
C=A-B          
print(C)

Submission status: Runtime Error

Solution code:
n=int(input())
a = [int(i) for i in input().split()] 
A=0
B=0
C=0
for i in range(n):
  if i%2==0:
    A += max(a)
    del a(a.index(max(a))
  else :
    B += max(a)
    del a(a.index(max(a))      
  
C=A-B          
print(C)

Submission status: Runtime Error

Solution code:
n=int(input())
a = [int(i) for i in input().split()] 
A=0
B=0
for i in range(n):
  if i%2==0:
    A += max(a)
    del a(a.index(max(a))
  else :
    B += max(a)
    del a(a.index(max(a))      
          
print(A-B)

Submission status: Runtime Error

Solution code:
n = int( input())
a = sorted(  list(map(int, input().split())) , reverse)
print((sum(a[::2])-sum(a[1::2]))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
alice = 0
bob = 0
for i in range(1,n+1):
  if i%2==1:
    alice += max(a)
    del max(a)
  else:
    bob += max(a)
    del　max(a)

Submission status: Runtime Error

Solution code:
n = input()
input_list = list(map(int, input().split()))
input_list.sort(reverse=True)
# aliceは奇数番目のものを、bobは偶数番目のものをとる
alice = 0
bob = 0
for i in range(n):
    if (i+1) % 2 == 1:
        alice += input_list[i]
    else:
        bob += input_list[i]
print(alice - bob)

Submission status: Runtime Error

Solution code:
input()
a = list(map(int,input().split()))
a.sorted()
print(sum(a[::2])-sum(a[1::2]))

Submission status: Runtime Error

Solution code:
n = int(input())
numbers = list(map(int,input().split()))
alice = 0
bob = 0
numbers = numbers.sort(reverse=True)
for i in range(n):
    if i%2 == 0:
        alice += numbers[i]
    else:
        bob += numbers[i]
ans = alice - bob
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))

a.sort(reversed=True)

for i in range(N):
    Alice = 0
    Bob = 0
    if N % 2 == 0:
        Alice += list[i]
    else:
        Bob += list[i]

print("{}".format(Alice - Bob))

Submission status: Runtime Error

Solution code:
N = int(input())
num = list(map(str, input().split()))
num.sort(reverse=True)
print(sum(num[0::2])-sum(num[1::2]))

Submission status: Runtime Error

Solution code:
N = int(input())
num = list(map(str, input().split()))
num.sort(reverse=True)
print(sum(num[::2])-sum(num[1::2]))

Submission status: Runtime Error

Solution code:
import numpy as np
n= int(input())
a_list = sorted(list(map(int, input().split())),reverse=True)
a_array = np.array(a_list)
alice = a_array[::2]
bob = a_array[1::2]
print(sum(alice-bob))

Submission status: Runtime Error

Solution code:
_ = input()
card_list = sorted(input().split())[::-1]
print(sum(card_list[::2])-sum(card_list[1::2]))

Submission status: Runtime Error

Solution code:
N = int(input())
A = sorted(map(int, input().split()))
print(A[::2]-A[1::2])

Submission status: Runtime Error

Solution code:
n=int(input())
a=(int(x) for x in input().split())
a.sort(reverse=True)
alice=0
bob=0
for i in range(0,n,2):
  alice+=a[i]
for i in range(1,n,2):
  bob+=a[i]
print(alice-bob)

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(map(int,input().split())) 
li.sort(reverse = True)
a,b = 0,0
while li:
    a += li.pop(0)
    b += li.pop(0)
print(a-b)

Submission status: Runtime Error

Solution code:
a=sorted(list(int(input()) for _ in range(int(input()))),reverse=True)
print(sum(a[::2])-sum(a[1::2]))

Submission status: Runtime Error

Solution code:
n = input()
lst = sorted([int(x) for x in input().split()], reverse=True)
alice = 0
bob = 0
for i in range(len(lst)):
    if i%2:
        bob += lst[I]
    else:
        alice += lst[i]
print(alice-bob)

Submission status: Runtime Error

Solution code:
n = input()
lst = sorted([int(x) for x in input().split()], reverse=True)
alice = 0
bob = 0
while len(lst)>0:
    alice += lst.pop(0)
    bob += lst.pop(0)
print(alice-bob)

Submission status: Runtime Error

Solution code:
n = input()
lst = [int(x) for x in input().split()].sort()
alice = 0
bob = 0
while len(lst)>0:
    alice += lst.pop(0)
    bob += lst.pop(0)
print(alice-bob)

Submission status: Runtime Error

Solution code:
n = input()
lst = [int(x) for x in input().split()].sort()
alice = 0
bob = 0
while len(lst):
    alice += lst.pop(0)
    bob += lst.pop(0)
print(alice-bob)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
A = []
B = []

while len(a) > 0:
	A.append(max(a))
	a.remove(max(a))
	B.append(max(a))
	a.remove(max(a))

print(sum(A) - sum(B))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))

a.sort(reversed=True)
score = [0, 0]
for i in range(n):
    score[i%2] += a[i]

print(score[0] - score[1])

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))

a.sort(reversed=True)
score = [0, 0]
for i in range(n):
    score[i&2] += a[i]

print(score[0] - score[1])

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))

alice = []
bob = []

while A != []:
	alice.append(max(A))
	A.remove(max(A))
	bob.append(max(A))
	A.remove(max(A))
	
print(sum(alice)-sum(bob))

Submission status: Runtime Error

Solution code:
N=int(input())
li=list(map(int,input().split()))
lis=list.sort(reverse=True)
lisAlice=lis[0::2]
lisbob=lis[1::2]
print(sum(lislalice)-sum(lisbob))

Submission status: Runtime Error

Solution code:
N = int(input())

a = sorted(map(int,input().split()))

a.reverse()

A = []
B = []

for x in range(0,N+1,2):
    A.append(a[x])
    
if N%2 == 1:
    for y in range(1,N,2):
        B.append(a[y])
        
    
else:
    for y in range(1,N+1,2):
        B.append(a[y])
    
    
    

    

print(sum(A)-sum(B))

Submission status: Runtime Error

Solution code:
N = int(input())

a = sorted(map(int,input().split()))

a.reverse()

A = []
B = []

for x in range(0,N+1,2):
    A.append(a[x])

for y in range(1,N,2):
    B.append(a[y])
    

print(sum(A)-sum(B))

Submission status: Runtime Error

Solution code:
n=int(input())
a=sorted(list(map(int,input().split()))[::-1]
print(sum(a[::2])-sum(a[1::2]))

Submission status: Runtime Error

Solution code:
n=int(input())
li=sorted[int(input()) for i in range(n)]
A=0
B=0
for k in range(n//2):
  A += li[2*k]
  B += li[2*k+1]
if n % 2 ==1:
  A += li[n-1]
print(B-A)

Submission status: Runtime Error

Solution code:
n=int(input())
li=sorted(list(map(int,input().split())))
a=0
b=0

for i in range(n):
  if i%0==0:
    a+=li[i]
  else:
    b+=li[i]

print(a-b)

Submission status: Runtime Error

Solution code:
n=int(input())
a=map(int,input().split())
sort_a=sorted(a)

alice = sum(sort_a[::2])
bob = sum(a[1::2])

print(alice - bob)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
a.sort()
Alice = 0
Bob = 0
for i in range(n):
  if i%2 == 0:
    Alice += A[i]
  else:
    Bob += A[i]
ans = Alice - Bob
print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
a=list(map(int,input()))
print(sum(a[::2])-sum(a[1::2]))

Submission status: Runtime Error

Solution code:
n = int(input())
a = map(int, input().split())
a.sort()

alice = 0
bob = 0

for i in range(1,n) :
  alice = alice + a[-i]
  bob = bob + a[-(i+1)]

print(alice - bob)

Submission status: Runtime Error

Solution code:
N = int(input())
a = sorted(list(map((int, input().split())), reverse=True))
A = 0
B = 0
for i in range(N):
    if i % 2 == 0:
        A += a[i]
    else:
        B += a[i]

print(A - B)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
alice = 0
bob = 0

a.sort()
for i in range(0, n, 2):
  alice += a[n-i]
  bob += a[n-i-1]

    
print(alice-bob)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
alice = 0
bob = 0

while a != []:
  alice += max(a)
  a.remove(max(a))
  bob += max(a)
  try:
    a.remove(max(a))
  except:
    break
    
print(alice-bob)

Submission status: Runtime Error

Solution code:
n = int(input())
c = list(map(int, input().split()))
c.sort(reverse=True)
a = sum([v for i, v in enumerate(c) if i % 2 == 0 ]
b = sum([v for i, v in enumerate(c) if i % 2 == 1 ]
print(a - b)

Submission status: Runtime Error

Solution code:
n = int(input())
c = list(map(int, input().split()))
c.sort(rexerse=True)
a = sum([v for i, v in enumerate(c) if i % 2 == 0 ]
b = sum([v for i, v in enumerate(c) if i % 2 == 1 ]
print(a - b)

Submission status: Runtime Error

Solution code:
N = int(input())
A = map(int, input().split())

sorted_A = A.sort().reverse()

alice = 0
bob = 0
for index, point in sorted_A:

  # Alice
  if (index + 1) % 2 == 0:
    alice = alice + point
  
  # Bob
  else:
    bob = bob + point

answer = alice - bob

print(answer)

Submission status: Runtime Error

Solution code:
from itertools import zip_longest


def main():
    _, *a = map(int, open(0))
    a = sorted(a, reverse=True)
    print(sum(i - j for i, j in zip_longest(*[iter(a)]*2, fillvalue=0)))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
li = []
a = []
b = []
for i in range(N):
  li.append(int(input()))
li.sort(reverse = True)
for i in li[0::2]:
  a.append(i)
for i in li [1::2]:
  b.append(i)
print(sum(a) - sum(b))

Submission status: Runtime Error

Solution code:
n = int(input())
a = input()

a = a.split()


for i in range(n):
	a[i] = int(a[i])
	
a = a.reverse()

alice = int(a[0])
bob = 0
for i in range(1, n):
	if i%2 == 0:
		alice = alice + int(a[i])
	else:
		bob = bob + int(a[i])
	
print(alice - bob)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input()

a = a.split()

alice = 0
bob = 0
ans = 0

for i in range(n):
	a[i] = int(a[i])

a = a.reverse()

for i in range(n):
	if i%2 == 0:
		alice = alice + int(a[i])
	else:
		bob = bob + int(a[i])
	
print(alice - bob)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int,input().split()))
a.sort(reverse==True)
ans = 0
for i in range(N):
  if(a%2==0):
    ans += a[i]
  else:
    ans-=a[i]

Submission status: Runtime Error

Solution code:
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2]-sum(a[1::2])))

Submission status: Runtime Error

Solution code:
N = int(input())
cards = list(map(int, input().split()))

alice = 0
bob = 0
for i in range(N+1):
  if i % 2 == 0:
    alice += cards[i]
  else:
    bob += cards[i]

print(alice-bob)

Submission status: Runtime Error

Solution code:
n = int(input())

a = sorted(list(map(int, input().split())), reversed=True)
ans = sum(a[::2]) - sum(a[1::2])
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))

A.sort(resverse = True)

print(sum(A[0::2]) - sum(A[1::2]))

Submission status: Runtime Error

Solution code:
input()
a=sorted(map(int, input().split()))[::-1]
print(sum(a[::2]-sum(a[1::2]))

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))

a.sort(reverse="True")

print(sum(a[0::2]) - sum(a[1::2]))

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    N = int(input())
    A = [None]*N
    A = list(map(int, input().split()))
    Alice = 0
    Bob = 0
    while(A):
        Alice += max(A)
        A.remove(max(A))
        Bob += max(A)
        A.remove(max(A))
    print(Alice - Bob)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=TRUE)
print(sum(A[0::2]) - sum(A[1::2]))

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]

Alice = []
Bob = []

for i in range(N):
    if len(A) != 0:
        Alice.append(max(A))
        A.remove(max(A))
    else:
        break
    if len(A) != 0:
        Bob.append(max(A))
        A.remove(max(A))
    else:
        break
print(sum(Alice) - sum(Bob))

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())), reverse=True)
print(sum(a[::2]) - sum(a[1::2])

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted(list(map(int,input().split()))), reverse=True)
print(sum(a[::2]) - sum(a[1::2])

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
b,c=0,0
for i in range(n):
    if i%2==0:
        b+=a[-i]
    else:
        c+=a[-i]
print(b-a)

Submission status: Runtime Error

Solution code:
N = int(input())
 
if N%2 == 0:
  print(N/2)
else:
  print([N+1] / 2)

Submission status: Runtime Error

Solution code:
_ = input()
l = list(map(int,input().split()))
l.sort()
l.reverse()
print(sum(l[::2]-sum(l[1::2])))

Submission status: Runtime Error

Solution code:
a_total, b_total = 0,0
for k in range(N):
    m = max(a)
    if k%2==0:
        a_total += m
    else:
        b_total += m
    a.remove(max(a))
print(a_total-b_total)

Submission status: Runtime Error

Solution code:
N = int(input())
A = map(int, input().split()).sort()

Alice = 0
Bob = 0
for i, v in enumerate(A[::-1]):
	if i % 2 == 0:
      Alice += v
    else:
      Bob += v
print(Alice - Bob)

Submission status: Runtime Error

Solution code:
N = int(input())
data = list(map(int,input().split()))

Alice = []
Bob = []

while N != 0:
        Alice.append(max(data))
        data.remove(max(data))
        if len(data) == 0:
                break
        else:
                Bob.append(max(data))
                data.remove(max(data))
        N -= 1

print(sum(Alice)-sum(Bob))

Submission status: Runtime Error

Solution code:
n = int(input())
cards = list(sorted(map(int, input()), reverse=True))

a = sum(cards[0::2])
b = sum(cards[1::2])

print(a - b)

Submission status: Runtime Error

Solution code:
N = int(input())
D.sort(reverse = True)
A = []
B = []
for i in range(N):
    if i%2==0:
        A.append(D[i])
    else:
        B.append(D[i])
 
print(sum(A)-sum(B))

Submission status: Runtime Error

Solution code:
N = int(input())
D.sort(reverse = True)
A = []
B = []
for i in range(N):
    if i%2==0:
        A.append(D[i])
    else:
        B.append(D[i])

print(sum(A)-sum(B))

Submission status: Runtime Error

Solution code:
N=int(input())
a=list(map(int,input().split()))
a=sorted(a)
Alice=0
Bob=0
Alice_turn=0
for i in range(N):
  if Alice_turn%2==even:
    Alice+=a[N-1-i]
    Alice_turn+=1
  else:
    Bob+=a[N-1-i]
print(Alice-Bob)

Submission status: Runtime Error

Solution code:
n = int(input())
nums = [int(i) for i in input().split()]

nums.sort_values(reverse=True)
print(sum(nums[0::2]) - sum(nums[1::2]))

Submission status: Runtime Error

Solution code:
n = int(input())
l = sorted(map(int, input().split()), reverse = True)

alice = 0
bob = 0
ab = False
for i in l:
  if ab == False:
	alice += i
    ab = True
  else:
    bob += i
    ab = False
    
print(alice - bob)

Submission status: Runtime Error

Solution code:
n = int(input())
l = sorted(map(int, input().split()), reverse = True)

alice = 0
bob = 0
ab = False
for i in l:
  if ab = False:
	alice += i
  else:
    bob += i
    
print(alice - bob)

Submission status: Runtime Error

Solution code:
N = input()
a = [int(i) for i in range(N)]
a_sorted = sorted(a)
diff = 0
for i in range(N/2):
   diff =  a_sorted[2*i] - a_sorted[2*i + 1]
if(N%2 != 0):
    diff += a_sorted[N-1]
print(diff)