Mr. Anant Asankhya is the manager at the INFINITE hotel. The hotel has an infinite amount of rooms. 

One fine day, a finite number of tourists come to stay at the hotel. 

The tourists consist of:

→ A Captain.

→ An unknown group of families consisting of $\mbox{K}$ members per group where $\mbox{K}$ ≠ $\mbox{I}$.

The Captain was given a separate room, and the rest were given one room per group.

Mr. Anant has an unordered list of randomly arranged room entries. The list consists of the room numbers for all of the tourists. The room numbers will appear $\mbox{K}$ times per group except for the Captain's room. 

Mr. Anant needs you to help him find the Captain's room number.

The total number of tourists or the total number of groups of families is not known to you.

You only know the value of $\mbox{K}$ and the room number list.

Input Format

The first line consists of an integer, $\mbox{K}$, the size of each group.

The second line contains the unordered elements of the room number list.

Constraints

$1<K<1000$

Output Format

Output the Captain's room number.

Sample Input
5
1 2 3 6 5 4 4 2 5 3 6 1 6 5 3 2 4 1 2 5 1 4 3 6 8 4 3 1 5 6 2 

Sample Output
8

Explanation

The list of room numbers contains $31$ elements. Since $\mbox{K}$ is $5$, there must be $\boldsymbol{6}$ groups of families. In the given list, all of the numbers repeat $5$ times except for room number $8$.

 Hence, $8$ is the Captain's room number.

Difficulty: EASY
Tags: Data structures
Skill types: Data structures

Starter code:

Solutions:
from collections import Counter
K = int(input())
rooms = list(map(int, input().split()))
roomsspec = Counter(rooms)
cap = [elem for elem in roomsspec if roomsspec[elem] != K]
print(cap[0])


def __starting_point():
	k = int(input().strip())
	numbers = list(map(int, input().strip().split(' ')))
	print((sum(set(numbers)) * k - sum(numbers)) // (k - 1))
__starting_point()


k = int(input())
L = list(map(int, input().split()))
croom = (sum(set(L)) * k - sum(L)) // (k - 1)
print(croom)


from collections import Counter
n = input()
m = Counter(map(int, input().split()))
for (k, y) in m.items():
	if y == 1:
		print(k)


input()
a = set()
b = set()
for i in map(int, input().split()):
	b.add(i) if i in a else a.add(i)
print(*a - b)


from collections import Counter

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

def read_int_words():
	return map(int, input().split())
k = read_int()
roomsC = Counter(read_int_words())
for (k, v) in roomsC.items():
	if v == 1:
		print(k)


from collections import Counter
K = int(input())
print(Counter(list(input().split())).most_common()[-1][0])


from collections import Counter
K = input()
room_numbers = map(int, input().split())
room_counts = Counter(room_numbers)
print(room_counts.most_common()[-1][0])


from collections import Counter
input()
print(Counter(input().split()).most_common()[-1][0])


familySize = int(input())
rooms = list(map(int, input().split()))
roomDict = dict()
for i in rooms:
	if i not in roomDict.keys():
		roomDict[i] = 1
	else:
		roomDict[i] += 1
for (k, v) in roomDict.items():
	if v == 1:
		print(k)


import collections
C = collections.Counter()
input()
for x in input().split():
	C[x] += 1
for x in C.items():
	if x[1] == 1:
		print(x[0])
		break


k = int(input())
a = input().split()
b = sum(set(map(int, a)))
c = sum(map(int, a))
r = (b * k - c) / (k - 1)
print('%0.0f' % r)


k = int(input())
lst = list(map(int, input().split()))
st = set(lst)
print(round((sum(st) * k - sum(lst)) / (k - 1)))


from collections import Counter
n = input()
cnt = Counter(input().strip().split())
for i in cnt.elements():
	if cnt[i] == 1:
		print(i)
		break


from collections import Counter
k = int(input())
s = Counter(map(int, input().split()))
print([d for (d, v) in s.items() if v == 1][0])


n = int(input())
l = list(map(int, input().split()))
s = set(l)
print(int((sum(s) * n - sum(l)) / (n - 1)))


from collections import Counter
k = int(input())
rooms = list(map(int, input().split()))
roomsc = Counter(rooms)
for room in roomsc:
	if roomsc[room] == 1:
		print(room)
		break


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
s = len(l)
for x in range(0, s, n):
	if x == s - 1:
		print(l[x])
		break
	elif l[x] != l[x + 1]:
		print(l[x])
		break


_ = int(input())
M = {}
for i in map(int, input().split()):
	M[i] = M.get(i, 0) + 1
for (k, v) in M.items():
	if v == 1:
		print(k)


k = int(input())
l = [int(x) for x in input().split()]
s = set(l)
tc = {}
for x in l:
	if x in tc:
		tc[x] = tc[x] + 1
	else:
		tc[x] = 1
for x in tc:
	if tc[x] == 1:
		p = x
print(p)


n = int(input())
l = list(map(int, input().split()))
sm = sum(l)
s = set(l)
print(round((sum(s) * n - sm) / (n - 1)))


from collections import Counter
k = int(input())
rooms = map(int, input().split())
uniques = Counter(rooms)
for (k, v) in uniques.items():
	if v == 1:
		print(k)
		break


from collections import Counter
a = int(input())
b = input()
b = Counter(b.split())
for i in b.items():
	if i[1] == 1:
		print(i[0])
		break


k = int(input())
l = list(map(int, input().split()))
l.sort()
size = len(l)
if size == 1:
	print(l[0])
if size > 1 and l[0] != l[1]:
	print(l[0])
if size > 1 and l[size - 1] != l[size - 2]:
	print(l[size - 1])
for i in range(1, size - 1):
	if l[i] != l[i - 1] and l[i] != l[i + 1]:
		print(l[i])
		break


K = int(input())
d = dict()
list = map(int, input().split())
for x in list:
	if x in d.keys():
		d[x] += 1
	else:
		d[x] = 1
print(''.join((str(x) for x in d.keys() if d[x] != K)))


from collections import Counter
_ = input()
c = Counter(input().strip().split())
print(c.most_common()[-1][0])


from collections import defaultdict
input()
sdict = defaultdict(int)
slist = map(int, input().split())
for i in slist:
	sdict[i] += 1
print(*[x for (x, y) in sdict.items() if y == 1])


from collections import Counter
k = int(input())
counter = Counter(list(map(int, input().split())))
for (key, val) in counter.items():
	if val == 1:
		print(key)
		break


k = int(input())
rooms = [int(x) for x in input().strip().split()]
one_time = set()
many_times = set()
while rooms:
	room = rooms.pop()
	if room in one_time:
		one_time.remove(room)
		many_times.add(room)
	elif room not in many_times:
		one_time.add(room)
for room in one_time:
	print(room)


K = int(input())
r_list = [i for i in map(int, input().split())]
r_set = set(r_list)
print((sum(r_set) * K - sum(r_list)) // (K - 1))


familySize = int(input())
numbers = input().split()
table = {}
for num in numbers:
	if num in table:
		table[num] += 1
	else:
		table[num] = 1
for room in table:
	if table[room] == 1:
		print(room)


k = int(input())
l = list(map(int, input().split()))
s = set(l)
print(int((sum(s) * k - sum(l)) / (k - 1)))


from collections import Counter
input()
for (k, v) in Counter(input().split()).items():
	if v == 1:
		print(k)


n = int(input())
l = list(input().split())
from collections import defaultdict
d = defaultdict(int)
s = list(set(l))
for i in s:
	d[i] = 0
for i in range(len(l)):
	d[l[i]] += 1
for i in s:
	if d[i] == 1:
		print(i)


n = int(input())
l = [int(x) for x in input().split()]
s = set(l)
print((sum(s) * n - sum(l)) // (n - 1))


seen = set()
mult = set()
n = int(input())
for i in input().split():
	if i in seen:
		mult.add(i)
	else:
		seen.add(i)
print((seen - mult).pop())


n = int(input())
list_rooms = input().split()
size = len(list_rooms)
list_rooms.sort()
for i in range(0, size, n):
	if i < size - 1 and list_rooms[i] == list_rooms[i + 1]:
		continue
	else:
		print(int(list_rooms[i]))
		break


n = int(input())
dic = {}
for x in input().split():
	dic[x] = dic.get(x, 0) + 1
for key in dic:
	if dic[key] != n:
		print(key)
		break


input()
digits = input().split()
counts = dict()
for num in digits:
	counts[num] = counts.get(num, 0) + 1
number = None
number_count = None
for (num, count) in counts.items():
	if number is None or count < number_count:
		number = num
		number_count = count
print(number)


from collections import Counter
group_size = int(input())
room_dict = Counter([int(i) for i in input().split()])
for room in room_dict:
	if room_dict[room] == 1:
		print(room)
		break


K = int(input())
a = map(int, input().split())
from collections import Counter
counts = Counter(a)
for (num, count) in counts.items():
	if count != K:
		print(num)
		break


K = int(input())
set_S = set()
sumlist_S = 0
for i in input().split():
	I = int(i)
	set_S.add(I)
	sumlist_S += I
print((sum(set_S) * K - sumlist_S) // (K - 1))


from collections import Counter
n = int(input())
k = [int(i) for i in input().split()]
a = Counter(k)
for i in a:
	if a[i] == 1:
		print(i)


from collections import defaultdict
a = defaultdict(int)
input()
l = input().split()
for i in l:
	a[i] = a[i] + 1
for i in a:
	if a[i] == 1:
		print(i)
		break


from collections import Counter
input()
print(Counter(map(int, input().split())).most_common()[-1][0])


import collections
K = int(input())
s = set()
lis = list(map(int, input().strip().split()))
aux = [i for (i, j) in collections.Counter(lis).items() if j == 1]
print(aux[0])


input()
a = list(input().split())
p = {}
for i in a:
	if i in p:
		p[i] += 1
	else:
		p[i] = 1
x = sorted(p, key=lambda x: p[x])
print(x[0])


n = int(input().strip())
items = list(map(int, input().strip().split(' ')))
numbers = set()
unique = set()
for item in items:
	if item not in numbers:
		numbers.add(item)
		unique.add(item)
	else:
		unique.discard(item)
print(unique.pop())


from collections import Counter
k = int(input())
lis = sorted(map(int, input().split()))
count = Counter(lis)
for i in count:
	if count.get(i) == 1:
		print(i)


import collections
K = int(input())
arr = map(int, input().split())
c = dict(collections.Counter(arr))
for (k, v) in c.items():
	if v == 1:
		print(k)
		break


k = int(input())
room_number_list = list(map(int, input().split()))
room_number_set = set(room_number_list)
room_number_list_sum = sum(room_number_list)
room_number_set_sum = sum(room_number_set) * k
diff = room_number_set_sum - room_number_list_sum
for i in room_number_set:
	if diff == (k - 1) * i:
		print(i)
		break


k = int(input())
unique_room_numbers = set()
sum_room_numbers = 0
for n in input().split():
	int_n = int(n)
	unique_room_numbers.add(int_n)
	sum_room_numbers += int_n
unique_room_numbers_times_k = k * sum(unique_room_numbers)
for n in unique_room_numbers:
	if sum_room_numbers == unique_room_numbers_times_k - n * (k - 1):
		print(n)
		exit()


k = int(input())
s = set()
r = set()
for x in map(int, input().split()):
	if x in s:
		s.remove(x)
		r.add(x)
	elif x not in r:
		s.add(x)
print(s.pop())


from collections import OrderedDict
k = int(input())
d = OrderedDict()
lis = list(map(int, input().strip().split()))
for i in range(len(lis)):
	if lis[i] in d:
		d[lis[i]] += 1
	else:
		d[lis[i]] = 1
for poop in d:
	if d[poop] == 1:
		print(poop)
		break


def ans(d):
	for (i, j) in d.items():
		if j == 1:
			print(i)
			return
input()
room_no = input().split(' ')
d = {}
for i in room_no:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
ans(d)


import collections
input()
cnt = collections.Counter(input().split())
for i in cnt:
	if cnt[i] == 1:
		print(i)


n = int(input())
set_a = set()
set_b = set()
for item in map(int, input().strip().split()):
	if item not in set_a:
		set_a.add(item)
	else:
		set_a.discard(item)
		set_b.add(item)
print(sum(set_a - set_b))


from collections import Counter
group_size = int(input())
rooms = Counter(map(int, str(input()).split()))
print([room for room in rooms.keys() if rooms[room] != group_size][0])


from collections import Counter
__author__ = 'namii'
K = int(input())
setti = Counter(input().split())
print(sorted(setti.items(), key=lambda x: x[1])[0][0])


k = int(input())
room_nums = map(int, input().split())
from collections import Counter
counts = Counter(room_nums)
for (num, count) in counts.items():
	if count != k:
		print(num)
		break


from collections import Counter
K = int(input())
print(Counter(map(int, input().split())).most_common()[-1][0])


k = int(input())
all_rooms = set()
family_rooms = set()
for s in input().split():
	r = {int(s)}
	family_rooms |= all_rooms.intersection(r)
	all_rooms |= r
print((all_rooms - family_rooms).pop())


from collections import Counter
k = int(input())
room_list = input().split(' ')
count = Counter(room_list)
for items in count:
	if count[items] != k:
		print(items)
		break
	else:
		continue


from collections import Counter
k = int(input())
rooms = input().split()
m = Counter(rooms)
for key in m:
	if m[key] == 1:
		print(key)


K = int(input())
rooms = list(map(int, input().split()))
unique_rooms = set(rooms)
captains_room = (sum(unique_rooms) * K - sum(rooms)) // (K - 1)
print(captains_room)


a = int(input())
l = list(map(int, input().split()))
s = list(set(l))
print((sum(s * a) - sum(l)) // (a - 1))


from collections import Counter
nb = int(input())
ls = list(Counter(map(int, input().split())).items())
ls.sort(key=lambda xs: xs[1])
print(ls[0][0])


numingroup = int(input())
roomnos = set()
sumoflist = 0
for touristroomnum in input().split():
	num = int(touristroomnum)
	roomnos.add(num)
	sumoflist += num
sumofuniqueroomnums = sum(roomnos)
setdiff = numingroup * sumofuniqueroomnums - sumoflist
captain = setdiff // (numingroup - 1)
print(captain)


input()
lst = input().split()
first = set()
second = set()
for d in lst:
	if d in first:
		second.add(d)
	else:
		first.add(d)
print((first ^ second).pop())


k = int(input())
rooms = [int(x) for x in input().split()]
my_set = set()
captains_room = set()
for room in rooms:
	if room in my_set:
		captains_room.discard(room)
	else:
		my_set.add(room)
		captains_room.add(room)
print(list(captains_room)[0])


from collections import Counter
input()
c = Counter(map(int, input().split()))
(e, n) = c.most_common()[-1]
print(e)


k = input()
rooms = input().split()
s1 = set(rooms)
roomsDict = {}
for room in rooms:
	if room in roomsDict:
		roomsDict[room] += 1
		if roomsDict[room] == 5:
			s1.discard(room)
	else:
		roomsDict.setdefault(room, 1)
for x in s1:
	print(int(x))


from collections import Counter
S = int(input())
A = list(map(int, input().split()))
counts = Counter(A)
B = set(A)
for i in B:
	if counts.get(i) is 1:
		print(i)


from collections import defaultdict
rooms = defaultdict(int)
(_, entries) = (input(), input().split())
for entry in entries:
	rooms[entry] += 1
for number in rooms:
	if rooms[number] is 1:
		print(number)
		break


from collections import defaultdict
n = int(input())
s1 = [int(x) for x in input().split()]
dt = defaultdict(int)
for x in s1:
	dt[x] += 1
for x in dt:
	if dt[x] != n:
		print(x)


k = int(input())
lst = list(input().split())
from collections import defaultdict
dic = defaultdict(int)
for n in lst:
	dic[n] += 1
for k in dic.keys():
	if dic[k] == 1:
		print(k)
		break


from collections import Counter
input()
s = Counter(map(int, input().split()))
for a in s:
	if s[a] == 1:
		print(a)


from collections import Counter as c
input()
a = c(input().split())
for i in a.keys():
	if a[i] == 1:
		print(i)


input()
numbers = list(map(int, input().split()))
possibilities = list(set(numbers)) * 2
for num in numbers:
	if num in possibilities:
		possibilities.remove(num)
print(possibilities.pop())


from collections import Counter
num = int(input())
k = Counter(map(int, input().split()))
for (l, d) in k.items():
	if d == 1:
		print(l)
		break


n = int(input())
s1 = list(map(int, input().split()))
print(int((n * sum(set(s1)) - sum(s1)) / (n - 1)))


n = int(input())
lRooms = input().split()
size = len(lRooms)
lRooms.sort()
for i in range(0, size, n):
	if i < size - 1 and lRooms[i] == lRooms[i + 1]:
		continue
	else:
		print(int(lRooms[i]))
		break


k = int(input())
assign = map(int, input().split())
tmp = set()
family = set()
for i in assign:
	if i not in tmp:
		tmp.add(i)
	else:
		family.add(i)
print((tmp - family).pop())


from collections import Counter
input()
data = Counter()
for i in input().split():
	data[i] += 1
print(list(filter(lambda x: data[x] == 1, data))[0])


k = int(input())
l = list(map(int, input().split()))
s = set(l)
print((sum(s) * k - sum(l)) // (k - 1))


from collections import defaultdict
k = int(input())
d = defaultdict(int)
l = [int(x) for x in input().split()]
for x in l:
	d[x] += 1
	if d[x] == k:
		d.pop(x)
print(list(d.items())[0][0])


import collections
_ = input()
c = collections.Counter(input().split())
print(c.most_common()[-1][0])