Given an array of bird sightings where every element represents a bird type id, determine the id of the most frequently sighted type.  If more than 1 type has been spotted that maximum amount, return the smallest of their ids.

Example 

$arr=[1,1,2,2,3]$   

There are two each of types $1$ and $2$, and one sighting of type $3$.  Pick the lower of the two types seen twice: type $1$.  

Function Description

Complete the migratoryBirds function in the editor below.    

migratoryBirds has the following parameter(s):  

int arr[n]: the types of birds sighted   

Returns   

int: the lowest type id of the most frequently sighted birds   

Input Format

The first line contains an integer, $n$, the size of $\textbf{arr}$. 

The second line describes $\textbf{arr}$ as $n$ space-separated integers, each a type number of the bird sighted.

Constraints

$5\leq n\leq2\times10^5$
It is guaranteed that each type is $1$, $2$, $3$, $4$, or $5$.

Sample Input 0
6
1 4 4 4 5 3

Sample Output 0
4

Explanation 0

The different types of birds occur in the following frequencies:

Type $1$: $1$ bird
Type $2$: $0$ birds
Type $3$: $1$ bird
Type $4$: $3$ birds
Type $5$: $1$ bird

The type number that occurs at the highest frequency is type $4$, so we print $4$ as our answer.

Sample Input 1
11
1 2 3 4 5 4 3 2 1 3 4

Sample Output 1
3

Explanation 1

The different types of birds occur in the following frequencies:  

Type $1$: $2$  
Type $2$: $2$  
Type $3$: $3$  
Type $4$: $3$  
Type $5$: $1$  

Two types have a frequency of $3$, and the lower of those is type $3$.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
import sys
from collections import Counter
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
freq = Counter(types)
print(max(freq, key=freq.get))


import sys
from collections import Counter
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
p = Counter(types)
m = max(p.values())
f = [k for (k, v) in p.items() if v == m]
print(min(f))


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counts = [0] * 5
for i in range(n):
	counts[types[i] - 1] += 1
m = 0
mi = -1
for i in range(5):
	if counts[i] > m:
		m = counts[i]
		mi = i
print(mi + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counts = [0, 0, 0, 0, 0, 0]
for bird in types:
	counts[bird] += 1
winner = 0
for x in range(6):
	if counts[x] > counts[winner]:
		winner = x
print(winner)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counter = [0] * n
for type in types:
	counter[type] += 1
max_value = -1
max_index = -1
for i in range(n):
	if counter[i] > max_value:
		max_value = counter[i]
		max_index = i
print(max_index)


import sys
n = int(input().strip())
numbers = input().split(' ')
birds = [0, 0, 0, 0, 0]
for i in numbers:
	if i == '1':
		birds[0] += 1
	if i == '2':
		birds[1] += 1
	if i == '3':
		birds[2] += 1
	if i == '4':
		birds[3] += 1
	if i == '5':
		birds[4] += 1
print(birds.index(max(birds)) + 1)


import sys
from collections import Counter
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
cnt = Counter()
for bird in types:
	cnt[bird] += 1
print(cnt.most_common(1)[0][0])


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
lst = [0, 0, 0, 0, 0]
for i in types:
	lst[i - 1] += 1
best = 0
idx = 0
for i in range(5):
	if lst[i] > best:
		best = lst[i]
		idx = i
print(idx + 1)


import sys
highest = 0
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
for i in range(1, 6):
	if types.count(i) > highest:
		varhighest = i
		highest = types.count(i)
print(varhighest)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
res = [0] * 5
for i in types:
	res[i - 1] += 1
max_value = max(res)
print(res.index(max_value) + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counter = {}
for x in types:
	counter[x] = counter.get(x, 0) + 1
s = sorted(counter.items(), key=lambda x: x[1], reverse=True)
top_value = s[0][1]
v = list(filter(lambda x: x[1] == top_value, s))[0][0]
print(v)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counts = [0] * 5
for i in range(0, n):
	counts[types[i] - 1] += 1
print(counts.index(max(counts)) + 1)


import sys
from collections import Counter
import operator
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
mydict = dict(Counter(types))
maximum = max(mydict, key=mydict.get)
print(maximum)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split()))
number = 0
for i in set(types):
	if types.count(i) > number:
		number = types.count(i)
		f = i
l = []
for i in set(types):
	if types.count(i) == number:
		l += [i]
print(min(l))


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
(c1, c2, c3, c4, c5) = (0, 0, 0, 0, 0)
for i in types:
	if i == 1:
		c1 += 1
	elif i == 2:
		c2 += 1
	elif i == 3:
		c3 += 1
	elif i == 4:
		c4 += 1
	else:
		c5 += 1
if max(c1, c2, c3, c4, c5) == c1:
	print('1')
elif max(c1, c2, c3, c4, c5) == c2:
	print('2')
elif max(c1, c2, c3, c4, c5) == c3:
	print('3')
elif max(c1, c2, c3, c4, c5) == c4:
	print('4')
else:
	print('5')


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
m = []
m.append(types.count(1))
m.append(types.count(2))
m.append(types.count(3))
m.append(types.count(4))
m.append(types.count(5))
for i in range(5):
	if m[i] == max(m):
		print(i + 1)
		break


import sys
from collections import Counter
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counter = Counter(types)
print(max(counter, key=counter.get))


import collections
input()
types = [int(x) for x in input().strip().split()]
freq = collections.defaultdict(int)
for x in types:
	freq[x] += 1
maxType = max(freq.values())
for t in range(1, 6):
	if maxType == freq[t]:
		print(t)
		break


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
bird_list = [0, 0, 0, 0, 0]
for x in types:
	bird_list[x - 1] += 1
print(bird_list.index(max(bird_list)) + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
types_dict = {}
for bird in types:
	types_dict[bird] = types_dict.get(bird, 0) + 1
(max_id, max_count) = (None, -1)
for (id, count) in types_dict.items():
	if count > max_count:
		max_id = id
		max_count = count
	elif count == max_count and id < max_id:
		max_id = id
		max_count = count
print(max_id)


import sys
from collections import *
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
count = Counter(types)
(max_count, b_id) = (0, -1)
for i in count:
	if count[i] > max_count:
		max_count = count[i]
		b_id = i
	if count[i] == max_count:
		if b_id > i:
			b_id = i
print(b_id)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
l = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0]]
for i in types:
	if i == 1:
		l[0][1] += 1
	elif i == 2:
		l[1][1] += 1
	elif i == 3:
		l[2][1] += 1
	elif i == 4:
		l[3][1] += 1
	else:
		l[4][1] += 1
l.sort(key=lambda x: x[1], reverse=True)
print(l[0][0])


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
type_count = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
for type in types:
	type_count[type] += 1
max = 1
for key in type_count:
	if type_count[key] > type_count[max]:
		max = key
print(max)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
t1 = types.count(1)
t2 = types.count(2)
t3 = types.count(3)
t4 = types.count(4)
t5 = types.count(5)
maxtype = max(t1, t2, t3, t4, t5)
if t1 == maxtype:
	print('1')
elif t2 == maxtype:
	print('2')
elif t3 == maxtype:
	print('3')
elif t4 == maxtype:
	print('4')
else:
	print('5')


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
count = [0, 0, 0, 0, 0]
answer = None
test = -1
for i in range(n):
	count[types[0] - 1] = count[types[0] - 1] + 1
	types.pop(0)
for i in range(len(count)):
	if count[i] > test:
		answer = i
		test = count[i]
print(answer + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
d = dict()
for i in types:
	d[i] = d.get(i, 0) + 1
k = sorted(list(d.keys()))
v = list(d.values())
x = max(v)
for i in k:
	if d[i] is x:
		break
print(i)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
freq = [0, 0, 0, 0, 0]
for i in types:
	freq[i - 1] += 1
maxVal = 0
t = 1
c = 1
for i in freq:
	if i > maxVal:
		t = c
		maxVal = i
	c += 1
print(t)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
result = [0, 0, 0, 0, 0]
for i in range(n):
	result[types[i] - 1] += 1
max_idx = 0
max = 0
for i in range(5):
	if result[i] > max:
		max = result[i]
		max_idx = i
print(max_idx + 1)


import sys
from collections import Counter
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
c = Counter(types)
print(max(c, key=c.get))


import sys
from collections import Counter, OrderedDict

class OrderedCounter(Counter, OrderedDict):
	pass
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
types.sort()
typesd = OrderedCounter(types)
print(typesd.most_common(1)[0][0])


import sys
n = int(input().strip())
types = sorted(list(map(int, input().strip().split(' '))))
set_t = set(types)
min_num = 0
min_id = n + 1
for i in set_t:
	if types.count(i) > min_num:
		min_num = types.count(i)
		min_id = i
print(min_id)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
types.sort()
m = max(set(types), key=types.count)
print(m)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
maxVal = 0
maxIdx = 0
arr = [0, 0, 0, 0, 0]
for (idx, val) in enumerate(types):
	arr[val - 1] += 1
for (idx, val) in enumerate(arr):
	if maxVal < val:
		maxVal = val
		maxIdx = idx
print(maxIdx + 1)


from collections import Counter
n = int(input().strip())
birds = [int(height_temp) for height_temp in input().strip().split(' ')]
print(Counter(birds).most_common()[0][0])


import sys
from collections import Counter as C
n = int(input().strip())
types = C(list(map(int, input().strip().split(' '))))
best = types.most_common(1)[0]
for bird_type in types.most_common():
	if bird_type[1] < best[1]:
		break
	elif bird_type[0] < best[0]:
		best = bird_type
print(best[0])


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
type_freq = {}
for t in types:
	if t in type_freq:
		type_freq[t] += 1
	else:
		type_freq[t] = 1
max_type = 0
max_freq = 0
for (k, v) in type_freq.items():
	if type_freq[k] > max_freq:
		max_freq = v
		max_type = k
print(max_type)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
liste = [0] * 6
for i in range(n):
	liste[types[i] - 1] += 1
m = max(liste)
pos = 0
for i in range(n):
	if liste[i] == m:
		print(i + 1)
		exit()


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counts = [0] * 5
for bird in types:
	counts[bird - 1] += 1
max_count = 0
max_type = 0
for (t, num) in enumerate(counts):
	if num > max_count:
		max_count = num
		max_type = t
print(max_type + 1)


n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
typeList = [1] * 5
maxi = 0
for num in types:
	typeList[num - 1] += 1
	if typeList[maxi] < typeList[num - 1] or (typeList[maxi] == typeList[num - 1] and num - 1 < maxi):
		maxi = num - 1
print(maxi + 1)


import collections as col
import sys
n = int(input().strip())
types = list(map(int, input().strip().split()))
ctr = col.Counter(types)
mc = ctr.most_common()
minType = mc[0][0]
maxCnt = mc[0][1]
i = 1
while i < 5 and mc[i][1] == maxCnt:
	if mc[i][0] < minType:
		minType = mc[i][0]
	i += 1
print(minType)


n = int(input().strip())
types = list(map(int, input().split()))
t = {}
ans = []
for num in types:
	t[num] = t.get(num, 0) + 1
for key in t:
	if t[key] == max(t.values()):
		ans.append(key)
print(min(ans))


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
first = 0
second = 0
third = 0
fourth = 0
fifth = 0
for bird in types:
	if bird == 1:
		first = first + 1
	if bird == 2:
		second = second + 1
	if bird == 3:
		third = third + 1
	if bird == 4:
		fourth = fourth + 1
	if bird == 5:
		fifth = fifth + 1
which = 1
great = 0
if fifth >= great:
	which = 5
	great = fifth
if fourth >= great:
	which = 4
	great = fourth
if third >= great:
	which = 3
	great = third
if second >= great:
	which = 2
	great = second
if first >= great:
	great = first
	which = 1
print(which)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
dictval = {}
for bird in types:
	if bird in dictval:
		dictval[bird] += 1
	else:
		dictval[bird] = 1
maxcount = max(dictval.values())
maxitem = list(dictval.keys())[list(dictval.values()).index(maxcount)]
print(maxitem)


import sys
d = {}
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
for x in types:
	if x not in d:
		d[x] = types.count(x)
max_val = sorted([key for (key, value) in d.items() if value == max(d.values())])[0]
print(max_val)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counts = []
for item in range(1, 6):
	counts.append(types.count(item))
most = max(counts)
for item in range(len(counts)):
	if counts[item] == most:
		print(item + 1)
		quit()


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
count = [0] * 6
for i in range(len(types)):
	count[types[i]] += 1
highest = -1
index = -1
for j in range(len(count)):
	if highest < count[j]:
		highest = count[j]
		index = j
print(index)


import sys
from collections import Counter
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
common = Counter(types)
biggest = common.most_common(1)
final = []
for bird in biggest:
	final.append(bird[0])
print(min(final))


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
dic = {}
for i in types:
	dic[i] = dic.get(i, 0) + 1
maxi = types[0]
for i in dic.keys():
	if dic[i] > dic[maxi]:
		maxi = i
for i in dic.keys():
	if dic[i] == dic[maxi] and i < maxi:
		maxi = i
print(str(maxi))


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
(t_1, t_2, t_3, t_4, t_5, asdf) = (0, 0, 0, 0, 0, 0)
for birds in types:
	if birds == 1:
		t_1 = t_1 + 1
	elif birds == 2:
		t_2 = t_2 + 1
	elif birds == 3:
		t_3 = t_3 + 1
	elif birds == 4:
		t_4 = t_4 + 1
	else:
		t_5 = t_5 + 1
asdf = max(t_1, t_2, t_3, t_4, t_5)
if t_1 == asdf:
	print('1')
elif t_2 == asdf:
	print('2')
elif t_3 == asdf:
	print('3')
elif t_4 == asdf:
	print('4')
else:
	print('5')


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counts = {}
for bird in types:
	if bird not in counts:
		counts[bird] = 1
	else:
		counts[bird] += 1
highest_count = max(counts.values())
lowest_ID = None
for key in counts:
	if counts[key] == highest_count:
		if lowest_ID == None or int(key) < lowest_ID:
			lowest_ID = int(key)
print(lowest_ID)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
count = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
for bird in types:
	if int(bird) == 1:
		count[1] = +1
	if int(bird) == 2:
		count[2] += 1
	if int(bird) == 3:
		count[3] += 1
	if int(bird) == 4:
		count[4] += 1
	if int(bird) == 5:
		count[5] += 1
mostcommon = max(count, key=count.get)
print(mostcommon)


import sys
from collections import Counter
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
t = Counter(types)
maximum = t.most_common()[0][1]
print(min([x for (x, y) in t.most_common() if y == maximum]))


import sys
from collections import Counter
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
types_counter = Counter(types)
print(min([k for (k, v) in types_counter.items() if v == max(types_counter.values())]))


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
hist = [0, 0, 0, 0, 0, 0]
for i in types:
	hist[i] += 1
m = 0
for i in range(1, 6):
	if hist[i] > hist[m]:
		m = i
print(m)


import collections
import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
types = collections.Counter(types)
maxBird = max(types.values())
lowMost = [x for (x, y) in types.items() if y == maxBird]
lowMost = min(lowMost)
print(lowMost)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
freq = [0] * 5
for t in types:
	freq[t - 1] += 1
print(freq.index(max(freq)) + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
elements = [0 for x in range(0, 5)]
for t in types:
	elements[t - 1] += 1
print(elements.index(max(elements)) + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counts = {}
for t in types:
	if t in counts:
		counts[t] += 1
	else:
		counts[t] = 1
most_birds = None
most_birds_val = 0
for key in counts:
	if counts[key] > most_birds_val:
		most_birds_val = counts[key]
		most_birds = key
print(most_birds)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
birds = [0 for _ in range(5)]
for bird_type in types:
	birds[bird_type - 1] += 1
print(birds.index(max(birds)) + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
n1 = types.count(1)
n2 = types.count(2)
n3 = types.count(3)
n4 = types.count(4)
n5 = types.count(5)
x = max(n1, n2, n3, n4, n5)
if x == n1:
	print(1)
elif x == n2:
	print(2)
elif x == n3:
	print(3)
elif x == n4:
	print(4)
elif x == n5:
	print(5)


import sys
from collections import Counter
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
c = Counter(types)
modal_val = max(c.values())
mode_lst = {k: v for (k, v) in c.items() if v == modal_val}
print(min(mode_lst.keys()))


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
compare = [[], [], [], [], []]
maxLen = 0
mode = 0
for i in range(n):
	if types[i] == 1:
		compare[0].append(types[i])
	elif types[i] == 2:
		compare[1].append(types[i])
	elif types[i] == 3:
		compare[2].append(types[i])
	elif types[i] == 4:
		compare[3].append(types[i])
	elif types[i] == 5:
		compare[4].append(types[i])
for x in range(5):
	if len(compare[x]) > maxLen:
		maxLen = len(compare[x])
		mode = x + 1
print(mode)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
tablica = [0, 0, 0, 0, 0]
for i in range(n):
	if types[i] == 1:
		tablica[0] += 1
	elif types[i] == 2:
		tablica[1] += 1
	elif types[i] == 3:
		tablica[2] += 1
	elif types[i] == 4:
		tablica[3] += 1
	else:
		tablica[4] += 1
wynik = tablica.index(max(tablica)) + 1
print(wynik)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
(t1, t2, t3, t4, t5) = (0, 0, 0, 0, 0)
dic = {}
for i in types:
	if i == 1:
		t1 = t1 + 1
		dic[1] = t1
	elif i == 2:
		t2 = t2 + 1
		dic[2] = t2
	elif i == 3:
		t3 = t3 + 1
		dic[3] = t3
	elif i == 4:
		t4 = t4 + 1
		dic[4] = t4
	else:
		t5 = t5 + 1
		dic[5] = t5
print(max(dic, key=dic.get))


import sys
a = []
b = []
c = []
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
maxi = 0
for i in types:
	count = 0
	if i not in a:
		a.append(i)
		for j in types:
			if j == i:
				count = count + 1
		if count >= maxi:
			maxi = count
			b.append(i)
for i in b:
	count = 0
	for j in types:
		if j == i:
			count = count + 1
	if count == maxi:
		c.append(i)
d = min(c)
print(d)


import sys
from collections import Counter
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
print(Counter(types).most_common(1)[0][0])


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
freq = [0, 0, 0, 0, 0]
for i in types:
	freq[i - 1] += 1
comm = max(freq)
for i in range(5):
	if freq[i] == comm:
		print(i + 1)
		break


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
Arr = [0, 0, 0, 0, 0]
for i in types:
	Arr[i - 1] += 1
maxid = 0
max = Arr[0]
for j in range(1, 5):
	if Arr[j] > max:
		max = Arr[j]
		maxid = j
print(maxid + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
(id, max_count) = (0, 0)
for type in set(types):
	type_count = types.count(type)
	if max_count < type_count:
		(id, max_count) = (type, type_count)
	elif max_count == type_count:
		id = min(id, type)
print(id)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
count = [0] * 5
for i in types:
	count[i - 1] += 1
print(count.index(max(count)) + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
count = [0, 0, 0, 0, 0]
for i in range(n):
	if types[i] == 1:
		count[0] += 1
	if types[i] == 2:
		count[1] += 1
	if types[i] == 3:
		count[2] += 1
	if types[i] == 4:
		count[3] += 1
	if types[i] == 5:
		count[4] += 1
print(count.index(max(count)) + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
numBirds1 = 0
numBirds2 = 0
numBirds3 = 0
numBirds4 = 0
numBirds5 = 0
for i in types:
	if i == 1:
		numBirds1 += 1
	elif i == 2:
		numBirds2 += 1
	elif i == 3:
		numBirds3 += 1
	elif i == 4:
		numBirds4 += 1
	else:
		numBirds5 += 1
m = max(numBirds1, numBirds2, numBirds3, numBirds4, numBirds5)
if m == numBirds1:
	print(1)
elif m == numBirds2:
	print(2)
elif m == numBirds3:
	print(3)
elif m == numBirds4:
	print(4)
else:
	print(5)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
l = [0, 0, 0, 0, 0]
for bird in types:
	l[bird - 1] = l[bird - 1] + 1
max = 0
for i in range(len(l)):
	if l[i] > max:
		max = l[i]
		mark = i
print(mark + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counts = [0, 0, 0, 0, 0, 0]
for i in types:
	counts[i] += 1
print(counts.index(max(counts)))


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
birds = [0, 0, 0, 0, 0]
for i in types:
	birds[i - 1] += 1
lg = 0
n = 0
for j in range(5):
	if birds[j] > lg:
		lg = birds[j]
		n = j
print(n + 1)


import sys
k = 0
count = []
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
for k in range(1, 6):
	n = types.count(k)
	count.append(n)
print(count.index(max(count)) + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
result = 5
for i in range(1, 5):
	if types.count(i) > types.count(result):
		result = i
	elif types.count(i) == types.count(result):
		result = min(i, result)
print(result)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counter = [0 for ii in range(5)]
for t in types:
	counter[t - 1] += 1
hf = 0
for (nth, c) in enumerate(counter[1:], start=1):
	if c > counter[hf]:
		hf = nth
print(hf + 1)


n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
occur = [0, 0, 0, 0, 0]
for t in types:
	occur[t - 1] += 1
print(occur.index(max(occur)) + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
a = [types.count(x) for x in range(1, 6)]
b = max(a)
for k in range(0, 5):
	if a[k] == b:
		print(k + 1)
		break


from collections import Counter
input()
c = Counter((int(i) for i in input().split()))
result = max(c.keys(), key=lambda x: (c[x], -x))
print(result)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
amt = [0, 0, 0, 0, 0]
i = 0
while i < n:
	if types[i] is 1:
		amt[0] = amt[0] + 1
	if types[i] is 2:
		amt[1] = amt[1] + 1
	if types[i] is 3:
		amt[2] = amt[2] + 1
	if types[i] is 4:
		amt[3] = amt[3] + 1
	if types[i] is 5:
		amt[4] = amt[4] + 1
	i = i + 1
print(str(amt.index(max(amt)) + 1))


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
commonBirds = [0, 0, 0, 0, 0, 0]
for i in types:
	commonBirds[i] = commonBirds[i] + 1
common_bird_size = max(commonBirds)
common_bird_type = 7
for j in range(len(commonBirds)):
	if commonBirds[j] == common_bird_size and j < common_bird_type:
		common_bird_type = j
print(common_bird_type)


birds = int(input())
bird1 = 0
bird2 = 0
bird3 = 0
bird4 = 0
bird5 = 0
birdt = input().split()
for i in range(birds):
	bird = int(birdt[i])
	if bird == 1:
		bird1 = bird1 + 1
	if bird == 2:
		bird2 = bird2 + 1
	if bird == 3:
		bird3 = bird3 + 1
	if bird == 4:
		bird4 = bird4 + 1
	if bird == 5:
		bird5 = bird5 + 1
birdList = [bird1, bird2, bird3, bird4, bird5]
highestf = bird1
pos = 0
for i in range(1, len(birdList)):
	if birdList[i] > highestf:
		highestf = birdList[i]
		pos = i
print(pos + 1)


n = int(input())
types = [0] * 5
for bird in [int(i) for i in input().strip().split(' ')]:
	types[bird - 1] = types[bird - 1] + 1
print(1 + types.index(max(types)))


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
print(max(set(types), key=types.count))


import sys
n = int(input().strip())
types = list(input().strip().split(' '))
occ = [types.count('1')]
occ += [types.count('2')]
occ += [types.count('3')]
occ += [types.count('4')]
occ += [types.count('5')]
print(occ.index(max(occ)) + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
count = [0] * 5
for num in types:
	count[num - 1] = count[num - 1] + 1
max = -1
index = -1
for i in range(len(count)):
	if count[i] > max:
		max = count[i]
		index = i
print(index + 1)


import sys
from collections import defaultdict
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
count = defaultdict(int)
for type in types:
	count[type] += 1
print(max(count, key=count.get))


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
a = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
for i in range(0, len(types)):
	a[types[i]] += 1
b = 0
p = 0
for i in range(1, len(a)):
	if a[i] > b:
		b = a[i]
		p = i
print(p)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
import collections
counter = collections.Counter(types)
for (k, v) in counter.items():
	if v == max(counter.values()):
		print(k)
		break


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
c = {}
for x in types:
	if x in c.keys():
		c[x] += 1
	else:
		c[x] = 1
m = max(c.values())
for x in c.keys():
	if c[x] == m:
		print(x)
		break


n = int(input())
birds = input().split(' ')
for i in range(0, len(birds)):
	birds[i] = int(birds[i])
a = [0, 0, 0, 0, 0]
for i in range(0, len(birds)):
	a[birds[i] - 1] = a[birds[i] - 1] + 1
max = a[0]
nu = 0
for i in range(1, len(a)):
	if a[i] > max:
		max = a[i]
		nu = i
print(nu + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
count = [0, 0, 0, 0, 0]
for i in types:
	count[i - 1] += 1
aType = 0
theType = 0
for i in count:
	if count[aType] > count[theType]:
		theType = aType
	aType += 1
print(theType + 1)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
distinct_types = [1, 2, 3, 4, 5]
d = {}
min_freq = -1
for t in distinct_types:
	d[t] = 0
for t in types:
	d[t] += 1
for t in distinct_types:
	if d[t] > min_freq:
		min_freq = d[t]
		most_common = t
print(most_common)


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
counts = list([0, 0, 0, 0, 0, 0])
for i in types:
	counts[i] = counts[i] + 1
print(counts.index(max(counts)))


import sys
from collections import defaultdict
n = int(input().strip())
cts = defaultdict(int)
for typ in map(int, input().strip().split(' ')):
	cts[typ] += 1
print(-max(((ct, -typ) for (typ, ct) in cts.items()))[1])


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
print(max([(c, len(list(filter(lambda x: x == c, types)))) for c in range(1, 6)], key=lambda x: x[1])[0])


import sys
n = int(input().strip())
types = list(map(int, input().strip().split(' ')))
nums = [0, 0, 0, 0, 0]
for item in types:
	nums[item - 1] += 1
print(nums.index(max(nums)) + 1)