Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given $n$ scores. Store them in a list and find the score of the runner-up. 

Input Format

The first line contains $n$. The second line contains an array $\mbox{A}[$ $\mathrm{~l~}$ of $n$ integers each separated by a space.  

Constraints

$2\leq n\leq10$  
$-100\le A[i]\le100$

Output Format

Print the runner-up score.

Sample Input 0
5
2 3 6 6 5

Sample Output 0
5

Explanation 0

Given list is $[2,3,6,6,5]$. The maximum score is $\boldsymbol{6}$, second maximum is $5$. Hence, we print $5$ as the runner-up score.

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

Starter code:

Solutions:
num = input()
a = input().split()
highest = None
second = None
for i in range(0, len(a)):
	temp = int(a[i])
	if highest == None or highest < temp:
		second = highest
		highest = temp
	elif second == None or second == highest or (second < temp and temp != highest):
		second = temp
print(second)


n = input()
a = map(int, input().split())
a = list(set(a))
a.remove(max(a))
print(max(a))


import sys
n = sys.stdin.readline().strip()
arr = sys.stdin.readline().strip()
arr = arr.split(' ')
arr = list(map(int, arr))
max1 = arr[0]
max2 = arr[0]
for x in arr[1:]:
	if x > max1:
		if max1 > max2:
			max2 = max1
		max1 = x
	if x < max1:
		if max1 == max2:
			max2 = x
		if x > max2:
			max2 = x
print(max2)


input()
a = [int(k) for k in input().split(' ')]
a.sort()
a.reverse()
for i in range(len(a)):
	if a[i] != a[0]:
		print(a[i])
		break


a = int(input())
list = sorted(map(int, input().split()))
max = list[-1]
while max in list:
	del list[-1]
print(list[-1])


n = int(input())
num_str_ar = input().strip().split()
num_ar = list(map(int, num_str_ar))
set_tmp = set(num_ar)
final_ar = list(set_tmp)
final_ar.sort()
print(final_ar[-2])


def findSM(l):
	(f, s) = (l[0], l[0])
	for i in range(len(l)):
		if l[i] > f:
			(s, f) = (f, l[i])
		elif l[i] < f:
			if f == s:
				s = l[i]
			elif l[i] > s:
				s = l[i]
	return s
n = int(input())
l = input().split()
for i in range(n):
	l[i] = int(l[i])
print(findSM(l))


input()
a = set(map(int, input().split(' ')))
print(sorted(a)[-2])


input()
input_buffer = list(map(int, input().split()))
max_num = -101
for num in input_buffer:
	if num > max_num:
		max_num = num
while max_num in input_buffer:
	input_buffer.remove(max_num)
max_num = -101
for num in input_buffer:
	if num > max_num:
		max_num = num
print(max_num)


ra_len = int(input())
ra = list(map(int, input().split()))
ultimate = max(ra)
penultimate = ultimate
while penultimate == ultimate:
	ra.remove(ultimate)
	penultimate = max(ra)
print(penultimate)


from heapq import nlargest
N = int(input())
A = {int(a) for a in input().split()}
result = nlargest(2, A)[1]
print(result)


n = int(input())
l = list(map(int, input().split()))
l = list(set(l))
l.sort()
print(l[-2])


input()
nums = input()
numbers = nums.split(' ')
num_list = []
for number in numbers:
	num_list.append(int(number))
max_val = 101
count = 0
for number in sorted(num_list, reverse=True):
	if number < max_val:
		max_val = number
		count += 1
	if count == 2:
		print(max_val)
		break


def secondMax(numbers):
	maximum = min(numbers)
	secondMax = maximum
	for number in numbers:
		if number > maximum:
			maximum = number
	for number in numbers:
		if number > secondMax and number < maximum and (number != maximum):
			secondMax = number
	return secondMax
count = int(input())
numbers = list(map(int, input().strip().split(' ')))
print(secondMax(numbers))


maxval = int(input())
tempstring = input()
lis = list(map(int, tempstring.split()))
finalset = set(lis)
highest = max(finalset)
finalset.remove(highest)
print(max(finalset))


n = int(input(''))
lis = input('')
lis = lis.split()
lisnew = []
while lis:
	lisnew.append(int(lis.pop()))
maxval = max(lisnew)
while maxval in lisnew:
	lisnew.remove(maxval)
print(max(lisnew))


import sys
n = sys.stdin.readline()
print(sorted([int(x) for x in set(sys.stdin.readline().split())], reverse=True)[1])


N = int(input())
liste = input().split()
i = 0
for nombre in liste:
	liste[i] = int(nombre)
	i += 1
maximum = max(liste)
preMax = min(liste)
for nombre in liste:
	if nombre < maximum and nombre > preMax:
		preMax = nombre
print(preMax)


N = int(input())
A = sorted(set(list(map(int, input().split()))))
print(A[-2])


ct = int(input())
strin = str(input()).split(' ')
intin = list(map(int, strin))
intin.sort()
maxi = intin[ct - 1]
loc = ct - 2
second = intin[loc]
while second == maxi:
	loc -= 1
	second = intin[loc]
print(second)


import heapq
_ = input()
lst = list(map(int, input().split()))
m = max(lst)
print(sorted([i for i in lst if i != m]).pop())


n = int(input())
l = sorted(map(int, input().split()))
for x in l[-2::-1]:
	if x != l[-1]:
		print(x)
		break


input()
ar = [int(e) for e in input().split()]
(x, y) = (ar[0], None)
for z in ar:
	if x != z:
		y = z
		break
if x < y:
	(x, y) = (y, x)
for z in ar:
	if x < z:
		(x, y) = (z, x)
	elif x != z and y < z:
		y = z
print(y)


n = int(input())
s = input()
li = s.split(' ')
li = list(set(li))
li = list(map(int, li))
li.sort()
l = len(li)
print(li[l - 2])


n = int(input())
lst = list(map(int, input().split()))
m = max(lst)
while m in lst:
	lst.remove(m)
print(max(lst))


M = input()
N = input()
lis = N.split()
Nlis = list(map(int, lis))
Nlis.sort()
sec_largest = Nlis[0]
length = len(Nlis)
for x in range(len(Nlis)):
	if max(Nlis) > Nlis[x]:
		sec_largest = Nlis[x]
print(sec_largest)


input()
nums = sorted([int(x) for x in input().split()])
print([x for x in nums if x != nums[-1]][-1])


def __starting_point():
	n = int(input())
	arr = list(map(int, input().split()))
	first = max(arr)
	print(max(list([a for a in arr if a != first])))
__starting_point()


import sys
N = int(sys.stdin.readline())
number_list = sys.stdin.readline().split(' ')
number_list = [int(x) for x in number_list]
biggest_number = -101
second_biggest_number = -102
for i in number_list:
	if i > biggest_number:
		second_biggest_number = biggest_number
		biggest_number = i
		next
	elif i == biggest_number:
		next
	elif i > second_biggest_number:
		second_biggest_number = i
print(second_biggest_number)


n = int(input())
st = input()
gr = st.split(' ')
for k in range(len(gr)):
	gr[k] = int(gr[k])
m = max(gr)
while m in gr:
	gr.remove(m)
print(max(gr))


import sys
sys.path
T = int(input())
S = input()
R = S.split(' ', len(S))
L = []
for x in R:
	L.append(int(x))
for r in range(0, len(L)):
	for w in range(0, len(L)):
		if L[r] >= L[w]:
			t = L[r]
			L[r] = L[w]
			L[w] = t
for q in range(0, len(L)):
	if L[q] < L[q - 1]:
		print(L[q])
		break


n = int(input())
l = str(input()).split()
l = list(map(lambda x: int(x), l))

def mm(l):
	if len(l) == 0:
		return 0
	res = l[0]
	for i in range(len(l)):
		if res < l[i]:
			res = l[i]
	return res
x = mm(l)
while x in l:
	l.remove(x)
print(mm(l))


arraySize = int(input())
array = []
array = input()
numbers = map(int, array.split())
sortedArray = []
for i in numbers:
	sortedArray.append(i)
sortedArray.sort()
sortedArray.reverse()
for i in range(arraySize):
	if sortedArray[i + 1] < sortedArray[i]:
		temp = sortedArray[i + 1]
		break
print(temp)


n = input()
xs = set((int(s) for s in input().split()))
print(list(sorted(xs, reverse=True))[1])


num = int(input())
ll = list(map(int, input().split(' ')))
for i in range(len(ll)):
	for j in range(i, len(ll)):
		if ll[j] > ll[i]:
			temp = ll[i]
			ll[i] = ll[j]
			ll[j] = temp
for i in range(len(ll)):
	if ll[i] > ll[i + 1]:
		print(ll[i + 1])
		break


int(input())
l = [int(a) for a in input().split()]
print(sorted(set(l))[-2])


n = int(input().strip())
max1 = None
max2 = None
nums = set(map(int, input().strip().split()))
for num in nums:
	if max1 == None or num > max1:
		if max2 == None or max1 > max2:
			max2 = max1
		max1 = num
	elif max2 == None or num > max2:
		max2 = num
print(str(max2))


n = input()
rs = input().strip()
rs = list(map(int, rs.split(' ')))
l = max(rs)
rs.remove(max(rs))
while max(rs) == l:
	rs.remove(max(rs))
print(max(rs))


def sec_max(n):
	print(list(sorted(set(map(int, input().split()))))[-2])
sec_max(int(input()))


n = int(input())
l = list(map(int, input().split(' ', maxsplit=n)))
max1 = l[0]
max2 = -101
for i in l:
	if i > max1:
		max2 = max1
		max1 = i
	elif max2 < i < max1:
		max2 = i
if max2 == -101:
	max2 = None
print(max2)


def main():
	input()
	print(sorted(set(map(int, input().split())))[-2])
main()


n = int(input())
inp = input()
li = list(map(int, inp.split(' ')))
max1 = -200
max2 = -200
for temp in li:
	if temp > max1:
		max2 = max1
		max1 = temp
	elif temp > max2 and temp != max1:
		max2 = temp
print(max2)


n = int(input())
a = sorted([int(num) for num in input().split()])
b = []
for i in a:
	if i not in b:
		b.append(i)
print(b[len(b) - 2])


import sys
input()
nums = list(map(int, input().split(' ')))
fmax = -101
smax = -101
for i in range(0, len(nums)):
	if nums[i] > fmax:
		smax = fmax
		fmax = nums[i]
	elif nums[i] < fmax and nums[i] > smax:
		smax = nums[i]
print(smax)


N = int(input())
A = list(map(int, input().split()))
max_of_A = max(A)
while max_of_A in A:
	A.remove(max_of_A)
print(max(A))


input1 = int(input())
input2 = input()
list1 = input2.split()
list2 = []
for x in range(len(list1)):
	a = int(list1[x])
	list2.append(a)
list2.sort()
if list2[-1] == list2[-2]:
	myset = set(list2)
	list3 = list(myset)
	list3.sort()
	print(list3[-2])
else:
	print(list2[-2])


n = int(input())
print(sorted(list(set([int(x) for x in input().strip().split()])))[::-1][1])


def mergeSort(lst):
	if len(lst) == 1:
		return lst
	else:
		m = len(lst) // 2
		l1 = mergeSort(lst[:m])
		l2 = mergeSort(lst[m:])
		lret = []
		i = 0
		j = 0
		while i < len(l1) and j < len(l2):
			if l1[i] < l2[j]:
				lret.append(l1[i])
				i += 1
			else:
				lret.append(l2[j])
				j += 1
		if len(l2[j:]) == 0:
			lret.extend(l1[i:])
		else:
			lret.extend(l2[j:])
		return lret

def get2ndGreatest(lst):
	lst = mergeSort(lst)
	ac = lst[-1]
	for i in reversed(range(len(lst))):
		if lst[i] != ac:
			return lst[i]
	return ac
n = int(input())
lst = list(map(int, input().strip().split()))
print(get2ndGreatest(lst))


def q(l):
	l1 = len(l)
	if l[l1 - 2] == l[l1 - 1]:
		return q(l[:l1 - 1])
	else:
		return l[l1 - 2]

def g():
	x = str(input())
	y = x.split()
	l = len(y)
	z = []
	for i in y:
		z.append(int(i))
	z.sort()
	return q(z)
n = int(input())
print(g())


testcase = int(input())
l = [int(x) for x in input().strip().split(' ')]
ll = []
for i in l:
	if i in ll:
		continue
	else:
		ll.append(i)
ll.sort()
print(ll[len(ll) - 2])


import fileinput
lines = fileinput.input()
N = int(lines[0])
A = list(set(map(int, lines[1].split(' '))))
A.sort()
print(A[len(A) - 2])


input()
ar = [int(i) for i in input().split()]
l1 = l2 = ar[0]
for i in ar:
	l1_ = l1
	l1 = max(i, l1)
	if l1 > l1_:
		l2 = l1_
	elif l2 < i < l1 or l2 == l1:
		l2 = i
print(l2)


n = int(input())
i = 0
arr = []
t = input()
arr = list(map(int, t.split(' ')))
arr.sort(reverse=True)
while arr[i] == arr[i + 1]:
	i += 1
print(arr[i + 1])


import sys
num = int(input())
numbers = input().split(' ')
numbers = [int(i) for i in numbers]
maxNum = -99999999999999
secMax = -99999999999999
for n in numbers:
	if n > maxNum:
		secMax = maxNum
		maxNum = n
	elif n == maxNum:
		pass
	elif n > secMax:
		secMax = n
print(secMax)


n = int(input())
lst = list(map(int, input().split(' ')))
h1 = -100
h2 = -100
for i in range(n):
	if lst[i] > h1:
		h2 = h1
		h1 = lst[i]
	elif h1 > lst[i] & lst[i] > h2:
		h2 = lst[i]
print(h2)


n = int(input())
l = list(map(int, input().split()))
l.sort()
m = max(l)
while max(l) == m:
	l.remove(m)
print(l[-1])


input()
a = list(map(int, input().split()))
m = max(a)
print(max((x for x in a if x != m)))


import sys
N = int(input())
nbr_list = [int(n) for n in input().split()]
biggest = max(nbr_list)
while biggest in nbr_list:
	nbr_list.remove(biggest)
print(max(nbr_list))


num = input()
m = list(set([int(x) for x in input().split(' ')]))
print(sorted(m)[len(m) - 2])


n = int(input())
a = map(int, input().strip().split(' '))
a = list(a)
mx1 = a[0]
mn = a[0]
for i in a:
	if i > mx1:
		mx1 = i
	if i < mn:
		mn = i
mx2 = mn
for i in a:
	if i > mx2 and i < mx1:
		mx2 = i
print(mx2)


import sys
sys.stdin.readline().strip()
numbers = list(set(map(int, sys.stdin.readline().strip().split())))
numbers.sort()
if len(numbers) > 1:
	print(numbers[-2])
else:
	print(numbers[0])


n = input()
l = input()
l = sorted(list(set(map(int, l.split(' ')))), reverse=True)
if len(l) > 1:
	print(l[1])
else:
	print(l[0])


input()
inp = list(map(int, input().split()))
mx = -101
mx1 = -102
for elem in inp:
	if elem > mx:
		mx1 = mx
		mx = elem
	elif elem > mx1 and elem < mx:
		mx1 = elem
print(mx1)


N = int(input())
Ar = list(map(int, input().split()))
m = max(Ar)
pop = 0
for i in range(len(Ar)):
	if Ar[i] == m and Ar[i] != 8:
		Ar.remove(m)
		Ar.insert(0, 0)
		pop = Ar[len(Ar) - 1]
	elif Ar[0] == 8 and m - Ar[i] == 1:
		pop = 7
print(pop)


n = int(input())
arr = []
inp = input()
line = inp.split()
for i in range(n):
	arr.append(int(line[i]))
maxm = max(arr)
while maxm in arr:
	arr.remove(maxm)
if len(arr):
	req = max(arr)
	print(req)


n = int(input())
a = list(map(int, input().split(' ')))
max = -100
for i in range(n):
	if a[i] > max:
		max = a[i]
smax = -100
for i in range(n):
	if a[i] < max and a[i] > smax:
		smax = a[i]
print(smax)


n = int(input())
a = list(map(int, input().split()))
a = list(set(a))
a.sort()
print(a[len(a) - 2])


n = input()
print(sorted(set(map(int, input().split())))[-2])


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = l[0]
for i in range(1, n):
	if l[i] != ans:
		ans = l[i]
		break
print(ans)


n = input()
a = input().split(' ')
a = [int(i) for i in a]
a = set(a)
a = list(a)
a.sort()
print(a[len(a) - 2])


lines = int(input())
inpt = input().split()
lis = []
for elm in inpt:
	lis.append(int(elm))
lis = sorted(lis)
x = len(lis) - 2
while lis[x] == lis[len(lis) - 1]:
	x -= 1
print(lis[x])


len = input()
a = input()
b = a.split()
c = []
for i in b:
	c.append(int(i))
	c.sort()
	d = set(c)
	e = list(d)
	e.sort()
print(e[-2])


input()
print(sorted(list(set([int(i) for i in input().split()])))[-2])


input()
l = sorted([int(i) for i in input().split(' ')], reverse=True)
m = l[0]
for i in range(1, len(l)):
	if l[i] < m:
		print(l[i])
		break


_ = input()
numbers = set([int(val) for val in input().split()])
print(sorted(numbers)[-2])


n = int(input())
nums = list(set(map(int, input().split())))
nums.sort()
print(nums[len(nums) - 2])


import sys
x = sys.stdin.read().split('\n')
x = x[1].split(' ')
high = -101
second = -101
for n in range(0, 2):
	for i in x:
		if int(i) >= high:
			high = int(i)
		if second < int(i) < high:
			second = int(i)
print(second)


import sys
arr = []
n = int(input())
line = sys.stdin.readline()
arr = line.split(' ')
arr = list(set(arr))
arr = [int(i) for i in arr]
max1 = -102
max2 = -101
for i in arr:
	if max1 < i:
		max2 = max1
		max1 = i
	elif max1 != i and max2 < i:
		max2 = i
print(max2)


N = int(input())
array_str = str(input()).split(' ', N)
array_int = []
for i in range(N):
	array_int.append(int(array_str[i]))
sorted_array = sorted(array_int, reverse=True)
i = 0
while i < N - 1:
	if sorted_array[i] == sorted_array[i + 1]:
		i += 1
	else:
		print(sorted_array[i + 1])
		break


import sys

def main():
	lines = [line.strip() for line in sys.stdin]
	A = [int(s) for s in lines[1].split(' ')]
	A = list(set(A))
	A.sort()
	print(A[-2])
main()


a = input()
a = input()
a = a.split()
for i in range(len(a)):
	a[i] = int(a[i])
a.sort()
a.reverse()
x = a[0]
for i in range(a.count(x)):
	a.remove(x)
print(a[0])


N = int(input())
A = [int(x) for x in input().strip().split(' ')]
found = False
for x in range(100, -101, -1):
	if found:
		if x in A:
			print(x)
			break
	elif x in A:
		found = True


n = int(input())
numb = input()
lis = list(map(int, numb.split()))
(big, sbig) = (-6000, -6000)
for i in lis:
	if i > big:
		(big, sbig) = (i, big)
	elif i < big and i > sbig:
		sbig = i
print(sbig)


n = input()
l = list(map(int, input().split()))
l.sort()
largest = l[-1]
for i in range(len(l) - 1, -1, -1):
	if l[i] == largest:
		continue
	else:
		largest = l[i]
		break
print(largest)


a = int(input())
s = []
b = input().split(' ')
for i in range(len(b)):
	s.append(int(b[i]))
s.sort()
for i in range(len(b) - 1, 0, -1):
	if s[i] == s[i - 1]:
		continue
	else:
		print(s[i - 1])
		exit(0)


n = int(input())
l = list(map(int, input().split()))
m = max(l)
for i in range(n):
	if l[i] == m:
		l[i] = -10000
m = max(l)
print(m)


(num, nums) = (int(input()), list(set([int(x) for x in str(input()).split()])))
nums.remove(max(nums))
print(max(nums))


import sys

def main():
	n = int(sys.stdin.readline())
	s = set((int(i) for i in sys.stdin.readline().split()))
	s.remove(max(s))
	print(max(s))
main()


N = int(input())
l = [int(i) for i in input().split(' ')]
l.sort(reverse=True)
for i in l:
	if i != l[0]:
		print(i)
		break


leng = int(input())
lis = input()
lis = lis.split()
lis = list(map(int, lis))
se = set(lis)
(first, second) = (-100, -100)
for x in se:
	if x >= first:
		second = first
		first = x
	elif x >= second:
		second = x
print(second)


n = int(input())
lineA = input()
listA = [int(x) for x in lineA.split()]
listA.sort(reverse=True)
largest = listA[0]
for number in listA:
	if number < largest:
		largest = number
		break
print(largest)


_ = input()
l = sorted(set(map(int, input().split())))
print(l[-2])


input()
x = list(map(int, input().split(' ')))
m = max(x)
while m in x:
	x.remove(m)
print(max(x))


n = int(input())
vals = [int(i) for i in input().split()]
m = max(vals)
while True:
	try:
		vals.remove(m)
	except ValueError:
		break
print(max(vals))


input()
numbers = input().split()
numbers.sort(key=int)
i = numbers.pop()
a = i
while a == i:
	a = numbers.pop()
print(a)


n = int(input())
lst = list(map(int, input().split()))
lst.sort()
size = len(lst)
max_num = lst[size - 1]
for i in reversed(lst):
	if i < max_num:
		print(i)
		break


N = int(input())
a = list(map(int, input().split()))
sa = sorted(a)
sx = filter(lambda x: x != sa[-1], sa)
print(list(sx)[-1])


input()
A = map(int, input().split())
second = -101
largest = -101
for a in A:
	if a > largest:
		second = largest
		largest = a
	elif a > second and a != largest:
		second = a
print(second)


N = int(input())
a = [int(x) for x in input().split()]
temp = max(a)
a.remove(temp)
while max(a) == temp:
	a.remove(temp)
print(max(a))