#Write and Erase

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

import collections
c = collections.Counter(A)

cnt = 0
for i in c.values():
    cnt += i%2
print(cnt)


import collections

N = int(input())

def mod2(n):
    a = n % 2
    return a

lis = []
for i in range(N):
    a = int(input())
    lis.append(a)

count = collections.Counter(lis)

print(sum(map(mod2, count.values())))


n = int(input())
h = set()
for i in range(n):
    a = int(input())
    if a in h:
        h.remove(a)
    else:
        h.add(a)
print(len(h))


n = int(input())
pool = []
ans = 0
for i in range(n):
    a = int(input())
    pool.append(a)
pool.sort()

ptr = 0
while ptr < len(pool):
    cc = pool[ptr]
    f = 0
    while ptr < len(pool) and pool[ptr] == cc:
        ptr += 1
        f += 1
    ans += f%2
print(ans)


from collections import defaultdict

n = int(input())
l = defaultdict(int)
for _ in range(n):
    a = input()
    l[a] += 1
ans = 0
for i in l.values():
    if i % 2 == 1:
        ans += 1
    else:
        pass
print(ans)


#ABC073C
import sys

n=int(raw_input())
dic={}
for i in xrange(n):
 a=int(raw_input())
 if a in dic:
  dic[a]^=1
 else:
  dic[a]=1

res=0
for i in dic:
 if dic[i]==1:
  res+=1
print res


N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

def customCount(idx):
    target = A[idx]
    cnt = 1
    idx += 1
    while True:
        if idx == N or A[idx] != target:
            return cnt
        else:
            idx += 1
            cnt += 1

index = 0
result = 0
while True:
    num = customCount(index)
    index += num
    if (num % 2) == 1:
        result += 1
    if N <= index:
        break
print(result)


#!/usr/bin/python3

n = int(input())

num = {}
for i in range(n):
    a = input()
    if a in num:
        num[a] += 1
    else:
        num[a] = 1

t = 0
for i in num.keys():
    if num[i] % 2:
        t += 1

print(t)


n = int(input().strip())

d = {}
for _ in range(n):
    a = int(input().strip())
    d[a] = not d.get(a, False)
total = 0
for v in d.values():
    if v:
        total += 1
print(total)


N = int(input())
from collections import defaultdict

paper_nums = defaultdict(lambda:int())
for _ in range(N):
  input_num = int(input())
  if input_num in paper_nums:
    paper_nums.pop(input_num)
  else:
    paper_nums[input_num]
print(len(paper_nums))


N = int(input())
s = set()
for i in range(N):
	a = input()
	if a in s:
		s.remove(a)
	else:
		s.add(a)
print(len(s))


from collections import Counter

N = int(input())
tell_list = [input() for _ in range(N)]
count = 0
tell_count = Counter(tell_list)
for num in tell_count.most_common():
    count += num[1] % 2
print(count)


#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

al = []

for i in range(n):
    a = raw_input()
    a = int(a)
    al.append(a)

al.sort()

num = 0

i = 0
while i < n:
    if i == n-1:
        num += 1
        break
    if al[i] == al[i+1]:
        i += 2
    else:
        num += 1
        i += 1

print num


N=int(input())
A=set()
for i in range(N):
    a=int(input())
    if a not in A:
        A.add(a)
    else:
        A.remove(a)
print(len(A))


from collections import defaultdict

def main():
    d = defaultdict(lambda: 0)
    n = int(input())
    for _ in range(n):
        x = int(input())
        d[x] += 1

    cnt = 0
    for key, value in sorted(d.items(), key=lambda x: x[1], reverse=True):
        if value%2 == 1:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()


N = int(input())
s = set()
for i in range(N):
  A = int(input())
  if A not in s:
    s.add(A)
  else:
    s.remove(A)
print(len(s))


# coding: utf-8
def get_ln_inputs():
    return input().split()

def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))

def main():
    N = get_ln_int_inputs()[0]
    A = list()
    for _ in range(N):
        A.append(get_ln_int_inputs()[0])

    res = {}
    for a in A:
        if not a in res:
            res[a] = 1
        else:
            del res[a]
    print(len(res))
    return

main()


from collections import defaultdict
n = int(input())
dd=defaultdict(int)
for _ in range(n):
    a=input()
    dd[a]+=1
    dd[a]%=2
ans=0
for k in dd.keys():
    if dd[k]==1:
        ans+=1
print(ans)


N = int(input())
s = set()
for i in range(N):
    A = input()
    if A in s:
        s.remove(A)
    else:
        s.add(A)
print(len(s))


from collections import defaultdict
lst= defaultdict(bool)
for i in range(int(input())):
    t = input()
    lst[t] = not lst[t]

print(len([x for x in lst if lst[x]]))


d={}
for i in range(input()):a=input();d[a]=d.get(a,0)+1
print len(filter(lambda x:x%2,map(lambda x:d[x],d)))


n = int(input())

f = {}
for i in range(n):
    a = int(input())
    if not f.get(a):
        f[a] = True
    else:
        f[a] = None

print(sum(1 for i in f if f[i]))


ans=set()
N=int(input())
for i in range(N):
 l=input()
 if l in ans:
  ans.remove(l)
 else:
  ans.add(l)
print(len(ans))


import sys

written = set()

N = int(sys.stdin.readline())

for i in range(N):
    tmp = int(sys.stdin.readline())
    if tmp in written:
        written.remove(tmp)
    else:
        written.add(tmp)
print(len(written))


# coding: utf-8
dic = {}
for i in range(int(input())):
    s = input()
    if s in dic:
        dic[s] = (dic[s] + 1) % 2
    else:
        dic[s] = 1
ans = 0
for n in dic.items():
    if n[1] == 1:
        ans += 1
print(ans)


from collections import Counter
n=int(input())
a=[int(input()) for i in range(n)]
ans=0
for k,v in Counter(a).items():
    if v%2!=0:
        ans+=1
print(ans)


#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        N = int(line)
        sheet = set()
        for i in xrange(N):
            a = sys.stdin.readline()
            if a in sheet:
                sheet.remove(a)
            else:
                sheet.add(a)
        print(len(sheet))
        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)


from collections import defaultdict, Counter
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10

def main():
    N = int(input())
    c = Counter([int(input()) for _ in range(N)])
    ans = 0
    for k, v in c.items():
        ans += v % 2 != 0
    print(ans)

if __name__ == '__main__':
    main()


N = int(input())
x = [int(input()) for i in range(N)]

x.sort()
i=0
while i < N-1:
    if x[i]==x[i+1]:
        del x[i+1]
        del x[i]
        N-=2
        continue
    i+=1
print(len(x))


N = int(input())

a = {}
for i in range(N):
    a_i = int(input())
    if a_i in a:
        del a[a_i]
    else:
        a[a_i] = 1

print(len(a))


n = int(input())

moji = set()
for i in range(n):
    a = int(input())
    if a in moji:
        moji.remove(a)
    else:
        moji.add(a)

print(len(moji))


def main():
    N = int(input())
    A = tuple(int(input()) for _ in range(N))

    num = dict()
    for n in A:
        num[n] = num.get(n, 0) + 1

    ans = 0
    for v in num.values():
        ans += v % 2

    print(ans)

main()


N = int(input())
list1 = [int(input()) for i in range(N)]

dict2 = {}
for i in list1:
    if(i in dict2):
        dict2[i] += 1
    else:
        dict2[i] = 1

count = 0;
for i in dict2.values():
    if i % 2 == 1:
        count += 1
print(count)


from collections import Counter
N = int(input())
src = [int(input()) for i in range(N)]
counter = Counter(src)

ans = 0
for v in counter.values():
    if v%2 == 1:
        ans += 1
print(ans)


n=input()
s={}
for i in range(n):
    tmp=input()
    if tmp in s:
        del s[tmp]
    else:
        s[tmp]=1
print len(s)


N = int(input())

a = []
for i in range(N):
    a.append(int(input()))

a.sort()

cnt2 = 0
cnt = 1
ans = 0
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        cnt += 1
    else:
        ans += cnt%2
        cnt = 1
        flg = False

ans += cnt%2
print(ans)


n = int(input())

array = []
for i in range(n):
	a = int(input())
	array.append(a)

array.sort()
last = -1
count = 0
ans = 0

for i in range(len(array)):
	if last != array[i]:
		if count % 2 == 1:
			ans += 1

		count = 1
	else:
		count += 1

	last = array[i]

if count % 2 == 1:
	ans += 1

print(ans)


as_ = set()
for _ in range(int(input())):
    a = int(input())
    if a in as_:
        as_.remove(a)
    else:
        as_.add(a)

print(len(as_))


#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
from collections import Counter

n = int(raw_input())
dat = map(int, [raw_input() for _ in xrange(n)])
cnt = Counter(dat)
res = sum(v & 1 for v in cnt.values())
print res


from collections import Counter
n = int(raw_input())
c = Counter([int(raw_input()) for _ in range(n)])
print len(filter(lambda x: x % 2 == 1, c.values()))


d={}
for i in range(input()):a=input();d[a]=d.get(a,0)+1
print len(filter(lambda x:x%2,map(lambda x:d[x],d)))


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    n = I()
    s = set()
    for _ in range(n):
        a = I()
        if a in s:
            s.remove(a)
        else:
            s.add(a)

    return len(s)

print(main())


N = int(input()) #1行目のNを取得
l = [int(input()) for i in range(N)] #N回繰り返し s に値を取得

l.sort()

a=0
ans=0
for i in l:
	if i==a:
		ans -= 1
		a=0
	else:
		ans += 1
		a=i

print(ans)


N = int(input())
ans = set()
for i in range(N):
    num = int(input())
    if num in ans:
        ans.remove(num)
    else:
        ans.add(num)
print(len(ans))


N = int(input())
seq = {}

for i in range(N):
    a = input()
    try:
        seq[a] = (seq[a] + 1) % 2
    except KeyError:
        seq[a] = 1

print(list(seq.values()).count(1))


n = input()

dic = {}

for i in range(n):
    a = input()
    if a not in dic:
        dic[a] = 1
    elif dic[a] == 0:
        dic[a] = 1
    else:
        dic[a] = 0

keys = dic.keys()
ct = 0
for i in keys:
    if dic[i] > 0:
        ct += 1

print ct


#coding:utf-8

N = int(input())
nums = set()

for i in range(N):
    A = int(input())

    if A in nums:
        nums.remove(A)
    else:
        nums.add(A)
print(len(nums))


from collections import defaultdict
d = defaultdict(int)
n = int(raw_input())
for _ in range(n):
    d[int(raw_input())] += 1
c = 0
for v in d.values():
    if v % 2 == 1:
        c += 1
print c


#!/user/bin/python
# coding: UTF-8

n = int(raw_input())
a = int(raw_input())

s = n*n - a

print s


#入力
N = int(input())
A = int(input())
#ますの数を数える
N = N * N
#ますの数から白に塗る部分を引いて黒の文をだす
Black = N  - A
#出力
print(Black)


N = int(input())
A = int(input())
print(N*N-A)


import numpy as np

N = int(input())
A = int(input())

print(N**2 - A)


def count_black(N, A):
    return N**2 - A

N = int(raw_input())
A = int(raw_input())

print(count_black(N, A))


N = int(input())
A = int(input())

print(N*N - A)


n = int(input())
a = int(input())
ans = n ** 2 - a
print(ans)


# coding: utf-8
N = int(input())
A = int(input())
print((N * N) - A)


# -*- coding: utf-8 -*-
"""A - Bichrome Cells"""

n = int(raw_input())
a = int(raw_input())

print n * n - a


n = int(raw_input())
a = int(raw_input())
x = n*n - a
print x


n = int(input())
A = int(input())
print(n **2 - A)


N = int(input())
A = int(input())
result = N**2 - A
print(str(result))


#Source code should be longer than 50 chars so I am writing this line
n=int(input())
a=int(input())
print((n*n)-a)


if __name__ == '__main__':
    N = input()
    A = input()

    print (N*N - A)


N = int(input())
A = int(input())

S = N * N

ANS = A - S
ANS = abs(ANS)

print (ANS)


import sys

# sys.stdin = open('a1.in')

def read_int_list():
    return list(map(int, input().split()))

def read_str_list():
    return input().split()

def read_int():
    return int(input())

def read_str():
    return input()

def main():
    n = read_int()
    a = read_int()
    res = n * n - a
    print(res)

main()


n = input()
a = input()

print  n ** 2 - a


N = int(input())
A= int(input())

ans=N*N-A

print(ans)


if __name__ == "__main__":
    N = int(input())
    A = int(input())
    print(N * N - A)


N = int(input())

A = int(input())

print(str(N**2-A))


(lambda N, A: print(N * N - A))(int(input()), int(input()))


# -*- coding=utf-8 -*-
# マス目の合計
square_number = int(input()) ** 2
# 白に塗るマス目の数
white_paint = int(input())

# 黒に塗るマス目の数
print(square_number - white_paint)


n = int(input())
a = int(input())

print(n**2 - a)


n = int(input())
m = int(input())

print(n * n - m)


N = int(input())
A = int(input())

print(N*N - A)


N = int(input())
A = int(input())

print(N ** 2 - A)


N = int(input())
a = int(input())
print (N *N - a)


n = int(input())
a = int(input())
print(n**2 - a)


N = int(input())
A = int(input())
print(N*N-A)


def main():
    N = int(input())
    A = int(input())
    print(N*N-A)

if __name__=='__main__':
    main()


def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, = read_line(int)
a, = read_line(int)

print(n * n - a)


N = int(input())
A = int(input())
T = N ** 2 - A
if N<100 :
    print(T)
else :
    print(0)


n = int(input())
a = int(input())
check = n*n
black = check - a
print(black)


from sys import  stdin
n = int(stdin.readline())
a = int(stdin.readline())
print n*n-a


def main():
    N = int(input())
    M = int(input())

    print (N**2-M)

if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()


N = int(input())
A = int(input())
print(N * N - A)


N = int(input())
A = int(input())
print(N**2-A)


N = int(input())
A = int(input())
print(N*N - A)


def main():
    N = int(input())
    A = int(input())

    print(N ** 2 - A)

if __name__ == '__main__':
    main()


N=int(input())
A=int(input())

print(N*N-A)


a = int(input())
b = int(input())
print(a*a-b)


N = int(input())
A = int(input())
print(N**2 - A)


N = int(input())
A = int(input())

ans = (N*N)-A
print(ans)


n= int(input())
a= int(input())
print(n*n-a)


n = int(input())
a = int(input())
print(n*n - a)


input1 = int(input())
input2 = int(input())

print (input1*input1 - input2)


n = input()
a = input()
n = int(n)
a = int(a)

print(n**2-a)


n=int(input())
m = int(input())
print(n**2 - m)


n = int(input())
a = int(input())
print(n*n-a)


N = int(input())
A = int(input())
T = N ** 2 - A
if N<=100 :
    print(T)
else :
    print(0)


a=int(input())
b=int(input())

print(a*a-b)


n = int(input())
a = int(input())

print(n*n-a)


import sys

N = int(sys.stdin.readline())
A = int(sys.stdin.readline())
print(N*N - A)


n = int(input())
a = int(input())
print((n * n - a))


if __name__ == '__main__':

    N = int(input())
    A = int(input())
    print(N*N - A)


n = int(input())
a = int(input())

print(n * n - a)


N,A = input(),input()

ans = N*N-A
print(ans)


N = int(input())
A = int(input())
print(N*N - A)


N = int(input())
A = int(input())
print(N**2-A)


N = int(input())
A = int(input())

print(N**2 - A)


n = int(input())
m = int(input())
print( n*n - m )


N = raw_input()
N = int(N)
A = raw_input()
A = int(A)

print(N*N-A)


N = int(input())
A = int(input())

print(N*N-A)


print((int(input()) ** 2) - int(input()))


n = int(input())
a = int(input())

print(n**2 - a)


# coding: utf-8
def get_ln_inputs():
    return input().split()

def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))

def main():
    N = get_ln_int_inputs()[0]
    A = get_ln_int_inputs()[0]
    print(N * N - A)
    return

main()


def main():
    N = int(input())
    A = int(input())

    ans = N ** 2 - A
    print(ans)

main()


# -*- coding: utf-8 -*-

N = int(input())
A = int(input())

print(N**2-A)


# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc074/tasks/abc074_a

"""
import sys
from sys import stdin
input = stdin.readline

def main(args):
    N = int(input())
    A = int(input())
    print(N**2 - A)

if __name__ == '__main__':
    main(sys.argv[1:])


#!/usr/bin/python3

n = int(input())
a = int(input())

print(n ** 2 - a)


n=int(input())
x=int(input())

print(n*n-x)


#python3
#@author-SK13

n= int(input())
a= int(input())
print(n*n-a)


n = int(raw_input())
a = int(raw_input())
print n*n-a


N = int(input())
A = int(input())
ans = N ** 2 - A
print(ans)


#coding:utf-8

N = int(input())
A = int(input())

print(N * N - A)


N = int(input())
A = int(input())
print(N ** 2 - A)


n = int(input())
a = int(input())

print(n * n - a)


def main():
    n = int(input())
    a = int(input())
    print(n*n-a)

if __name__ == "__main__":
    main()


N=input()
N=int(N)
A=input()
A=int(A)
print((N**2)-A)


import sys

def main():
    N = int(input())
    A = int(input())
    black = N**2-A
    print(black)

if __name__=='__main__':
    main()


import sys

# utils
def read_numbers():
    return [int(num) for num in sys.stdin.readline().split()]
def read_string():
    return sys.stdin.readline().rstrip('\r\n')
def list2str(*array):
    return ' '.join([str(i) for i in array])

def main(N, A):
    return N*N - A

def parse_stdin():
    # N = read_numbers()
    # data = []
    # for i in range(N):
    #    data.append(read_numbers())
    N = read_numbers()[0]
    A = read_numbers()[0]
    return N, A

def test_main():
    """run pytest stdin.py to test"""
    #assert main([1,2], 'hi') == '3 hi'
    pass

if __name__ == '__main__':
    N, A = parse_stdin()
    result = main(N, A)
    print(result)


N = int(input())
A = int(input())
print(N**2 - A)


n=int(input())
a=int(input())
result=n*n-a
print(result)


# -*- coding: utf-8 -*-

n = int(input())
a = int(input())

result = n * n - a
print(result)


N = int(input())

A = int(input())

print(N * N - A)


# coding: utf-8

n = input()
a = input()

print n**2-a


N = int(input())
A = int(input())
print(N**2-A)


a = [int(input()) for i in range(2)]
print(a[0] ** 2 - a[1])


use = int(input())
use1 = int(input())

print(use ** 2 - use1)


if __name__ =='__main__':
    N = int(input())
    A = int(input())
    ans = N**2-A
    print(ans)


# coding: utf-8
# Here your code !
N=int(input().rstrip())
A=int(input().rstrip())
print((N**2)-A,flush=True)


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")

def main():
    N = int(input())
    A = int(input())
    print(N * N - A)

if __name__ == '__main__':
    main()


a = int(raw_input())
b = int(raw_input())
print a*a-b


#ABC074A
n=int(raw_input())
a=int(raw_input())
print n*n-a


def main():
    n = int(input())
    a = int(input())
    print(n*n-a)

if __name__ == "__main__":
    main()


N = int(input())
A = int(input())
T = N ** 2 - A
if N<100 :
    print(T)
else :
    print(0)


N = int(input())
w = int(input())

print(N**2-w)


N = int(input())
K = int(input())
x = map(int, input().split())
x = list(x)
ans = 0
for i in range(N):
    s = K - x[i]
    if(x[i] > s):
        ans += s
    else:
        ans += x[i]

print(ans * 2)


def main():
    N=int(input())
    K=int(input())
    x=[int(i) for i in input().split()]
    ans=0
    for i in x:
        ans+=2*min(K-i,i)
    print(ans)

if __name__=='__main__':
    main()


N=input()
K=input()
x=map(int,raw_input().split())
print sum(min(t,abs(K-t))for t in x)*2


N = int(input())
K = int(input())
x = list(map(int, input().split()))
ans = 0
for n in range(N):
    if x[n] * 2 <= K:
        ans += x[n]*2
    else:
        ans += (K - x[n])*2
print(ans)


N=(int)(input())
K=(int)(input())
x=(input()).split(' ')
result=0

for i in x:
    result+=2*min((int)(i),abs((int)(i)-K))

print(result)


n = int(input())
k = int(input())
x = list(map(int, input().split()))
ans = 0

for ball in x:
    ans += min(abs(ball*2), abs(ball-k)*2)

print(ans)


N = int(input())
K = int(input())
Ball = list(map(int,input().split()))
sumA = 0
sumB = 0

def SUMa(i):
    sumA = Ball[i]*2
    return sumA
def SUMb(i):
    sumB = (K-Ball[i]) *2
    return sumB

goukei = 0
for i in range(0,N):
    if SUMa(i) > SUMb(i):
        goukei += SUMb(i)
    else:
        goukei += SUMa(i)

print(goukei)


# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc074/tasks/abc074_b

"""
import sys
from sys import stdin
input = stdin.readline

def main(args):
    N = int(input())
    K = int(input())
    balls = [int(x) for x in input().split()]

    total_step = 0
    for b in balls:
        step_a = 2 * b
        step_b = 2 * abs(K - b)
        step = min(step_a, step_b)
        total_step += step

    print(total_step)

if __name__ == '__main__':
    main(sys.argv[1:])


n = int(input())
k = int(input())
x = list(map(int, input().split()))
d = 0
for i in x:
    d += min(i, k-i) * 2

print(d)


# -*- coding:utf-8 -*-
N = int(input())
K = int(input())
x = list(map(int, input().split()))
ans = 0
for tmp in range(N):
    ans += min(x[tmp]*2, abs(K-x[tmp])*2)
print(ans)


N = int(input())
K = int(input())
x = list(map(int, input().split()))

ans = 0

for i in range(N):
    a_dis = x[i] * 2
    b_dis = (K - x[i]) * 2
    ans += min(a_dis, b_dis)

print(ans)


N = input()
K = input()
x = map(int, raw_input().split())
print sum(2 * min(abs(K-x[i]), x[i]) for i in range(N))


N=input()
K=input()

x=map(int, raw_input().split())

l=0
for i in range(len(x)):

	if x[i] < abs(K-x[i]):
		l+=x[i]*2
	else:
		l+=abs(K-x[i])*2

print l


N = int(input())
K = int(input())
src = list(map(int, input().split()))

ans = 0
for i in range(N):
    d = min(src[i], K-src[i])
    ans += 2*d
print(ans)


import sys
N = int(input())
K = int(input())
X = list(map(int,input().split()))
ans = 0
for a in X:
    if abs(a-K) < a:
        ans += 2 * abs(a-K)
    else:
        ans += 2*a
print(ans)


import math
N,K=input(),input()
x = [int(_) for _ in raw_input().split()]
sum = 0

for i in range(N):
	if K < x[i]:
		sum += (x[i]-K)*2
	elif K/2 < x[i]:
		sum += (K-x[i])*2
	else:
		sum += x[i]*2
print(sum)


N = int(input())
K = int(input())
x = list(map(int,input().split()))
L = 0
for i in range(N):
  if K - x[i] >= x[i]:
    L += x[i]
  else:
    L += K -x[i]
print (2 * L)


n=input()
k=input()
a=map(int,raw_input().split())
dist=0
for i in xrange(n):dist+=2*min(a[i],k-a[i])
print dist


N = raw_input()
N = int(N)
K = raw_input()
K = int(K)
x = raw_input()
x = x.split(' ')
x = [int(d) for d in x]

sum_ = 0
for i in range(N):
	sum_ += 2*min(abs(x[i]-K),x[i])

print(sum_)


import math

def main():
  N = int(input())
  K = int(input())
  x_i = input().split()
  x_i = [ int(x) for x in x_i ]
  ans = 0

  for i in range(0, N):
    ans += 2 * min(math.fabs(x_i[i] - 0), math.fabs(x_i[i] - K))

  print(int(ans))

if __name__ == '__main__':
  main()


N = int(input())
K = int(input())
x = [int(i) for i in input().split()]

totalDist = 0
for i in range(N):
    choiceA = abs(0 - x[i]) * 2
    choiceB = abs(K - x[i]) * 2
    totalDist += min(choiceA,choiceB)
print(totalDist)


if __name__ == "__main__":
    N = int(input())
    K = int(input())
    xs = [int(s) for s in input().split(' ')]
    res = 0
    for i in range(N):
        res += min(xs[i], abs(K - xs[i])) * 2
    print(res)


N = int(input())
K = int(input())
x = list(map(int,input().split()))
sum = 0
for i in range(N):
    xl = x[i]
    xr = K-x[i]
    if xl<xr:
        sum += xl
    else:
        sum += xr
print(sum*2)


import math

n = int(input())
k = int(input())
x = list(map(int, input().split()))
l = 0

for i in range(n):
    l += min(x[i], k - x[i]) * 2

print(l)


#!/usr/bin/env python
# coding: utf-8

def main():
    n = int(input())
    k = int(input())
    xs = [int(x) for x in input().split()]
    move = 0
    for x in xs:
        move += 2 * min(x, abs(k-x))
    print(move)

if __name__ == '__main__':
    main()


n=int(input())
k=int(input())
x=input().split()
l=0

for i in range(n):
  if int(x[i]) <=abs(int(x[i])-k):
    l=l+2*int(x[i])
  else:
    l=l+2*abs(int(x[i])-k)
print(l)


N = int(input())
K = int(input())
X = list(map(int, input().split()))

S = 0
for i in range(N):
	S += 2 * min(X[i], K - X[i])

print(S)


N = int(input())
K = int(input())

xi = input().split()

if N != len(xi):
    print('err')
    exit()

sum = 0

for i in range(N):
    if int(xi[i]) >= K - int(xi[i]):
        add = K - int(xi[i])
    else:
        add = int(xi[i])
    sum += add * 2

print(sum)


N=int(raw_input())
K=int(raw_input())
x=map(int,raw_input().split(' '))

s=0
for i in range(N):
    s+=2*min(x[i],K-x[i])

print s


n = int(input())
k = int(input())
x = list(map(int, input().split()))
for i in range(n):
    if x[i] > k/2:
        x[i] = abs(x[i]-k)
ans = 0
for i in range(n):
    ans += 2*x[i]
print(ans)


def min(a,b):
	if(a<b):
		return a
	else:
		return b
n=int(input())
k=int(input())
l=list(map(int,input().split()))
ans=0
for val in l:
	ans+=2*abs(min(val,abs(k-val)))
print(ans)


N = int(input())
K = int(input())

x = input().split()

ans = 0
for i in range(N):
    ans += 2*min(int(x[i]), K-int(x[i]))

print(ans)


def main():
    N = int(input())
    K = int(input())

    x = [int(i) for i in input().split()]

    #print(N)
    #print(K)
    #print(x)

    sum_dis = 0
    for pos in x:
        min_dis = min(pos, K - pos) * 2
        sum_dis += min_dis

    print(sum_dis)

if __name__=="__main__":
    main()


N = int(input())
K = int(input())
x = [int(i) for i in input().split()]

ans = 0
for i in range(N):
    if(abs(K-x[i]) >= x[i]):
        ans += x[i]
    else:
        ans += abs(K-x[i])

print(ans*2)


import sys

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())

def main():
    n = I()
    k = I()
    xs = LI()

    r = 0
    for x in xs:
        r += 2*min(k-x, x)

    return r

print(main())


N = int(input())
K = int(input())
X = list(map(int,input().split()))

s=0
for x in X:
   s += min(x,abs(K-x))
print(2*s)


n = int(input())
k = int(input())
x = list(map(int, input().split()))

ans = 0
for i in x:
    ans += 2 * min(abs(i), abs(i - k))
print(ans)


N = int(input())
K = int(input())
x = list(map(int, input().split()))
print(2*sum([min(a, K-a) for a in x]))


n = int(raw_input())
k = int(raw_input())
xl = map(int, raw_input().split())
total = 0
for x in xl:
    if x > k / 2:
        total += (k - x) * 2
    else:
        total += x * 2
print total


def main():
    n = int(input())
    k = int(input())
    print(sum([2*min(k-int(i), int(i)) for i in input().split()]))

if __name__ == "__main__":
    main()


N = int(input())
K = int(input())
x = tuple(map(int,input().split()))
result = 0

for n in x:
    result += min(n, K-n) * 2

print(result)


n=int(input())
k=int(input())
x=list(map(int,input().split()))
ans=0
for i in x:
  ans += min(i,k-i)*2
print(ans)


N = input()
K =input()
x =input().split()
c =0
for i in range(0,int(N)):
    a = int(x[i])
    b = int(K)-int(x[i])
    c = c + 2*min(abs(a),abs(b))
print(c)


def B_CollectingBalls(N, K, x):
    ans = 0
    for i in range(0, N):
        dist = min(abs(x[i]), abs(x[i] - K)) * 2
        ans += dist
    return ans

N=int(input())
K=int(input())
x=[int(i) for i in input().split()]
print(B_CollectingBalls(N, K, x))


n = input()
k = input()
x = map(int, raw_input().split())

ans = 0

for i in x:
    if i < k - i:
        ans += i * 2
    else:
        ans += (k - i) * 2

print ans


N = int(input())
K = int(input())
X = map(int, input().split())

ret = 0
for x in X:
    ret += min(x, K - x) * 2

print(ret)


#!/usr/bin/python3

n = int(input())
k = int(input())
x = list(map(int, input().split()))

d = 0
for i in x:
    d += min(i, k - i) * 2

print(d)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    K = int(input())
    X = list(map(int, input().split()))

    ans = 0
    for x in X:
        ans += 2 * min(x, K-x)

    print(ans)

if __name__ == "__main__": main()


N = int(input())
K = int(input())

x = list(map(int, input().split()))

a = 0
for i in x:
    if float(i) <= (K / 2):
        a += i * 2
    elif float(i) > (K / 2):
        a += (K - i) * 2

print(a)


N = int(input())
K= int(input())
xlist = list(map(int, input().split()))

def Minl(x, K):
  l = abs(K - x)
  if l < x:
    return 2 * l
  else:
    return 2 * x

ans = 0
for x in xlist:
  ans = ans + Minl(x, K)

print(str(ans))


if __name__ == '__main__':
    N = int(input())
    K = int(input())
    x = list(map(int, input().split()))
    sum_half = 0
    for tmp_x in x:
        sum_half += min(tmp_x, K - tmp_x)

    print(sum_half * 2)


import numpy as np

N = int(input())
K = int(input())
x = [_ for _ in map(int, input().split())]
ans = 0
for i in range(N):
  ans += min(2 * x[i], 2 * (K - x[i]))
print(ans)


n, k = [int(input()) for _ in range(2)]
xi = [int(i) for i in input().split()]
dist = 0
for x in xi:
    l, m = [abs(k-x), abs(x)]
    dist += l*2 if l<m else m*2

print(dist)


n = int(input())
k = int(input())
a = list(map(int, input().split()))

print(sum(min(abs(k - i), i) * 2 for i in a))


N = int(input())
K = int(input())
x = list(map(int, input().split()))
print(2 * sum([min(x[i], abs(K - x[i])) for i in range(N)]))


r = lambda : map(int, raw_input().split())

n = r()[0]
k = r()[0]
a = r()

tot = 0

for x in a :
    val = min(x*2, abs(k-x)*2)
    tot += val

print tot


def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, = read_line(int)
k, = read_line(int)
xs = [int(x) for x in input().split()]

cost = 0
for x in xs:
    cost += min(x, k - x) * 2
print(cost)


N = int(input())
K = int(input())
X = list(map(int, input().split()))
res = 0

for i in range(N):
    res += min(X[i], K - X[i]) * 2

print(res)


N = int(input())
K = int(input())
X = [(int(j), i+1) for i, j in enumerate(input().split())]
A = [(0, a) for a in range(N+1)]
B = [(K, b) for b in range(N+1)]
cost = 0

for i,x_i in enumerate(X):
	cost += min(abs(x_i[0] - A[i][0])*2, abs(x_i[0] - B[i][0])*2)

print(cost)


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")

def main():
    N = int(input())
    K = int(input())
    x_list = list(map(int, input().split()))

    ans = 0
    for x in x_list:
        ans += min(abs(x - 0) * 2, abs(x - K) * 2)
    print(ans)

if __name__ == '__main__':
    main()


n = int(input())
k = int(input())
lis = list(map(int, input().split()))
ans = 0
for x in lis:
    ans += min(x, abs(x-k)) * 2
print(ans)


n=int(input())
k=int(input())
a=0
for x in [int(i) for i in input().split()]:
    a+=min(x,abs(k-x))
print(a*2)


N = int(input())
K = int(input())
x = list(map(int,input().split()))

res = 0

for i in range(N):
    res += 2*min(x[i]-0,abs(x[i]-K))

print(res)


n = int(input())
k = int(input())
x_list = input().split()
x_list = [int(x) for x in x_list]

goukei = 0
for x in x_list:
    if abs(0-x) > abs(k-x):
        goukei += 2*abs(k-x)
    else:
        goukei += 2*abs(x)

print(goukei)


# coding: utf-8
n,k=int(input()),int(input())
data=list(map(int,input().split()))
ans=0
for x in data:
    ans += min(x*2,(k-x)*2)
print(ans)


N = int(input())
K = int(input())
x = [int(i) for i in input().split()]
sum = 0

for i in range(0,N):
    sum += 2*min([abs(x[i]-K),x[i]])

print(sum)


N=int(input())
K=int(input())
x=list(map(int,input().split()))
ans=0
for i in range(N):
  ans+=min(x[i],abs(K-x[i]))
print(2*ans)


N = int(input())
K = int(input())
balls = [int(b) for b in input().split(' ')]

count = 0

for b in balls:
    if (2 * b < K):
        count += 2 * b
    else:
        count += 2 * (K - b)

print(count)


N = int(input())
K = int(input())
X = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += min(X[i], K - X[i]) * 2
print(ans)


N = int(input())
K = int(input())
x = list(map(int,input().split()))

res = 0
for i in range(N):
    res += (min(K - x[i], x[i])) * 2

print (res)


N = int(input())
K = int(input())
count = int(0)

data = list(map(int, input().split()))

for i in range(N):
    A = abs(data[i])
    B = abs(K - data[i])
    if A < B:
        count += A*2
    else:
        count += B*2

print(count)


import numpy as np
N = int(input())
K = int(input())
x = np.fromiter(map(int, input().split()), dtype=np.int)
A = x
B = np.abs(x - K*np.ones(N))
C = np.minimum(A,B)
print(int(C.sum()*2))


N = int(input())
K = int(input())
x = [(int(xi), i + 1) for i, xi in enumerate(input().split())]
A = [(0, i) for i in range(1, N+1)]
B = [(K, i) for i in range(1, N+1)]
print(sum([2*min(abs(x[i][0]-A[i][0]), abs(x[i][0]-B[i][0])) for i in range(N)]))


N = int(raw_input())
K = int(raw_input())
x = map(int, raw_input().split())
ans = 0
for i in xrange(N):
    ans += 2*min(x[i], abs(K - x[i]))
print ans


import sys

N = int(sys.stdin.readline())
K = int(sys.stdin.readline())
x = list(map(int, input().split()))

z = [2 * (K - i) if i > K/2 else 2 * i for i in x]
print(sum(z))


#ABC074B
n=int(raw_input())
k=int(raw_input())
x=map(int,raw_input().split())
res=0
for i in x:
 res+=2*min(i,k-i)
print res


# -*- coding: utf-8 -*-

n = int(input())
k = int(input())
x = list(map(int, input().split())) #x[0->(n-1)]

sum = 0

for i in x:
    if i < k - i:
        sum = sum + i
    else:
        sum = sum + k - i

print(sum*2)


N = int(input())
K = int(input())
X = list(map(int, input().split()))
Total_dist = 0

#iterate through number of bals
for i in range(N):
	dist = []
	for Rtype in ['A','B']:
		if Rtype == 'A':
			dist.append(abs(X[i] - 0)*2)
		if Rtype == 'B':
			dist.append(abs(X[i] - K)*2)
	Total_dist += min(dist)

print(Total_dist)


# -*- coding: utf-8 -*-
"""B - Collecting Balls (Easy Version)"""

n = int(raw_input())
k = int(raw_input())
x_list = map(int, raw_input().split())

ret = 0
for x in x_list:
    ret += min(x, k - x) * 2

print ret


N = int(input())
K = int(input())
listx = [int(_) for _ in input().split()]

counter = 0

for _ in listx:
    if abs(K - _) > _:
        counter += _*2
    else:
        counter += abs(K - _)*2

print(counter)


# coding: utf-8
# Here your code !
N=int(input().rstrip())
K=int(input().rstrip())
xi=map(int,input().rstrip().split())

idoSum=0

for x in xi:
    roboA=x*2
    roboB=abs(K-x)*2
    idoSum+=( roboB if( roboB < roboA) else roboA )
print(idoSum,flush=True)


N = int(input())
K = int(input())
data = input().split()

x = []
for i in range(N):
	x.append(int(data[i]))

sum = 0
for i in range(N):
	sum += min(x[i], K-x[i]) * 2

print(sum)


def main():
    N = int(input())
    K = int(input())
    X = tuple(map(int, input().split()))

    dist = 0
    for x in X:
        dist += min(x * 2, (K - x) * 2)
    print(dist)

main()


#coding:utf-8

N = int(input())
K = int(input())
x_list = map(int, input().split(" "))

dist = 0
for x in x_list:
    dist += 2 * min(x, K - x)
print(dist)


#!/user/bin/python
# coding: UTF-8

N = int(raw_input())
K = int(raw_input())
x = raw_input().split()
x = map(int, x)

n = 0

for i in xrange(N):
    if x[i] < K - x[i]:
        n = n + x[i] * 2
    else:
        n = n + (K - x[i]) * 2
print n


N=int(input())
K=int(input())
x=list(map(int,input().split()))
onewaysum=0
for i in range(N):
    if x[i]<=K-x[i]:
        onewaysum+=x[i]
    else:
        onewaysum+=K-x[i]
print(onewaysum*2)


def read_int_list():
    return list(int(i) for i in input().split())

n = int(input())
k = int(input())
x = read_int_list()

typeA=0
typeB=k
ans=0
for i in range(len(x)):
    ans += min(abs(x[i]-typeA),abs(x[i]-typeB))
print(ans*2)


#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()

    while line:
        N = int(line)
        K = int(sys.stdin.readline())
        X = map(int, sys.stdin.readline().rstrip("\n").split(" ", N))

        distance = 0
        for x in X:
            distance += min(x - 0, K - x) * 2
        print(distance)

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)


N = int(input())
K = int(input())
X = list(map(int,input().split(" ")))
print(2 * sum([min([X[i], K-X[i]]) for i in range(N)]))


if __name__ == "__main__":
    N = int(input())
    K = int(input())
    x = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        r = min(x[i],abs(K-x[i]))
        ans += 2*r
    print(ans)


n = int(input())
k = int(input())
l = list(map(int,input().split()))
s=0
for i in range(n):
    s+=min(l[i] - 0,k - l[i])
s*=2
print(s)


n=int(input())
k=int(input())
arr=list(map(int,input().split()))
ans=0
for a in arr:
    ans+=min(a,k-a)
print(ans*2)


N = int(input())
K = int(input())
x = list(map(int,input().split()))
length = 0
Khalf = K//2
for i in range(N):
	if x[i] <= Khalf:
		length += 2*x[i]
	else:
		length += 2*(K-x[i])
print(length)


n=int(input())
k=int(input())
x=list(map(int,input().split()))
ans=0
for i in range(n):
    ans+=min(x[i],k-x[i])*2
print(ans)


n=int(input())
k=int(input())
x=[int(x) for x in input().split()]
ans=0
from math import fabs
for i in x:
    ans+=min(fabs(i-k),fabs(i))
print(int(ans*2))


# -*- coding: utf-8 -*-

N = int(input())
K = int(input())
x = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += min(abs(0-x[i]), abs(K-x[i])) * 2

print(ans)


# coding: utf-8
# Here your code !
N = int(input())
K = int(input())
ans = 0

x = list(map(int,input().split()))

for i in range(N):
    if x[i] > K/2:
        ans = ans + 2 *(K-x[i])
    else:
        ans = ans + 2 *x[i]

print(ans)


# -*- coding=utf-8 -*-
def convert_lines_to_int(args):
    """ "a b c d e f ..." >> [a, b, c, d, e, f ...]
        args:
            args:text splited by space.
        return:
            list
    """
    return list(map(int, args.split(" ")))

ball_count = int(input())
type_b_robot_point = int(input())
ball_point_x = convert_lines_to_int(input())

class Robot(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def collect_ball(self, ball_point):
        pass

class RobotA(Robot):
    def __init__(self, x, y):
        self.x = 0
        self.y = y
        self.collect_cost = None

    def collect_ball(self, ball_point):
        self.collect_cost = ball_point * 2

class RobotB(Robot):
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.collect_cost = None

    def collect_ball(self, ball_point):
        self.collect_cost = (self.x - ball_point) * 2

class Ball(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y

ball_list = [Ball(ball_point_x[count], count + 1) for count in range(ball_count)]
robot_a_list = list()
robot_b_list = list()
for ball in ball_list:
    r = RobotA(ball.x, ball.y)
    r.collect_ball(ball.x)
    robot_a_list.append(r)

    r = RobotB(type_b_robot_point, ball.y)
    r.collect_ball(ball.x)
    robot_b_list.append(r)
# Test
# for r in robot_a_list:
#     print(r.collect_cost)
#
# print("")
#
# for r in robot_b_list:
#     print(r.collect_cost)

# Check!
summary = list()
for i in range(ball_count):
    if robot_a_list[i].collect_cost > robot_b_list[i].collect_cost:
        summary.append(robot_b_list[i].collect_cost)
    else:
        summary.append(robot_a_list[i].collect_cost)

print(sum(summary))


N = int(input())
K = int(input())
x = [int(i) for i in input().split()]

ans = 0
for xi in x:
    if xi < K/2:
        ans += xi*2
    else:
        ans += (K-xi)*2
print(ans)


if __name__ == '__main__':
    N = input()
    K = input()
    x = map(int, raw_input().split())
    sum = 0
    for d in x:
        if (K-d < d):
            sum += 2*(K-d)
        else:
            sum += 2*d

    print sum


N = int(input())
K = int(input())
xstr = input().split()
d = 0
for i in xstr:
    xi = int(i)
    dK = K-xi
    if dK < xi:
        d += dK
    else:
        d += xi
print(d*2)


import sys

# utils
def read_numbers():
    return [int(num) for num in sys.stdin.readline().split()]
def read_string():
    return sys.stdin.readline().rstrip('\r\n')
def list2str(*array):
    return ' '.join([str(i) for i in array])

def main(N, K, xs):
    result = 0
    for x in xs:
        result += 2*min(K-x, x)
    return result

def parse_stdin():
    # N = read_numbers()
    # data = []
    # for i in range(N):
    #    data.append(read_numbers())
    N = read_numbers()[0]
    K = read_numbers()[0]
    xs = read_numbers()
    return N, K, xs

def test_main():
    """run pytest stdin.py to test"""
    assert main(2, 9, [3, 6]) == 12

if __name__ == '__main__':
    N, K, xs = parse_stdin()
    result = main(N, K, xs)
    print(result)


N=int(input())
K=int(input())
ans=0

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

for i in range(N):
    if(K-n[i]<n[i]):
        ans+=2*(K-n[i])
    else:
        ans+=2*n[i]

print(ans)


n = int(input())
k = int(input())
l = input().split()
ans = 0
for i in l:
  j = int(i)
  if( j < abs( j - k )  ):
    ans += 2*j
  else:
    ans += 2*abs(j-k)
print(ans)


NUM = int(input())
K = int(input())
POS = list(map(int, input().split()))
sum = 0
for i in POS:
    a = i * 2
    b = abs(i - K) * 2
    sum += min(a, b)
print(sum)


def main():
    """
    ball: N
    ball position: (X, Y) -> (x_i, i)
    robot A: N
    robot B: N
    A position: (X, Y) -> (0, i)
    B position: (X, Y) -> (K, i)

    A pattern: (0, a) if ball pos eq (xx, a)
    B pattern: (K, b) if ball pos eq (xx, b)
    """
    N = int(input())
    K = int(input())
    xs = map(int, input().split())

    mov_dist = 0
    for y, x in enumerate(xs, 1):
        a_dist = x
        b_dist = abs(K - x)
        dist = min(a_dist, b_dist)

        mov_dist += dist * 2

    print(mov_dist)

if __name__ == '__main__':
    main()


N = int(input())
K = int(input())

X = list(map(int, input().split()))

HalfK = K/2.0

Ans = 0

for i in range(N):
    if X[i] > HalfK:
        Ans += 2*(K-X[i])
    else:
        Ans += 2*X[i]

print(str(Ans))


from sys import stdin
ans = 0
n = int(stdin.readline())
k = int(stdin.readline())
a = map(int,stdin.readline().split())
for i in a:
 ans += min(i,k-i)
print 2*ans


import math

N = int(input())
K = int(input())
X = list(map(int, input().split(' ')))
ans = 0
for i in range(N):
    dis1 = X[i]
    dis2 = X[i]-K
    if dis2 < 0:
        dis2 = -dis2
    ans += min(dis1, dis2)*2
print(ans)


N = int(input())
K = int(input())

x = list(map(int, input().split()))

ans = 0
for a in x:
    ans += min(a, abs(K - a)) * 2

print(ans)


import sys

# sys.stdin = open('b1.in')

def read_int_list():
    return list(map(int, input().split()))

def read_str_list():
    return input().split()

def read_int():
    return int(input())

def read_str():
    return input()

def main():
    n = read_int()
    k = read_int()
    x = read_int_list()

    res = 0
    for i in range(n):
        r = 2 * x[i]
        if k - x[i] < x[i] - 0:
            r = 2 * (k - x[i])
        res += r
    print(res)

main()


N = int(input())
K = int(input())
X = list(map(int, input().split()))

d = 0
for x in X:
    d += 2 * min(x, K-x)

print(d)


# coding: utf-8
def get_ln_inputs():
    return input().split()

def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))

def main():
    N = get_ln_int_inputs()[0]
    K = get_ln_int_inputs()[0]
    xs = get_ln_int_inputs()

    ans = 0
    for x in xs:
        ans += min(abs(K - x), abs(x))

    print(2 * ans)
    return

main()


n = int(input().strip())
k = int(input().strip())
xs = [int(x) for x in input().strip().split()]

total = 0
for x in xs:
    if x < abs(x-k):
        total += x*2
    else:
        total += abs(x-k)*2
print(total)


N = int(input())
K = int(input())
x = input()
split_x = x.split()
int_split_x = [int(i) for i in split_x]
result = 0

for i in range(0, len(int_split_x)):
    if abs(K - int_split_x[i]) > abs(0 - int_split_x[i]):
        result += (abs(0 - int_split_x[i]))*2
    else:
        result += (abs(K - int_split_x[i]))*2

print(result)


N = int(input())

K = int(input())

balls_x = input().split(' ')

sum = 0

for ball_x_str in balls_x:

    ball_x  = int(ball_x_str)

    sum += min(ball_x, K - ball_x) * 2

print(sum)


N = int(input())
K = int(input())
x = list(map(int,input().split()))
kyori = 0
for i in range(N):
    kyori += min(x[i]*2,abs(K-x[i])*2)
print(kyori)


def main():
    n = int(input())
    k = int(input())
    print(sum([2*min(k-int(i), int(i)) for i in input().split()]))

if __name__ == "__main__":
    main()


N = int(input())
K = int(input())
positions = map(int, input().split(" "))

roboA_distance = 0
roboB_distance = 0
for position in positions:
  hoge = K-position
  if hoge > position:
    roboA_distance += position
  else:
    roboB_distance +=  hoge
print(2*(roboA_distance + roboB_distance))


N = int(input())
K = int(input())
xs = map(int, input().split())

ans = 0
for x in xs:
    ans += min(2*x, 2*abs(x-K))

print(ans)


N = int(input())
K = int(input())
x = list(map(int,input().split(" ")))

sum = 0

for i in range(N):
	sum += abs(min(x[i], K - x[i]) * 2)

print(sum)


N, K, A = int(input()), int(input()), [int(v) for v in input().split()]
R = 0
for a in A:
  Na = abs(0-a)
  Ka = abs(K-a)
  r = Na if Na <= Ka else Ka
  R += r * 2

print(R)


N=int(input())
K=int(input())
print(2*sum([ min(x,K-x) for x in map(int,input().split()) ]))


n = int(input())
k = int(input())
x = list(map(int,input().split()))
s = 0
for i in range(n):
    s += min(k-x[i],x[i])
print(s*2)


dump = int(input())
K = int(input())
sum = 0
x = list(map(int, input().split()))
for x_i in x:
  sum += 2*min(x_i, K-x_i)
print(sum)


n=int(input())
k=int(input())
x=list(map(int,input().split()))

ans=0
for i in x:
    ans += min(abs(i)*2,abs(k-i)*2)

print(ans)


N = int(input())
K = int(input())
x = [int(n) for n in input().split()]

res = 0
for t in x:
  res += 2*min(K-t, t)

print(res)


n = int(input())
k = int(input())
xs = map(int, input().split(" "))

s = 0

for x in xs:
    s += 2 * min(x - 0, abs(x - k))

print(s)


def calc_dist(N, K, x):
    dists = [2 * min(K - x_i, x_i) for x_i in x]
    return sum(dists)

if __name__ == "__main__":
    N = int(raw_input())
    K = int(raw_input())
    x = map(int, raw_input().split())
    print(calc_dist(N, K, x))


a, b, c = list(map(int, input().split()))

if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)


a,b,c = input().split()
a = int(a)
b = int(b)
c= int(c)

if a == b:
    print(c)
elif b == c:
    print(a)
else:
    print(b)


l = list(map(int,input().split()))
if l[0]==l[1]:
    print(l[2])
elif l[1]==l[2]:
    print(l[0])
else:
    print(l[1])


A,B,C = map(int, input().split())
print(A^B^C)


l = [int(x) for x in raw_input().split()]
for x in set(l):
	if l.count(x) == 1:
		print x


nums = [ int(i) for i in input().split()]
nums.sort()
if nums[0] == nums[1]:
    print(nums[2])
else:
    print(nums[0])


# coding: utf-8

a = input().split()

if a[0] == a[1]:
    print(a[2])
elif a[1] == a[2]:
    print(a[0])
elif a[0] == a[2]:
    print(a[1])


A, B, C = sorted(map(int, input().split()))
print(A if A != B else C)


# -*- coding:utf-8 -*-
a = list(map(int, input().split()))
d = set()
e = [ tmp for tmp in a if tmp in d or d.add(tmp) ]
for tmp in a:
    if tmp not in e:
        print(tmp)
        break


import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a,b,c = na()
print(a^b^c)


A,B,C=map(int, input().split())
if A==B:
 print(C)
elif B==C:
 print(A)
else:
 print(B)


from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))

def main():
	a=sorted(readLine_int_list())
	print(a[0] if a.count(a[0]) == 1 else (a[2]))

if __name__ == "__main__":
    main()


nums = [int(x) for x in input().split()]

nums.sort()

if nums[0] == nums[1]:
	print(nums[2])
elif nums[1] == nums[2]:
	print(nums[0])


A,B,C = map(int,input().split())
if A==B:
    print(C)
if A==C:
    print(B)
if B==C:
    print(A)


x = list(map(int, input().split()))

if x[0]==x[1]:
    print(x[2])
    quit()
elif x[1]==x[2]:
    print(x[0])
    quit()

print(x[1])

quit()


a,b,c = map(int,input().split())
print(a^b^c)


a, b, c = map(int, input().split())
if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)


from sys import stdin
a,b,c = map(int,stdin.readline().split())
print a^b^c


a, b, c = map(int, input().split())
if a==b:
  print(c)
elif b==c:
  print(a)
else:
  print(b)


a,b,c = map(int, input().split())
print(a^b^c)


a, b, c = input().split(" ")

if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)


a, b, c = map(int, input().split())

if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)


A, B, C = input().split(" ")

if A == B:
    print(C)
elif A == C:
    print(B)
else:
    print(A)


# -*- coding: utf-8 -*-

import sys
from collections import Counter

def main():
    for line in sys.stdin:
        data = line.rstrip().split(" ")
        counter = Counter(data)
        print(list(counter.most_common())[-1][0])

if __name__ == "__main__":
    main()


import sys
from collections import Counter

# sys.stdin = open('a1.in')

def read_int_list():
    return list(map(int, input().split()))

def read_str_list():
    return input().split()

def read_int():
    return int(input())

def read_str():
    return input()

def main():
    n = read_int_list()
    c = Counter(n)
    for i in c:
        if c[i] == 1:
            print(i)

main()


def main():
    A, B, C = map(int, input().split())

    if A == B:
        print(C)
    elif B == C:
        print(A)
    else:
        print(B)

if __name__ == '__main__':
    main()


nums = map(int, input().split())
d = {}
for n in nums:
  d.setdefault(n, 0)
  d[n] += 1
print(list(d.keys())[list(d.values()).index(1)])


inputs=input().split()
A = int(inputs[0])
B = int(inputs[1])
C = int(inputs[2])

if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)


import math,heapq,collections,sys,numpy

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

a,b,c = LI()
if a == b:
    print(c)
elif b == c:
    print(a)
elif a == c:
    print(b)


a, b, c = (int(i) for i in input().split())

if a==b:
    print(c)
elif b==c:
    print(a)
else:
    print(b)


a = list(map(int, input().split()))
if a[0] == a[1]:
    print(a[2])
elif a[0] == a[2]:
    print(a[1])
elif a[1] == a[2]:
    print(a[0])


import numpy as np

A, B, C = (list(map(int, input().split())))
if(A == B):
  print(C)
elif(A == C):
  print(B)
else:
  print(A)


# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()

a, b, c = map(int, input().split())

if a == b:
    print(c)
elif b == c:
    print(a)
else:
    print(b)


A, B, C = map(int, input().split())
if(A == B):
    print(C)
elif(B == C):
    print(A)
else:
    print(B)


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    a = LI()
    if a[0] == a[1]:
        return a[2]
    if a[0] == a[2]:
        return a[1]

    return a[0]

print(main())


a,b,c=map(int,input().split())
if a==b:
    print(c)
elif a==c:
    print(b)
else:
    print(a)


# -*- coding: utf-8 -*-
import traceback

def main():
    _list = map(int,raw_input().split())
    for val in _list:
        if _list.count(val) == 1:
            return val

print main()


a,b,c = input().split()
if a == b:
    print(c)
elif b==c:
    print(a)
else:
    print(b)


#!/usr/bin/env python
# -*- coding: utf-8 -*-

a, b, c = list(map(int, input().split()))

if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)


A, B, C = map(int, input().split())
if (A==B):
    print(C)
elif (A==C):
    print(B)
else:
    print(A)


nums=input().split()
for i in range(3):
    nums[i]=int(nums[i])

if nums[0]==nums[1]:
    print(nums[2])
elif nums[0]==nums[2]:
    print(nums[1])
else:
    print(nums[0])


a, b, c = map(int, raw_input().split())
if a == b:
    print c
elif b == c:
    print a
else:
    print b


a=list(input().split())
for i in range(3):
  if a.count(a[i])==1:
    b=a[i]
print(b)


# coding: utf-8
a=list(map(int,input().split()))
for n in a:
    if a.count(n)==1:
        print(n)
        break


A, B, C = map(int, raw_input().split())
if A == B:
    print C
elif A == C:
    print B
else:
    print A


import sys

l = list(map(int, sys.stdin.readline().strip().split(" ")))

if (l[0] == l[1]):
    print(str(l[2]))
elif (l[1] == l[2]):
    print(str(l[0]))
else:
    print(str(l[1]))


A, B, C = map(int, input().split())

if (A==B) & (A!=C):
    print(C)
elif (A==C) & (A!=B):
    print(B)
else:
    print(A)


a,b,c = map(int, input().split(" "))

if b == c:
    print(a)
elif a == c:
    print(b)
else:
    print(c)


A, B, C = map(int, input().split())

if A == B:
    print(C)
elif A == C:
    print(B)
else:
    print(A)


a,b,c = map(int,input().split())
if a == b:
	print(c)
elif b == c:
	print(a)
elif c == a:
	print(b)


a = [int(i) for i in input().split()]
a.sort()
print(a[2] if a[0] == a[1] else a[0])


A, B, C = map(int, input().split())
if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)


A, B, C = map(int, input().split())

if A == B:
  Ans = C
else:
  if A == C:
    Ans = B
  else:
    Ans = A

print(Ans)


# coding: utf-8
A, B, C = map(int, raw_input().split(' '))

if A == B:
    print C
elif A == C:
    print B
else:
    print A


a,b,c=map(int,input().split())
if a==b:
  print(c)
elif a==c:
  print(b)
else: print(a)


A,B,C = list(map(int, input().split()))

if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)


#ABC075A

a,b,c=map(int,raw_input().split())
if a==b:
 print c
elif a==c:
 print b
else:
 print a


a, b, c = map(int, raw_input().split())

if b == c:
	ans = a
elif a == c:
	ans = b
else:
	ans = c

print str(ans)


X = map(int, raw_input().split())
print sum(X)-(sum(X)-min(X)-max(X))*2


def main():
    ABC = tuple(map(int, input().split()))
    print(lonelyInteger(ABC))

def lonelyInteger(array):
    result = 0
    for i in array:
        result ^= i
    return result

main()


a ,b ,c=map(int,raw_input().split())
if a==b:
  print(c)
elif a==c:
  print(b)
else:
  print(a)


line=input().split()
a=int(line[0])
b=int(line[1])
c=int(line[2])
if (a==b):
    print (c)
elif (b==c):
    print(a)
elif (a==c):
    print(b)


a,b,c = [int(i) for i in input().split()]
print(a if a != b and a!= c else b if b!= a and b != c else c)


A, B, C = (input()).split()
if A == B:
    print(C)
elif B == C:
    print(A)
elif C == A:
    print(B)


n = input().split()
if n[0] == n[1]:
  print(n[2])
elif n[0] == n[2]:
  print(n[1])
else:
  print(n[0])


A,B,C = map(int,input().split())
if A == B:
	print(C)
elif B == C:
	print(A)
else:
	print(B)


from collections import Counter
N = list(map(int,input().split()))
c = Counter(N)

for k,v in c.items():
     if v == 1:
          print(k)


A,B,C = map(int,raw_input().split())
if A == B:
    print C
elif A == C:
    print B
else:
    print A


a,b,c = (int(x) for x in input().split())

print(c if a == b else (b if a == c else a))


def main():
    a, b, c = map(int, raw_input().split(" "))

    if a == b:
        print(c)
    elif a == c:
        print(b)
    else:
        print(a)

if __name__ == '__main__':
    main()


*S,=map(int, input().split())
S.sort()
print(S[0] if S[1] == S[2] else S[2])


a,b,c=map(int,raw_input().split(' '))

if a==b:
    print c
elif b==c:
    print a
else:
    print b


A,B,C = map(int,input().split())
if A==B:
    print(C)
elif B==C:
    print(A)
else:
    print(B)


A, B, C = map(int, input().split())

print(({A} ^ {B} ^ {C}).pop())


A, B, C = map(int, input().split())

if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)


A,B,C = map(int, input().split())
if A == B:
	print(C)
elif A == C:
	print(B)
else:
	print(A)


l = list(map(int, input().split()))
if l[0]==l[1]:
	print(l[2])
elif l[0] ==l[2]:
	print(l[1])
elif l[1] ==l[2]:
	print(l[0])


A = list(map(int, input().split()))
print(A[0]^A[1]^A[2])


# coding: utf-8
# Here your code !
s=list(map(int,input().rstrip().split()))

for i in s:
    if( s.count(i) == 1 ):
        print(i,flush=True)
        break


S = input().split(" ")

A = int(S[0])
B = int(S[1])
C = int(S[2])
if A == B:
    print (C)
elif B == C:
    print(A)
else:
    print(B)


A,B,C = list(map(int, input().strip().split()))
if A == B:
    print(C)
elif A == C:
    print(B)
else:
    print(A)


a,b,c=map(int, input().split())
if a == b: print(c)
elif b == c: print(a)
else: print(b)


a, b, c = map(int, input().split())		# 5 7 2

if a==b:
	print(c)
elif a==c:
	print(b)
else:
	print(a)


# One out of Three

a,b,c = list(map(int, input().split()))

if (a==b):
    print(c)
else:
    if (a==c):
        print(b)
    else:
        print(a)


A, B, C = list(map(int, input().split()))
if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)


a,b,c = map(int,input().split())

if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")

def main():
    A, B, C = map(int, input().split())
    if A == B:
        print(C)
    elif A == C:
        print(B)
    elif B == C:
        print(A)

if __name__ == '__main__':
    main()


A, B, C = map(int, input().split())
if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)


# -*- coding: utf-8 -*-

a, b, c = map(int, raw_input().split())

if a == b:
  output = c
elif a == c:
  output =  b
else:
  output = a

print(output)


a, b, c = map(int, raw_input().split())
if a == b:
    print c
else:
    if a == c:
        print b
    else:
        print a


#!/usr/bin/python3

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

h = {}
for i in n:
    if i not in h:
        h[i] = 0
    h[i] += 1

for i in h.keys():
    if h[i] < 2:
        print(i)
        exit()


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
"""

# import {{{
from collections import ChainMap
from collections import Counter
from collections import defaultdict
from collections import deque
from collections import namedtuple
import bisect
import copy
import decimal
import fractions
import functools
import heapq
import itertools
import locale
import math
import operator
import pdb
import pprint
import random
import re
import string
import sys
import time

try:
    import numpy as np
    import scipy as sp
except:
    pass
# }}}

# util {{{
def is_odd(x):
    return x % 2 == 1

def is_even(x):
    return x % 2 == 0

def cmp(x, y):
    return (x > y) - (x < y)

def sgn(x):
    return cmp(x, 0)

def clamp(x, lo, hi):
    assert lo <= hi
    if x < lo:
        return lo
    elif x > hi:
        return hi
    else:
        return x

def chmax(xmax, x):
    if x > xmax:
        return x, True
    else:
        return xmax, False

def chmin(xmin, x):
    if x < xmin:
        return x, True
    else:
        return xmin, False

def argmax(seq):
    return max(range(len(seq)), key=seq.__getitem__)

def argmin(seq):
    return min(range(len(seq)), key=seq.__getitem__)

def INPUT():
    return input().rstrip() # CRLF対策

sys.setrecursionlimit(100000)

locale.setlocale(locale.LC_ALL, "C")
# }}}

# 適宜調整
PINF = float("inf")
NINF = float("-inf")
EPS  = 1e-9

def main():
    X = list(map(int, input().split()))

    X.sort()
    if X[0] == X[1]:
        print(X[2])
    elif X[1] == X[2]:
        print(X[0])

if __name__ == "__main__": main()


l = raw_input().split()

if l[0] == l[1] :
	print l[2]
elif l[1] == l[2] :
	print l[0]
elif l[0] == l[2] :
	print l[1]


#!/usr/bin/env python
#-*- coding: utf-8 -*-

A, B, C = [int (i) for i in raw_input ().split ()]
print A ^ B ^ C


a,b,c = input().split()
if a == b:
    print(c)
elif b==c:
    print(a)
else:
    print(b)


A,B,C=list(map(int,raw_input().split()))
if A==B:
	print C
elif A==C:
	print B
elif B==C:
	print A


if __name__ == '__main__':
    A, B, C = map(int, input().split())
    if A == B:
        print(C)
    elif B == C:
        print(A)
    else:
        print(B)


A, B, C = map(int, input().split())

if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)


#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import Counter
nums = [int(i) for i in input().split()]
counter = Counter(nums)
for key, value in counter.items():
    if value == 1:
        print(key)


A,B,C = map(int,input().split())
if A == B: print(C)
elif B == C: print(A)
else: print(B)


# coding: utf-8
# Here your code !
s=list(map(int,input().rstrip().split()))

for i in s:
    if( s.count(i) == 1 ):
        print(i,flush=True)
        break


nums=raw_input().split(' ')
if nums[0]!=nums[1]:
 if nums[0]==nums[2]:
  print nums[1]
 else:print nums[0]
else:print nums[2]


A, B, C = input().split()
if A == B:
    print(C)
elif A == C:
    print(B)
else:
    print(A)


#https://beta.atcoder.jp/contests/abc075
# -*- coding: utf-8 -*-
a,b,c = map(int,input().split())

if a == b : print(c)
if b == c : print(a)
if c == a : print(b)


a,b,c = input().split()
if a == b:
    print(c)
else:
    if a == c:
        print(b)
    else:
        print(a)


a,b,c = map(int, raw_input().split())
if a == b:
    print c
elif a == c:
    print b
else:
    print a


a, b, c = map(int, input().split())
if a == b:
    print(c)
if a == c:
    print(b)
if b == c:
    print(a)


#! /usr/bin/env python3
# -*- coding: utf-8 -*-

A,B,C = map(int,input().split(" "))

if A ==  B:
	print(C)
elif B == C:
	print(A)
else:
	print(B)


#!/usr/bin/env python
#-*- coding: utf-8 -*-

from collections import defaultdict
from math import factorial as f
from fractions import gcd as g

l = [int (i) for i in raw_input ().split ()]
d = defaultdict (int)
for i in l: d [i] += 1
print [i for i in d if d [i] == 1][0]


a, b, c = input().split()

if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)


#!/usr/bin/env python

a, b, c = map(int, input().split())

if a == b:
    print(c)
elif b == c:
    print(a)
elif c == a:
    print(b)
else:
    pass


A, B, C = map(int,input().split())

if A==C:
    print(B)

elif A==B:
    print(C)

else:
    print(A)


a = list(map(int,input().split()))
a.sort()

ans = a[0]
if a[0] == a[1]:
    ans = a[2]
print(ans)


a, b, c = map(int, input().split())
if(a==b): print(c)
if(b==c) :print(a)
if(a==c) :print(b)


a, b, c = map(int, input().split())
print(a^b^c)


a,b,c=input().strip().split(' ')
if a==b:
  print(c)
elif a==c:
  print(b)
elif b==c:
  print(a)


# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc075/tasks/abc075_a

"""
import sys
from sys import stdin
input = stdin.readline

def main(args):
    A, B, C = map(int, input().split())
    ans = 0
    if A == B:
        ans = C
    elif B == C:
        ans = A
    else:
        ans = B
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])


a, b, c = [int(i) for i in input().split(" ")]

if a == b:
    print(c)
elif b == c:
    print(a)
elif a == c:
    print(b)


from collections import defaultdict

def main():
    d = defaultdict(lambda: 0)
    for i in input().split():
        d[int(i)] += 1
    d = {v:k for k, v in d.items()}
    print(d[1])

if __name__ == "__main__":
    main()


from collections import Counter

num = list(map(int,input().split()))
c = Counter(num)

print(c.most_common()[1][0])


a, b, c = map(int, input().split())

if a == b:
    x = c
elif b == c:
    x= a
else:
    x = b

print(x)


a,b,c = map(int,input().split())
if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)


a,b,c=[int(i) for i in input().split()]

if a==b:
  print(c)
elif b==c:
  print(a)
else:
  print(b)


num = input().split()
num = [int(x) for x in num]

for i in num:
    if num.count(i) == 1:
        print(i)


a,b,c=input().split()

if a==c:
    print(b)
elif b==c:
    print(a)
else:
    print(c)