Given an array of integers, where all elements but one occur twice, find the unique element.  

Example 

$a=[1,2,3,4,3,2,1]$  

The unique element is $\begin{array}{c}4\end{array}$.  

Function Description  

Complete the lonelyinteger function in the editor below.   

lonelyinteger has the following parameter(s):  

int a[n]: an array of integers   

Returns  

int: the element that occurs only once  

Input Format

The first line contains a single integer, $n$, the number of integers in the array. 

The second line contains $n$ space-separated integers that describe the values in $\boldsymbol{a}$.

Constraints

$1\leq n<100$  
It is guaranteed that $n$ is an odd number and that there is one unique element.  
$0\leq a[i]\leq100$, where $0\leq i<n$.

Sample Input 0
1
1

Sample Output 0
1

Explanation 0

There is only one element in the array, thus it is unique.

Sample Input 1
3
1 1 2

Sample Output 1
2

Explanation 1

We have two $\mbox{1}$'s, and $2$ is unique. 

Sample Input 2
5
0 0 1 2 1

Sample Output 2
2

Explanation 2

We have two $\mbox{0}$'s, two $\mbox{1}$'s, and one $2$.  $2$ is unique.

Difficulty: EASY
Tags: Bit manipulation
Skill types: Bit manipulation

Starter code:

Solutions:
n = int(input())
a = list(map(int, input().split()))
r = a[0]
for i in range(1, n):
	r = r ^ a[i]
print(r)


def lonelyinteger(a):
	answer = 0
	a = list(a)
	for i in a:
		if a.count(i) == 1:
			answer = i
			break
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


input()
l = [int(x) for x in input().split(' ')]
for i in range(101):
	if l.count(i) == 1:
		print(i)


def lonelyinteger(a):
	answer = 0
	for i in a:
		answer = answer ^ i
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


T = int(input())
n = input().split(' ')
store = []
for x in n:
	x = int(x)
	if x not in store:
		store.append(x)
	else:
		store.remove(x)
print(store[0])


def lonelyinteger(a):
	s = set()
	for x in a:
		s.remove(x) if x in s else s.add(x)
	return s.pop()
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	answer = 0
	tmp = dict()
	for x in a:
		try:
			tmp[x] = tmp[x] + 1
		except:
			tmp[x] = 1
	for (v, v1) in tmp.items():
		if v1 == 1:
			answer = v
			break
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


n = int(input())
nums = [int(i) for i in input().split()]
for i in list(set(nums)):
	if nums.count(i) == 1:
		print(i)
		break


def lonelyinteger(b):
	for i in b:
		if b.count(i) == 1:
			return i
a = int(input())
b = list(map(int, input().strip().split(' ')))
print(lonelyinteger(b))


from collections import Counter

def lonelyinteger(a):
	for (k, c) in Counter(a).items():
		if c == 1:
			return k
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


num = int(input())
mylist = input().split()
mylist = [int(x) for x in mylist]
if num == 1:
	print(mylist[0])
else:
	mynewlist = list(set(mylist))
	sumun = sum(mynewlist)
	sm = sum(mylist)
	diff = sm - sumun
	print(sumun - diff)


n = int(input())
l = [int(x) for x in input().split()]
i = 0
while i < n:
	if l.count(l[i]) == 1:
		print(l[i])
		break
	i += 1


def lonelyinteger(a, n):
	answer = 0
	for i in range(n):
		answer ^= next(b)
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b, a))


def result(array):
	array = sorted(array)
	for i in range(0, len(array) - 1, 2):
		if array[i] != array[i + 1]:
			return array[i]
	return array[len(array) - 1]
N = int(input())
array = list(map(int, input().split()))
print(result(array))


def lonelyinteger(a):
	for n in a:
		if a.count(n) == 1:
			return n
	answer = a[0]
	return answer
a = int(input())
b = input().split(' ')
print(lonelyinteger(b))


def lonelyinteger(a):
	a = list(a)
	for x in a:
		if len(list(filter(lambda y: y == x, a))) == 1:
			return x
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	counts = [0] * 101
	for num in a:
		counts[num] += 1
	for num in range(len(counts)):
		if counts[num] == 1:
			return num
	return -1
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


import collections

def main():
	N = int(input())
	ar = str(input()).split()
	print([x for (x, y) in collections.Counter(ar).items() if y == 1][0])
main()


def read_ints():
	return [int(x) for x in input().split(' ')]

def find_lonely_int(ar):
	z = dict()
	for a in ar:
		if a in z:
			del z[a]
		else:
			z[a] = 1
	return list(z.keys())[0]
n = read_ints()
ar = read_ints()
print(find_lonely_int(ar))


import sys
N = int(sys.stdin.readline())
input = sorted([int(x) for x in sys.stdin.readline().split()])
repeats = {}
for number in input:
	repeats[number] = repeats.get(number, 0) + 1
print(sorted(repeats.items(), key=lambda t: t[1])[0][0])


count = int(input())
array = input().strip().split()
entries = dict()
for entry in array:
	if entry in entries:
		entries[entry] = True
	else:
		entries[entry] = False
for entry in entries:
	if entries[entry] == False:
		print(entry)


n = int(input())
l = [0 for i in range(0, 101)]
a = map(int, input().split(' '))
ans = 0
for i in a:
	if l[i] == 0:
		l[i] += 1
		ans += i
	else:
		ans -= i
print(ans)


n = int(input())
t = [int(x) for x in input().split()]
if n % 2 == 1 and n > 0 and (n <= 100) and (x <= 100 and x >= 0 for x in t):
	for j in range(n):
		indices = [i for (i, x) in enumerate(t) if x == t[j]]
		if len(indices) == 1:
			print(t[j])
			break
		else:
			continue
else:
	pass


def search(l):
	d = dict()
	for x in l:
		d[x] = d.get(x, 0) + 1
	for (key, val) in d.items():
		if val == 1:
			print(key)
			break

def main():
	n = int(input())
	l = list((int(x) for x in input().split(' ')))
	search(l)
main()


import sys
numElements = sys.stdin.readline()
elements = [int(x) for x in sys.stdin.readline().strip().split()]
accumulator = 0
for element in elements:
	accumulator ^= element
print(accumulator)


data = input()
data = int(data)
s = input()
s = s.split(' ')
s = [int(i) for i in s]
for i in s:
	if s.count(i) == 1:
		print(i)
		quit()


def main():
	testcase = int(input())
	integers = [int(i) for i in input().split()]
	not_lonely = {}
	for j in integers:
		if j not in not_lonely:
			not_lonely[j] = 1
		else:
			not_lonely[j] = not_lonely[j] + 1
	for (key, val) in not_lonely.items():
		if val == 1:
			print(key)
main()


num_integers = int(input())
integers = input().split()
integers = list(map(int, integers))
j = 0
for i in integers:
	j = j ^ i
print(j)


import sys
val = int(sys.stdin.readline())
nums = [int(x) for x in sys.stdin.readline().split()]
used = {}
for val in nums:
	if val not in used:
		used[val] = 0
	used[val] += 1
for (key, val) in used.items():
	if val < 2:
		print(key)
		break


import sys

def find_unique(numbers):
	if len(numbers) == 1:
		return numbers[0]
	numbers.sort()
	iter_num = iter(numbers)
	for x in iter_num:
		if x == numbers[-1]:
			return x
		y = next(iter_num)
		if x != y:
			return x
N = int(input())
numbers = [int(x) for x in input().strip().split()]
if N != len(numbers):
	exit()
print(find_unique(numbers))


input()
eyes = input().split(' ')
once = []
for i in eyes:
	if i not in once:
		once.append(i)
	else:
		once.remove(i)
print(once[0])


n = int(input())
occurrences = {}
for token in input().strip().split():
	x = int(token)
	if x not in occurrences:
		occurrences[x] = 1
	else:
		occurrences[x] += 1
for key in occurrences:
	if occurrences[key] == 1:
		print(key)
		break


def findLoner(A):
	loner = 0
	for x in A:
		loner = loner ^ x
	return loner
N = int(input().split()[0])
A = [int(x) for x in input().split()]
print(findLoner(A))


import random

def quicksort(a):
	n = len(a)
	if n <= 1:
		return a
	i = 1
	pos = random.randrange(0, n)
	(a[0], a[pos]) = (a[pos], a[0])
	pivot = a[0]
	for j in range(1, n):
		if a[j] < pivot:
			(a[i], a[j]) = (a[j], a[i])
			i = i + 1
	(a[i - 1], a[0]) = (a[0], a[i - 1])
	left_sort = quicksort(a[0:i])
	right_sort = quicksort(a[i:])
	return merge(left_sort, right_sort)

def merge(left, right):
	i = 0
	j = 0
	result = [0] * len(left + right)
	left = left + [float('inf')]
	right = right + [float('inf')]
	for k in range(len(result)):
		if left[i] < right[j]:
			result[k] = left[i]
			i = i + 1
		else:
			result[k] = right[j]
			j = j + 1
	return result
N = int(input())
array = list(map(int, input().split(' ')))
array = quicksort(array)
if N == 1:
	print(array[0])
else:
	if N % 2 != 0:
		array = array + [float('inf')]
		N = N + 1
	for i in range(0, N, 2):
		if array[i] != array[i + 1]:
			break
	print(array[i])


import operator
from functools import reduce
input()
array = map(int, input().split(' '))
ans = reduce(operator.xor, array)
print(ans)


grid = []
n = input()
grid.append(input().split())
S = [0] * 1000
for x in range(0, len(grid[0])):
	S[int(grid[0][x])] += 1
for y in range(0, 1000):
	if S[y] == 1:
		print(y)


n = int(input())
numbers = input().split()
res = 0
for i in range(n):
	res = res ^ int(numbers[i])
print(res)


n = int(input())
arr = input().split()[:n]
for z in arr:
	if arr.count(z) == 1:
		print(z)
		break


N = int(input())
A = input().split()
A.sort()
for i in range(0, N - 2, 2):
	if A[i] != A[i + 1]:
		print(A[i])
		break
else:
	print(A[-1])


n = int(input())
ar = input().split()
ar = sorted(list(map(int, ar)))
for i in range(0, n):
	if ar.count(ar[i]) == 1:
		print(ar[i])
		break


def find_recluse(numbers):
	map = {}
	for i in numbers:
		if i in map:
			map[i] = map[i] + 1
		else:
			map[i] = 1
	for i in numbers:
		if map[i] == 1:
			return i
import sys
file_name = sys.stdin
i = 0
for line in file_name:
	if i == 0:
		i += 1
	else:
		numbers = [int(i) for i in line.split()]
		print(find_recluse(numbers))


size = int(input())
data = input().split()
dic = {}
for x in data:
	if x in dic:
		dic[x] += 1
	else:
		dic[x] = 1
for x in dic:
	if dic[x] == 1:
		print(x)
		break


def lonely_integer(numbers):
	num_count = {}
	for num in numbers:
		if numbers.count(num) == 1:
			return num

def main():
	a = input()
	b = [int(num) for num in input().split(' ')]
	print(lonely_integer(b))
main()


N = int(input())
nums = input().split(' ')
nums = [int(num) for num in nums]
nums_list = [0 for i in range(101)]
for i in nums:
	nums_list[i] += 1
for i in range(len(nums_list)):
	if nums_list[i] == 1:
		print(str(i))
		break


def find_integer():
	num_integers = int(input())
	str_in = str(input()).strip()
	uniq_seen = []
	repeat_list = []
	int_list = [int(x) for x in str_in.split(' ')]
	for integer in int_list:
		if integer in repeat_list:
			continue
		if not integer in uniq_seen:
			uniq_seen.append(integer)
		else:
			uniq_seen.remove(integer)
			repeat_list.append(integer)
	print(uniq_seen[0])

def main():
	find_integer()
main()


ignore = input()
values = input()
new_values = [int(i) for i in values.split(' ')]
for i in range(len(new_values)):
	tmp = new_values[i]
	new_values[i] = -1
	if tmp not in new_values:
		print(tmp)
	else:
		new_values[i] = tmp


n = int(input())
li = [int(i) for i in input().split()]
rt = 0
for i in li:
	rt ^= i
print(rt)


n = int(input())
nums = [int(s) for s in input().split()]
result = 0
for i in nums:
	result = result ^ i
print(result)


N = int(input())
l = []
for i in map(int, input().split()):
	l.append(i)
for i in l:
	if l.count(i) == 1:
		lonely = i
		break
print(lonely)


import sys
from collections import defaultdict
lines = sys.stdin.readlines()
d = defaultdict(int)
nums = lines[1].split(' ')
for n in nums:
	if n:
		d[int(n)] += 1
for k in d:
	if d[k] == 1:
		print(k)


number = int(input())
num_array = input()
num_array = num_array.split(' ')
flag = True
i = 0
ans = ''
while flag:
	if num_array.count(num_array[i]) == 1:
		ans = num_array[i]
		flag = False
	i += 1
print(int(ans))


from collections import Counter
input()
numbers = Counter([int(a) for a in input().split()])
print(min(numbers.keys(), key=lambda x: numbers[x]))


n = int(input())
tmp = input()
a = []
for i in tmp.split():
	a.append(int(i))
for i in a:
	if a.count(i) == 1:
		print(i)
		break


n = int(input())
array = input()
if n == 1:
	print(int(array))
else:
	array = array.split(' ')
	array = [int(element) for element in array]
	array.sort()
	length = len(array)
	i = 0
	while i < length:
		if i == length - 1:
			print(array[i])
			break
		elif array[i] == array[i + 1]:
			i += 2
		else:
			print(array[i])
			break


n = int(input())
arr = [int(x) for x in input().split()]
_arr = []
for i in range(len(arr)):
	if arr[i] in _arr:
		_arr.remove(arr[i])
	else:
		_arr.append(arr[i])
print(_arr[0])


n = int(input())
a = [int(i) for i in input().split(' ')]
d = set(a)
for i in d:
	if a.count(i) == 1:
		print(i)
		break


def main():
	inputNum = int(input())
	arrString = input().split()
	arrData = []
	for i in range(0, inputNum):
		arrData.append(int(arrString[i]))
	arrData.sort()
	tempData = arrData[0]
	count = 0
	for j in range(1, inputNum):
		if tempData == arrData[j]:
			count += 1
		elif tempData != arrData[j] and count == 0:
			print(tempData)
			quit()
		else:
			tempData = arrData[j]
			count = 0
	print(tempData)
main()


input()
xs = input().split()
for x in xs:
	if xs.count(x) == 1:
		print(x)
		break


from collections import Counter

def lonelyinteger(a):
	answer = Counter(a).most_common()[-1][0]
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyInteger():
	a = int(input())
	b = input().split(' ')
	for i in range(0, a):
		found = 0
		for y in b:
			if b[i] == y:
				found += 1
		if found == 1:
			print(b[i])
lonelyInteger()


def lonelyinteger(a):
	l = list(a)
	d = dict()
	for x in range(0, len(l)):
		if l[x] in d:
			d[l[x]] = d[l[x]] + 1
		else:
			d[l[x]] = 1
	v = list(d.values())
	for k in d:
		if d[k] % 2 == 1:
			answer = k
			break
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	a = list(a)
	counts = [str(x) for x in a if a.count(x) == 1]
	return ' '.join(counts)
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	h = {}
	for x in a:
		if x in h:
			h[x] += 1
		else:
			h[x] = 1
	for k in h:
		if h[k] == 1:
			answer = k
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


from collections import Counter

def Solve(List):
	c = Counter(List)
	k = c.most_common()
	Answer = k[len(k) - 1]
	print(int(Answer[0]))
Length = int(input())
Array = []
Numbers = input()
Numbers = Numbers.split()
for Value in Numbers:
	Array.append(Value)
Solve(Array)


def lonelyinteger(a):
	occured = set()
	for n in a:
		if n in occured:
			occured.remove(n)
		else:
			occured.add(n)
	if not len(occured) == 1:
		println('Either found 0 or more than 1 element occuring once.')
	return sorted(list(occured))[0]
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	dict = {}
	for val in a:
		if val in dict:
			dict[val] = dict[val] + 1
		else:
			dict[val] = 1
	for val in dict:
		if dict[val] == 1:
			return val
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


import collections

def lonelyinteger(a):
	answer = 0
	c = dict(collections.Counter(a))
	for (i, j) in c.items():
		if j == 1:
			answer = i
			break
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	answer = 0
	candid = set()
	ncandid = set()
	for i in iter(a):
		if i in candid:
			candid.remove(i)
			ncandid.add(i)
		elif i not in ncandid:
			candid.add(i)
	return candid.pop()
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	doubleList = []
	for num in a:
		if num in doubleList:
			doubleList.remove(num)
		else:
			doubleList.append(num)
	return doubleList[0]
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


a = int(input())
b = input().split(' ')
c = [0] * 101
for i in range(a):
	c[int(b[i])] += 1
for i in range(101):
	if c[i] == 1:
		print(i)
		break


def lonelyinteger(a):
	answer = 0
	counts = {a[i]: 0 for i in range(len(a))}
	for i in range(len(a)):
		counts[a[i]] += 1
	for i in counts:
		if counts[i] == 1:
			answer = i
			break
	return answer
a = int(input())
b = [int(i) for i in input().split()]
print(lonelyinteger(b))


def lonelyinteger(a):
	a = list(a)
	a.sort()
	i = 0
	answer = a[i]
	while i < len(a) - 1:
		if a[i] == a[i + 1]:
			i += 2
		else:
			break
	return a[i]
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	count = []
	for i in a:
		if i in count:
			count.remove(i)
		else:
			count.append(i)
	return count[0]
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


a = input()
a = input()
a = a.split()
i = ''
list1 = []
for i in a:
	if i in list1:
		list1.remove(i)
	else:
		list1.append(i)
print(list1[0])


def lonelyinteger(a):
	counts = {}
	for element in a:
		if element not in counts:
			counts[element] = 1
		else:
			counts.pop(element, None)
	return list(counts)[0]
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	s = set()
	for i in a:
		if i in s:
			s.remove(i)
		else:
			s.add(i)
	return list(s)[0]
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	myhash = {}
	for x in a:
		if x in myhash:
			myhash[x] = 'pair'
		else:
			myhash[x] = 'single'
	for (x, y) in myhash.items():
		if y == 'single':
			return x
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	a = sorted(a)
	if len(a) < 3:
		return a[0]
	elif a[0] != a[1]:
		return a[0]
	else:
		return lonelyinteger(a[2:])
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


from operator import itemgetter

def lonelyinteger(a):
	d = {}
	for x in a:
		d[x] = d.get(x, 0) + 1
	return sorted(d.items(), key=itemgetter(1))[0][0]
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	d = {}
	for e in a:
		d[e] = d.get(e, 0) + 1
	for (e, v) in d.items():
		if v == 1:
			return e
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


n = int(input())
a = input().split()
v = [int(x) for x in a]
d = dict()
for i in range(0, n):
	try:
		d[v[i]] += 1
	except KeyError:
		d[v[i]] = 1
for a in d:
	if d[a] == 1:
		print(a)
		break


def lonelyinteger(a):
	dict = {}
	for x in a:
		if x in dict:
			del dict[x]
		else:
			dict[x] = 1
	answer = 0
	for key in dict.keys():
		answer = key
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	while len(a) != 1:
		if a[0] == a[1]:
			a.remove(a[0])
			a.remove(a[0])
		else:
			return a[0]
	return a[0]

def checkelements(a):
	if a[0] >= 0 & a[len(a) - 1] >= 0 & a[len(a) - 1] <= 100:
		return True
	else:
		return False
a = int(input())
b = sorted(list(map(int, input().strip().split(' '))))
if len(b) == a:
	if a % 2 == 1:
		if a >= 0 & a <= 100:
			if checkelements(b):
				print(lonelyinteger(b))
else:
	print('Try')


def lonelyinteger(a):
	s = set()
	for i in a:
		if i in s:
			s.remove(i)
		else:
			s.add(i)
	remaining = list(s)
	return remaining[0]
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	answer = 0
	for i in a:
		answer ^= i
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	answer = 0
	count = {}
	for i in a:
		if i in count:
			count[i] += 1
		else:
			count[i] = 1
	v = list(count.values())
	k = list(count.keys())
	answer = k[v.index(min(v))]
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	a = sorted(a)
	return lonelyHelper(a, 0, len(a) - 1)

def lonelyHelper(a, low, high):
	if low == high:
		return a[low]
	else:
		check = (low + high) // 2
		if a[check] == a[check + 1]:
			if check % 2 == 0:
				return lonelyHelper(a, check + 2, high)
			else:
				return lonelyHelper(a, low, check - 1)
		elif check % 2 == 0:
			return lonelyHelper(a, low, check)
		else:
			return lonelyHelper(a, check + 1, high)
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


from collections import Counter
s = int(input())
r = input().strip()
din = list(map(int, r.split(' ')))
akh = set(map(int, r.split(' ')))
rs = Counter(din)
sre = list(akh)
for i in range(s):
	krish = sre[i]
	if rs[krish] == 1:
		print(krish)
		break


def lonelyinteger(a):
	b = sorted(a)
	for i in range(0, len(b) // 2):
		if b[2 * i] != b[2 * i + 1]:
			return b[2 * i]
	return b[-1]
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	total = 0
	for x in a:
		total ^= x
	return total
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	a = list(sorted(a))
	for i in range(len(a)):
		if a[i - 1:i] != a[i:i + 1] and a[i:i + 1] != a[i + 1:i + 2]:
			return a[i]
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	temp = []
	for i in a:
		if i in temp:
			temp.remove(i)
		else:
			temp.append(i)
	answer = temp[0]
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a, length):
	for i in range(length):
		j = 0
		flag = True
		while flag and j < length:
			if i != j and a[i] == a[j]:
				flag = False
			j += 1
		if flag:
			return a[i]
	return 999
a = int(input())
b = list(map(int, input().strip().split(' ')))
print(lonelyinteger(b, a))


def lonelyinteger(a):
	answer = 0
	arr = list(a)
	for n in arr:
		if arr.count(n) == 1:
			answer = n
			break
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	lstofthingsSeen = []
	lstofrepeat = []
	for x in list(a):
		if x in lstofthingsSeen and x not in lstofrepeat:
			lstofrepeat.append(x)
		elif x not in lstofthingsSeen:
			lstofthingsSeen.append(x)
	for i in lstofrepeat:
		lstofthingsSeen.remove(i)
	answer = lstofthingsSeen[0]
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	s = set()
	for i in a:
		s ^= set([i])
	assert len(s) == 1
	return s.pop()
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	d = dict()
	for i in a:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	for j in d:
		if d[j] == 1:
			return j
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))


def lonelyinteger(a):
	answer = 0
	s = dict()
	for _ in a:
		if _ not in s:
			s[_] = None
		else:
			s.pop(_)
	answer = list(s.keys())[0]
	return answer
a = int(input())
b = map(int, input().strip().split(' '))
print(lonelyinteger(b))