A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer.

Limak can discard (throw out) some cards. His goal is to minimize the sum of numbers written on remaining (not discarded) cards.

He is allowed to at most once discard two or three cards with the same number. Of course, he won't discard cards if it's impossible to choose two or three cards with the same number.

Given five numbers written on cards, cay you find the minimum sum of numbers on remaining cards?


-----Input-----

The only line of the input contains five integers t_1, t_2, t_3, t_4 and t_5 (1 ≤ t_{i} ≤ 100) — numbers written on cards.


-----Output-----

Print the minimum possible sum of numbers written on remaining cards.


-----Examples-----
Input
7 3 7 3 20

Output
26

Input
7 9 3 1 8

Output
28

Input
10 10 10 10 10

Output
20



-----Note-----

In the first sample, Limak has cards with numbers 7, 3, 7, 3 and 20. Limak can do one of the following.

  Do nothing and the sum would be 7 + 3 + 7 + 3 + 20 = 40.  Remove two cards with a number 7. The remaining sum would be 3 + 3 + 20 = 26.  Remove two cards with a number 3. The remaining sum would be 7 + 7 + 20 = 34. 

You are asked to minimize the sum so the answer is 26.

In the second sample, it's impossible to find two or three cards with the same number. Hence, Limak does nothing and the sum is 7 + 9 + 1 + 3 + 8 = 28.

In the third sample, all cards have the same number. It's optimal to discard any three cards. The sum of two remaining numbers is 10 + 10 = 20.

Difficulty: EASY
Tags: Implementation

Constructive algorithms

Starter code:

Solutions:
l = list(map(int, input().split()))
l.sort(reverse=True)
newList = []
for i in range(len(l)):
	if l.count(l[i]) == 2:
		newList.append(sum(l) - l[i] * 2)
	elif l.count(l[i]) >= 3:
		newList.append(sum(l) - l[i] * 3)
newList.append(sum(l))
print(min(newList))


arr = [int(i) for i in input().split()]
hsh = [0 for i in range(0, 101)]
arr.sort()
ans = 0
for i in arr:
	hsh[i] += 1
	ans += i
(i, temp, anst) = (100, ans, ans)
while i >= 1:
	if hsh[i] >= 3:
		temp = ans - 3 * i
		anst = min(anst, temp)
	elif hsh[i] >= 2:
		temp = ans - 2 * i
		anst = min(anst, temp)
	i -= 1
print(anst)


a = list(map(int, input().split()))
mas = []
for i in a:
	number = a.count(i)
	if number >= 2 and number <= 3:
		mas.append(number * i)
	elif number >= 4:
		mas.append(i * 3)
	else:
		continue
if len(mas) > 0:
	print(sum(a) - max(mas))
else:
	print(sum(a))


t = list(map(int, input().split()))
t.sort()
arr = [0] * 5
num = [0] * 5
arr[0] = 1
num[0] = t[0]
j = 0
sumt = sum(t)
for i in range(1, 5):
	if t[i - 1] == t[i]:
		arr[j] += 1
	else:
		j += 1
		arr[j] += 1
		num[j] = t[i]
i = 0
ans = sum(t)
while i < 5 and arr[i] != 0:
	if arr[i] == 1:
		i += 1
		continue
	rem = sumt - num[i] * min(arr[i], 3)
	ans = min(rem, ans)
	i += 1
print(ans)


a = [int(i) for i in input().split()]
s = sum(a)
for i in a:
	if a.count(i) >= 2:
		s = min(sum(a) - min(3, a.count(i)) * i, s)
print(s)


l = list(map(int, input().split()))
a = 0
ans = 0
for i in range(5):
	ans += l[i]
for i in range(5):
	for j in range(i + 1, 5, 1):
		if l[i] == l[j] and 2 * l[i] > a:
			a = 2 * l[i]
for i in range(5):
	for j in range(i + 1, 5, 1):
		for k in range(j + 1, 5, 1):
			if l[i] == l[j] == l[k] and 3 * l[i] > a:
				a = 3 * l[i]
print(ans - a)


lst = list(map(int, input().split()))
d = {}
for k in lst:
	d[k] = lst.count(k)
sm = []
for k in d:
	if d[k] == 2:
		sm.append(d[k] * k)
	elif d[k] >= 3:
		sm.append(k * 3)
if len(sm) != 0:
	print(sum(lst) - max(sm))
else:
	print(sum(lst))


arr = list(map(int, input().split()))
cnt = [0] * 101
arr_sum = sum(arr)
res = [arr_sum]
for i in range(5):
	cnt[arr[i]] += 1
for i in range(100, 0, -1):
	if cnt[i] > 1:
		if cnt[i] > 2:
			res.append(arr_sum - i * 3)
		else:
			res.append(arr_sum - i * 2)
print(min(res))


from collections import defaultdict
t = list(map(int, input().split()))
d = defaultdict(int)
s = sum(t)
for x in t:
	d[x] += 1
ans = s
for (x, y) in d.items():
	if y < 2:
		continue
	if s - x * y < ans:
		ans = s - x * min(y, 3)
print(ans)


arr = sorted(list(map(int, input().split())))
s = sum(arr)
narr = []
for x in arr:
	cnt = 0
	for y in arr:
		cnt += int(y == x)
	cnt = min(cnt, 3)
	if cnt > 1:
		narr.append(x * cnt)
	else:
		narr.append(0)
print(s - max(narr))


cards = list(map(int, input().split()))
d = {}
maxv = 0
s = 0
for v in cards:
	d[v] = d.setdefault(v, 0) + 1
	if d[v] == 2 or d[v] == 3:
		s = v * d[v]
		if maxv < s:
			maxv = s
print(sum(cards) - maxv)


a = list(map(int, input().split()))
b = sorted(a)
ans = []
for i in reversed(b):
	if a.count(i) >= 3:
		ans.append(i * 3)
	elif a.count(i) == 2:
		ans.append(i * 2)
if len(ans) != 0:
	print(sum(a) - max(ans))
else:
	print(sum(a))


from collections import Counter
vector = input()
vector = list(map(int, vector.split(' ')))
vector.sort()
suma = 0
counter = []
for (i, x) in enumerate(vector):
	suma += 1
	if i == len(vector) - 1:
		counter.append([vector[i], suma])
		suma = 0
	elif x != vector[i + 1]:
		counter.append([vector[i], suma])
		suma = 0
totals = []
for x in counter:
	if x[1] > 2:
		totals.append([x[0], x[0] * 3])
	if x[1] > 1 and x[1] < 3:
		totals.append([x[0], x[0] * 2])
totals.sort(key=lambda x: x[1])
if len(totals) == 0:
	print(sum(vector))
else:
	print(sum(vector) - totals[-1][-1])


l = list(map(int, input().split()))
t = sum(l)
d = {}
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
z = t
for j in d:
	k = t
	if d[j] == 2:
		k = k - j * 2
	elif d[j] > 2:
		k = k - j * 3
	if k <= z:
		z = k
print(z)


a = list(map(int, input().split()))
a.sort()
(ans1, ans2) = (0, 0)
if a[4] == a[2]:
	ans1 = a[4] + a[3] + a[2]
elif a[3] == a[1]:
	ans1 = a[1] + a[2] + a[3]
elif a[2] == a[0]:
	ans1 = a[2] + a[1] + a[0]
if a[4] == a[3]:
	ans2 = a[4] + a[3]
elif a[3] == a[2]:
	ans2 = a[2] + a[3]
elif a[2] == a[1]:
	ans2 = a[1] + a[2]
elif a[1] == a[0]:
	ans2 = a[1] + a[0]
if ans1 == 0 and ans2 == 0:
	print(sum(a))
else:
	print(sum(a) - max(ans1, ans2))


from collections import Counter
t = list(map(int, input().split()))
c = Counter(t)
cc = []
for elem in c:
	if c[elem] > 1:
		cc.append(elem)
m = sum(t)
for elem in cc:
	m = min(m, sum(t) - min(c[elem], 3) * elem)
print(m)


a = list(map(int, input().split()))
b = [0] * 101
for i in a:
	b[i] += 1
b[0] = 3
for i in range(101):
	if b[i] > 1:
		x = i * 2
	if b[i] > 2:
		y = i * 3
print(sum(a) - max(x, y))


numbers = input().split(' ')
for i in range(len(numbers)):
	numbers[i] = int(numbers[i])
unique = set(numbers)
total = sum(numbers)
minSum = total
current = total
for num in unique:
	count = numbers.count(num)
	if count >= 3:
		current = total - num * 3
	elif count == 2:
		current = total - num * 2
	if current < minSum:
		minSum = current
print(minSum)


numbers = list(map(int, input().split()))
d = {}
for n in numbers:
	if n not in d:
		d[n] = 1
	else:
		d[n] += 1
to_drop = None
value_to_drop = 0
for i in sorted(d.keys(), reverse=True):
	if d[i] <= 1:
		continue
	else:
		new_value = i * min(d[i], 3)
		if new_value > value_to_drop:
			to_drop = i
			value_to_drop = new_value
print(sum(numbers) - value_to_drop)


t = list(map(int, input().split()))
td = {}
for n in t:
	if n in td.keys():
		td[n] += 1
	else:
		td[n] = 1
ts = sorted(list(set(t)))[::-1]
best = sum(t)
for n in ts:
	if td[n] >= 2:
		c = min(3, td[n])
		best = min(best, sum(t) - n * c)
print(best)


a = list(map(int, input().split()))
a.sort(reverse=True)
p_ans = 0
c = 0
for i in range(len(a) - 1):
	if a[i] == a[i + 1]:
		c = 2 * a[i]
		if i != 0:
			if a[i] == a[i - 1]:
				c = 3 * a[i]
				if p_ans < c:
					p_ans = c
				else:
					continue
			else:
				c = 2 * a[i]
				if p_ans <= c:
					p_ans = c
				else:
					continue
		elif p_ans < c:
			p_ans = c
		else:
			continue
	else:
		continue
print(sum(a) - p_ans)


l = list(map(int, input().split()))
l.sort()
s = sum(l)
for i in l:
	a = l.count(i)
	if a == 2:
		s = min(s, sum(l) - a * i)
	elif a >= 3:
		s = min(s, sum(l) - 3 * i)
print(s)


A = [int(i) for i in input().split()]
z = sum(A)
d = z
for i in range(len(A)):
	zz = A.count(A[i])
	if zz >= 2:
		if zz >= 3:
			zz = 3
		h = z - zz * A[i]
		if h < d:
			d = h
print(d)


from sys import stdin, stdout
d = {}
ans = 0
numbers = list(map(int, stdin.readline().split()))
for i in range(5):
	a = numbers[i]
	ans += a
	if a not in d:
		d[a] = [a, 1]
	else:
		d[a] = [d[a][0] + a, d[a][1] + 1]
choose = 0
for v in d:
	if 4 > d[v][1] > 1:
		choose = max(choose, d[v][0])
	elif d[v][1] >= 4:
		choose = max(choose, d[v][0] // d[v][1] * 3)
stdout.write(str(ans - choose))


import sys
from collections import defaultdict

def main():
	p = list(map(int, sys.stdin.readline().split()))
	m = defaultdict(int)
	res = sum(p)
	s = sum(p)
	for i in p:
		m[i] += 1
	for k in m:
		v = m[k]
		if v > 1:
			if v > 3:
				v = 3
			if res > s - k * v:
				res = s - k * v
	print(res)
main()


from collections import Counter
val = list(map(int, input().split()))
tot = sum(val)
ans = tot
cnt = Counter(val)
for (k, v) in cnt.items():
	if 2 <= v:
		ans = min(ans, tot - k * min(v, 3))
print(ans)


a = [int(x) for x in input().split()]
a.sort()
if a[4] == a[3]:
	if a[0] == a[1] and a[1] == a[2]:
		k = a[4] + a[3]
		p = a[0] + a[1] + a[2]
		if k > p:
			print(p)
		else:
			print(k)
	elif a[3] == a[2]:
		print(a[0] + a[1])
	else:
		print(a[0] + a[1] + a[2])
elif a[3] == a[2]:
	if a[2] == a[1]:
		print(a[0] + a[4])
	else:
		print(a[0] + a[1] + a[4])
elif a[2] == a[1]:
	if a[1] == a[0]:
		print(a[3] + a[4])
	else:
		print(a[0] + a[3] + a[4])
elif a[1] == a[0]:
	print(a[2] + a[3] + a[4])
else:
	print(a[0] + a[1] + a[2] + a[3] + a[4])


A = list(map(int, input().split()))
m = {}
for a in A:
	if a not in m:
		m[a] = 1
	else:
		m[a] += 1
ne = 0
for a in m:
	if m[a] >= 2:
		ne = max(ne, a * 2)
	if m[a] >= 3:
		ne = max(ne, a * 3)
print(sum(A) - ne)


t = list(map(int, input().split()))
st = set(t)
sm = sum(t)
ans = sm
if len(st) < 5:
	for x in st:
		cnt = t.count(x)
		if cnt > 1:
			candidate_ans = sm - x * min(3, cnt)
			if candidate_ans < ans:
				ans = candidate_ans
print(ans)


l = list(map(int, input().split()))
s = sum(l)
c = list(set(l))
p = {}
for i in c:
	p[i] = 0
m = 0
for i in sorted(l):
	p[i] += 1
vk = s
for i in sorted(c)[::-1]:
	if p[i] >= 2:
		if p[i] >= 3:
			pk = s - 3 * i
		else:
			pk = s - 2 * i
	else:
		pk = s
	if vk > pk:
		vk = pk
print(vk)


a = list(map(int, input().split()))
d = {}
for x in a:
	d[x] = d.get(x, 0) + 1
max_sum = 0
for (k, v) in d.items():
	if v > 1:
		max_sum = max(max_sum, min(3, v) * k)
print(sum(a) - max_sum)


cards = list(map(int, input().split()))
zmensenie = 0
for card in cards:
	oc = 0
	for c2 in cards:
		if c2 == card:
			oc += 1
	if oc >= 2:
		oc = min(oc, 3)
		zmensenie = max(zmensenie, oc * card)
print(sum(cards) - zmensenie)


f = list(map(int, input().split()))
f.sort()
vals = [sum(f)]
for i in range(len(f)):
	if f.count(f[i]) >= 2:
		s = 0
		t = 0
		for u in range(len(f)):
			if f[u] == f[i] and t < 3:
				t += 1
				continue
			s += f[u]
		vals.append(s)
print(min(vals))


l = list(map(int, input().split()))
l.sort()
ans = sum(l)
s = set(l)
l2 = list(s)
l1 = []
for i in s:
	l1.append(l.count(i))
for i in range(len(l1) - 1, -1, -1):
	if l1[i] == 2:
		ans = min(ans, sum(l) - l1[i] * l2[i])
	elif l1[i] > 2:
		ans = min(ans, sum(l) - l2[i] * 3)
print(ans)


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(99999)
arr = list(map(int, input().split()))
s = sum(arr)
cs = collections.Counter(arr)
mx = 0
for (k, v) in cs.items():
	if v == 2:
		mx = max(mx, 2 * k)
	elif v > 2:
		mx = max(mx, 3 * k)
print(s - mx)


a = input()
a = a.split()
a[0] = int(a[0])
a[1] = int(a[1])
a[2] = int(a[2])
a[3] = int(a[3])
a[4] = int(a[4])
a.sort()
b = a[0]
contador = 0
mayor = 0
for k in range(5):
	c = a.count(a[k])
	r = c * a[k]
	if mayor < r and c >= 2:
		b = a[k]
		contador = c
		mayor = r
if contador >= 3:
	a.remove(b)
	a.remove(b)
	a.remove(b)
	y = sum(a)
if contador == 2:
	a.remove(b)
	a.remove(b)
	y = sum(a)
else:
	y = sum(a)
print(y)


def getWorth(data, freq):
	if freq >= 3:
		return data * 3
	elif freq == 2:
		return data * 2
	else:
		return 0
cardLine = input()
card = cardLine.split()
for i in range(5):
	card[i] = int(card[i])
card.sort()
data = card[4]
freq = 1
maxFreq = 1
for i in range(3, -1, -1):
	if card[i] == card[i + 1]:
		freq += 1
	elif freq > maxFreq and getWorth(data, maxFreq) < getWorth(card[i + 1], freq):
		data = card[i + 1]
		maxFreq = freq
		freq = 1
if freq > maxFreq and getWorth(data, maxFreq) < getWorth(card[i], freq):
	data = card[0]
	maxFreq = freq
ans = sum(card) - getWorth(data, maxFreq)
print(ans)


a = 3 * [0] + sorted(map(int, input().split()))
print(sum(a) - max((2 * z + (x == z) * z for (x, y, z) in zip(a, a[1:], a[2:]) if z == y)))


mas = [int(x) for x in input().split()]
p = sum(mas)
pp = p
mas.sort(reverse=True)
for i in mas:
	k = mas.count(i)
	if k >= 3:
		pp = min(pp, p - 3 * i)
	elif k == 2:
		pp = min(pp, p - 2 * i)
print(pp)


import sys

def main():
	nums = [int(tok) for tok in sys.stdin.readline().split()]
	nums = list(sorted(nums))
	all_sum = sum(nums)
	sum_list = [all_sum]
	for (a1, a2, a3) in zip(nums, nums[1:], nums[2:]):
		if a1 == a3:
			sum_list.append(all_sum - 3 * a1)
		elif a1 == a2:
			sum_list.append(all_sum - 2 * a1)
		elif a2 == a3:
			sum_list.append(all_sum - 2 * a2)
	print(min(sum_list))
main()


t = list(map(int, input().split(' ')))
t.sort()
sum1 = 0
sum2 = 0
for i in t:
	if t.count(i) >= 3:
		sum1 = 3 * i
	if t.count(i) == 2:
		sum2 = 2 * i
print(sum(t) - max(sum1, sum2))


l = list(map(int, input().split()))
orig = sum(l)
ans = sum(l)
for i in l:
	if l.count(i) == 2:
		ans = min(ans, orig - i * 2)
	elif l.count(i) >= 3:
		ans = min(ans, orig - i * 3)
print(ans)


(t1, t2, t3, t4, t5) = map(int, input().split())
max1 = -1
a = sorted([t1, t2, t3, t4, t5])
for i in range(len(a) - 1, -1, -1):
	if a.count(a[i]) > 1 and a[i] * a.count(a[i]) > max1:
		if a.count(a[i]) in [2, 3]:
			max1 = a[i] * a.count(a[i])
		else:
			max1 = a[i] * 3
if max1 == -1:
	print(t1 + t2 + t3 + t4 + t5)
else:
	print(t1 + t2 + t3 + t4 + t5 - max1)


from collections import Counter
ls = list(map(int, input().split()))
ls.sort()
ls.reverse()
d = dict(Counter(ls))
Max = 0
for (k, v) in d.items():
	if v >= 3:
		Max = max(Max, 3 * k)
	if v == 2:
		Max = max(Max, 2 * k)
print(sum(ls) - Max)


a = list(map(int, input().split()))
cnt = [0] * 1000
for i in a:
	cnt[i] += 1
s = sum(a)
res = s
for i in range(1000):
	cnt[i] = min(cnt[i], 3)
	if 2 <= cnt[i]:
		res = min(res, s - cnt[i] * i)
print(res)


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def summarizeList(l):
	sl = sorted(l, key=lambda x: x, reverse=True)
	a = sl[0]
	c = 1
	res = []
	for x in sl[1:]:
		if x == a:
			c += 1
		else:
			res.append([a, c])
			a = x
			c = 1
	res.append([a, c])
	return res

def main():
	l = LI()
	sm = sum(l)
	sl = summarizeList(l)
	minus_max = 0
	for (x, c) in sl:
		if c > 1:
			if c > 2:
				minus_max = max(minus_max, x * 3)
			else:
				minus_max = max(minus_max, x * 2)
	return sm - minus_max
print(main())


l = list(map(int, input().split()))
k = list(set(l))
g = 0
m = []
if len(k) == len(l):
	print(sum(l))
else:
	for i in k:
		c = l.count(i)
		if c > 3:
			c = 3
		if c < 2:
			c = 0
		m.append(sum(l) - i * c)
	print(min(m))


t = list(map(int, input().split()))
t.sort(reverse=True)
t.append(0)
c = 0
m = 0
prev = t[0]
for e in t:
	if e == prev:
		c += 1
	else:
		if c > 3:
			c = 3
		if prev * c > m and c >= 2:
			m = prev * c
		c = 1
		prev = e
print(sum(t) - m)


L = [int(x) for x in input().split()]
d = {}
for i in L:
	if i not in d:
		d[i] = 0
	d[i] += 1
s = sum(L)
ans = s
for i in L:
	if d[i] > 1:
		ans = min(ans, s - i * min(3, d[i]))
print(ans)


s = input()
l = s.split()
l1 = []
sum = 0
for i in range(len(l)):
	sum += int(l[i])
	l1.append(int(l[i]))
dic = {}
for i in l1:
	if i not in dic:
		dic[i] = 1
	else:
		dic[i] += 1
t = 0
for (k, v) in dic.items():
	if v > 1:
		t = max(t, k * min(3, v))
print(sum - t)


import sys
from collections import Counter

def main():
	s = list(map(int, sys.stdin.read().strip().split()))
	return sum(s) - max((i * min(j, 3) for (i, j) in Counter(s).items() if j > 1), default=0)
print(main())


l = list(map(int, input().split()))
d = {}
s = sum(l)
m = int(s)
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
for i in d:
	if d[i] < 4 and d[i] != 1:
		m = min(m, s - i * d[i])
	elif d[i] > 3:
		m = min(m, s - i * 3)
print(m)


from collections import Counter
arr = list(map(int, input().split()))
c = Counter(arr)
s = sum(arr)
ans = s
for ele in c:
	if c[ele] >= 3:
		ans = min(ans, s - 3 * ele)
	elif c[ele] >= 2:
		ans = min(ans, s - 2 * ele)
print(ans)


disc = [0]
x = list(map(int, input().split(' ')))
x.sort()
for i in list(set(x)):
	if x.count(i) >= 3:
		disc.append(3 * i)
	if x.count(i) == 2:
		disc.append(2 * i)
print(sum(x) - max(disc))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
li = inlt()
freq = [0] * 102
sum = 0
for i in li:
	freq[i] = freq[i] + 1
	sum += i
d = 0
for i in range(102):
	if freq[i] == 2 or freq[i] == 3:
		d = max(d, freq[i] * i)
	elif freq[i] > 3:
		d = max(d, i * 3)
print(sum - d)


list1 = list(map(int, input().split()))
n = 0
for i in set(list1):
	if list1.count(i) > 1:
		n = max(n, i * min(3, list1.count(i)))
print(sum(list1) - n)


s = list(map(int, input().split()))
num = sum(s)
for i in range(5):
	tmp = 0
	t = []
	k = 0
	for j in range(5):
		if k < 3 and s[i] == s[j]:
			k += 1
			continue
		tmp += s[j]
		t.append(s[j])
	if k == 2 or k == 3:
		num = min(num, tmp)
print(num)


l = sorted(list(map(int, input().split())))
d = {}
for e in l:
	try:
		d[e] += 1
	except KeyError:
		d[e] = 1
answer = sum(l)
for e in sorted(d.keys(), reverse=True):
	if d[e] > 1:
		answer = min(answer, sum(l) - e * min(3, d[e]))
print(answer)


t = list(map(int, input().split()))
s = sum(t)
a = [s]
for i in range(5):
	x = t.count(t[i])
	if x == 2:
		k = s - 2 * t[i]
		a.append(k)
	if x >= 3:
		k = s - 3 * t[i]
		a.append(k)
print(min(a))


d = dict()
a = list(map(int, input().split()))
s = sum(a)
if sum(set(a)) == s:
	print(s)
	exit()
for i in a:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
max = 0
for (key, value) in d.items():
	if value > 1:
		ans = key * value
		if ans > max:
			if value > 2:
				max = key * 3
			elif value > 1:
				max = key * 2
print(s - max)


t = sorted(list(map(int, input().split())))
k = 0
if t[-1] == t[-3]:
	k = max(k, 3 * t[-1])
if t[-1] == t[-2]:
	k = max(k, 2 * t[-1])
if t[-2] == t[-4]:
	k = max(k, 3 * t[-2])
if t[-2] == t[-3]:
	k = max(k, 2 * t[-2])
if t[-3] == t[-5]:
	k = max(k, 3 * t[-3])
if t[-3] == t[-4]:
	k = max(k, 2 * t[-3])
if t[-4] == t[-5]:
	k = max(k, 2 * t[-4])
print(sum(t) - k)


l = [int(x) for x in input().split()]
l.sort()
a = sorted(list(set(l)))
x = list(filter(lambda x: x > 1, map(l.count, a)))
y1 = list(filter(lambda x: l.count(x) > 1, a))
v = []
for (i, y) in enumerate(x):
	v.append(min(y, 3) * y1[i])
v.append(0)
print(sum(l) - max(v))


l = list(map(int, input().split()))
d = {}
for x in l:
	d[x] = d.get(x, 0) + 1
ans = sum(l)
for x in sorted(d.keys())[::-1]:
	if d[x] > 1:
		s = 0
		for y in d:
			if y != x:
				s += d[y] * y
			else:
				s += max(d[y] - 3, 0) * y
		if s < ans:
			ans = s
print(ans)


l = list(map(int, input().split()))
s = sum(l)
if len(l) == len(set(l)):
	print(s)
else:
	m = []
	for i in l:
		if l.count(i) == 2:
			m.append(s - i * 2)
		elif l.count(i) >= 3:
			m.append(s - i * 3)
	print(min(m))


cartes = list(map(int, input().split()))
somme = sum(cartes)
nbOccurence = [0] * 100
enleverMax = 0
for carte in cartes:
	nbOccurence[carte - 1] += 1
for (numeroCarte, nombre) in enumerate(nbOccurence):
	nombreEnlever = min(3, nombre)
	if nombre >= 2 and (numeroCarte + 1) * nombreEnlever > enleverMax:
		enleverMax = (numeroCarte + 1) * nombreEnlever
print(somme - enleverMax)


a = list(map(int, input().split()))
d = [a.count(i) for i in a]
print(sum(a) - max((a[i] * min(d[i], 3) * (d[i] > 1) for i in (0, 1, 2, 3, 4))))


n = list(map(int, input().split()))
p = list(set(n))
w = []
if len(p) != len(n):
	for i in p:
		if 2 <= n.count(i) <= 3:
			w.append(i * n.count(i))
		elif n.count(i) > 3:
			w.append(i * 3)
	print(sum(n) - max(w))
else:
	print(sum(n))


def Plus(Array):
	c = 0
	for i in range(len(Array)):
		c += Array[i]
	return c
Array = input().split(' ')
for j in range(len(Array)):
	Array[j] = int(Array[j])
P = Plus(Array)
lst = []
bzyr = []
f = 1
for i in range(len(Array)):
	if Array.count(Array[i]) > 1:
		f = 0
if f == 1:
	print(P)
elif f == 0:
	c = 0
	while len(Array) > 0:
		if Array.count(Array[0]) == 1:
			lst.append(Array[0])
			Array.remove(Array[0])
		elif Array.count(Array[0]) > 1:
			t = Array[0]
			bzyr.append(t)
			s = Array.count(t)
			c += 1
			while Array.count(t) > 0:
				lst.append(Array[Array.index(t)])
				Array.remove(t)
	if c == 1:
		if s == 2:
			print(P - 2 * t)
		elif s > 2:
			print(P - 3 * t)
	elif c == 2:
		if lst.count(bzyr[0]) * bzyr[0] > lst.count(bzyr[1]) * bzyr[1]:
			print(P - lst.count(bzyr[0]) * bzyr[0])
		elif lst.count(bzyr[0]) * bzyr[0] < lst.count(bzyr[1]) * bzyr[1]:
			print(P - lst.count(bzyr[1]) * bzyr[1])
		else:
			print(P - lst.count(bzyr[0]) * bzyr[0])


from collections import Counter
x = [int(i) for i in input().split()]
sum_ = sum(x)
c = Counter(x)
dum = []
for (i, j) in c.items():
	if j == 2 or j == 3:
		dum.append(i * j)
	elif j > 3:
		dum.append(i * 3)
if len(dum) != 0:
	print(sum_ - max(dum))
else:
	print(sum_)


arr = list(map(int, input().split()))
ss = sum(arr)
s = [ss]
for num in set(arr):
	c = arr.count(num)
	if c > 1:
		c = min(c, 3)
		s.append(ss - num * c)
print(min(s))


arr = list(map(int, input().split()))
ans = sum(arr)
temp = [0] * 103
for i in arr:
	temp[i] = temp[i] + 1
cut = 0
for i in range(103):
	if temp[i] > 1 and i * min(3, temp[i]) > cut:
		cut = i * min(3, temp[i])
print(ans - cut)


from collections import defaultdict
arr = map(int, input().strip().split())
full = 0
counter = defaultdict(int)
for e in arr:
	counter[e] += 1
	full += e
max_remove = 0
for (k, v) in counter.items():
	remove = 0
	if v >= 3:
		remove = k * 3
	elif v == 2:
		remove = k * 2
	max_remove = max(max_remove, remove)
print(full - max_remove)


l = [int(x) for x in input().split()]
if len(set(l)) == 5:
	print(sum(l))
elif len(set(l)) == 1:
	print(2 * l[0])
elif len(set(l)) == 4:
	s = 0
	for i in range(5):
		if l.count(l[i]) != 2:
			s += l[i]
	print(s)
elif len(set(l)) == 2:
	q = []
	s = 0
	x = 0
	for i in range(5):
		if l.count(l[i]) == 4:
			x = l[i]
		else:
			s += l[i]
	s += x
	if x != 0:
		print(s)
	else:
		x = max(set(l))
		q.append(l.count(x) * x)
		x = min(set(l))
		q.append(l.count(x) * x)
		print(min(q))
else:
	q = []
	q.append(sum(l))
	m = []
	for i in range(5):
		if l.count(l[i]) == 2 and i not in m:
			m.append(i)
	if len(m) == 4:
		x = l.index(max(l[m[0]], l[m[1]], l[m[2]], l[m[3]]))
		s = 0
		for i in range(5):
			if l[i] != l[x]:
				s += l[i]
		q.append(s)
	s = 0
	for i in range(5):
		if l.count(l[i]) != 3:
			s += l[i]
	q.append(s)
	print(min(q))


v = input()
v = v.split()
from collections import Counter
soma = 0
for i in range(len(v)):
	v[i] = int(v[i])
	soma += v[i]
mAx = []
x = Counter(v)
for elemento in x:
	if x[elemento] > 1:
		if x[elemento] <= 3:
			mAx.append(elemento * x[elemento])
		else:
			mAx.append(elemento * 3)
if len(mAx) > 0:
	print(soma - max(mAx))
else:
	print(soma)


a = list(map(int, input().split()))
b = [sum(a) - min(3, a.count(i)) * i for i in set(a) if a.count(i) >= 2]
print(min(b) if len(b) != 0 else sum(a))


from collections import Counter
t = Counter(map(int, input().split()))
s = ans = sum((x * t[x] for x in t))
for x in t:
	if t[x] > 1:
		ans = min(ans, s - x * min(3, t[x]))
print(ans)


t = list(map(int, input().split()))
tset = list(set(t))
t.sort()
if len(tset) == 1:
	print(tset[0] * 2)
elif len(tset) == 2:
	if t.count(tset[0]) == 1 or t.count(tset[0]) == 4:
		print(tset[0] + tset[1])
	else:
		print(min(t.count(tset[0]) * tset[0], t.count(tset[1]) * tset[1]))
elif len(tset) == 3:
	for i in range(3):
		if t.count(tset[i]) == 3:
			print(sum(t) - 3 * tset[i])
			exit()
	else:
		t.sort()
		if t.count(max(t)) == 1:
			print(sum(t) - 2 * t[3])
		else:
			print(sum(t) - 2 * t[4])
		exit()
elif len(tset) == 4:
	for i in range(4):
		if t.count(tset[i]) == 2:
			print(sum(t) - 2 * tset[i])
			exit()
else:
	print(sum(t))


def cardsFrequencyIsDiffFromOne(cards):
	cardsFrequency = {}
	for card in cards:
		if card not in cardsFrequency:
			cardsFrequency[card] = 1
		else:
			cardsFrequency[card] += 1
	if len(cardsFrequency) == 5:
		return (cardsFrequency, False)
	else:
		return (cardsFrequency, True)

def fiveCards(cards):
	(cardsFrequency, isValid) = cardsFrequencyIsDiffFromOne(cards)
	if isValid:
		minimumSum = {}
		for card in cardsFrequency.keys():
			if cardsFrequency[card] >= 2:
				bulkCopyOfCards = cards.copy()
				i = 0
				if cardsFrequency[card] == 2:
					while i < 2:
						bulkCopyOfCards.remove(card)
						i += 1
				else:
					while i < 3:
						bulkCopyOfCards.remove(card)
						i += 1
				minimumSum[sum(bulkCopyOfCards)] = card
		lenMinSum = len(minimumSum)
		if lenMinSum == 1:
			print(int(list(minimumSum.keys())[0]))
		elif lenMinSum >= 2:
			minimumSumNumber = min(minimumSum.keys())
			print(minimumSumNumber)
	else:
		print(sum(cards))
cards = list(map(int, input().split()))
fiveCards(cards)


from itertools import groupby
tab = sorted(list(map(int, input().split())))
result = sum(tab)
A = reversed(sorted([(x * y, y) for (x, y) in [(x, len(list(y))) for (x, y) in groupby(tab)]]))
for tmp in A:
	if tmp[1] >= 2:
		result -= tmp[0] // tmp[1] * min(3, tmp[1])
		break
print(result)


numbers = list(map(int, input().split()))
sum = 0
count = []
for i in range(0, 101):
	count.append(0)
for number in numbers:
	count[number] += 1
	sum += number
current_sum = sum
for number in numbers:
	if count[number] >= 2:
		if count[number] >= 3:
			multiply = 3
		else:
			multiply = 2
		if sum - number * multiply < current_sum:
			current_sum = sum - number * multiply
print(current_sum)


a = list(map(int, input().split()))
a.sort()
res = a[0] + a[1] + a[2] + a[3] + a[4]
if a[4] == a[3] and a[3] == a[2]:
	res = a[0] + a[1]
if a[4] == a[3]:
	res = min(res, a[0] + a[1] + a[2])
if a[3] == a[2] and a[2] == a[1]:
	res = min(res, a[0] + a[4])
if a[3] == a[2]:
	res = min(res, a[0] + a[1] + a[4])
if a[2] == a[1] and a[1] == a[0]:
	res = min(res, a[3] + a[4])
if a[2] == a[1]:
	res = min(res, a[0] + a[3] + a[4])
if a[1] == a[0]:
	res = min(res, a[2] + a[3] + a[4])
print(res)


from sys import stdin, stdout
input = stdin.readline

def write(n, sep='\n'):
	stdout.write(str(n))
	stdout.write(sep)

def gil():
	return list(map(int, input().split()))
t = gil()
from collections import Counter as C
x = C(t)
m = 0
for i in x:
	if x[i] > 1:
		v = min(3, x[i]) * i
		m = max(v, m)
a = sum(t) - m
print(a)


a = list(map(int, input().split()))
dict = {}
for i in a:
	dict[i] = 0
for i in a:
	dict[i] = dict[i] + 1
min = 9999999999999
if len(set(a)) == 5:
	print(sum(a), flush=True)
else:
	for k in dict:
		lst = [x for x in filter(lambda x: x != k, a)]
		if len(lst) == 0:
			lst.append(k)
			lst.append(k)
		if len(lst) == 1:
			lst.append(k)
		s = sum(lst)
		if dict[k] >= 2 and s < min:
			min = s
	print(min, flush=True)


l = list(map(int, input().split()))
su = sum(l)
l_set = list(set(l))
lp = []
if len(l) - len(l_set) > 0:
	for i in l_set:
		if l.count(i) > 1:
			lp.append(i * min(3, l.count(i)))
	print(su - max(lp))
else:
	print(su)


L = list(map(int, input().split()))
ans = sum(L)
Hash = [0] * 101
for i in L:
	Hash[i] += 1
(max1, maxG) = (0, 0)
for i in range(1, 101):
	if Hash[i] == 2:
		max1 = Hash[i] * i
		if maxG < max1:
			maxG = max1
	elif Hash[i] >= 2:
		max1 = 3 * i
		if maxG < max1:
			maxG = max1
print(ans - maxG)


l = list(map(int, input().split()))
d = []
s = sum(l)
for i in l:
	if l.count(i) == 2:
		d.append(s - i * 2)
	elif l.count(i) >= 3:
		d.append(s - i * 3)
if len(d) == 0:
	print(s)
else:
	print(min(d))


a = list(map(int, input().split()))
c = 0
a2 = [0]
w = 0
ans = a[0] + a[1] + a[2] + a[3] + a[4]
for n in a:
	for j in a:
		if j == n:
			c = c + 1
	if c == 3 or c == 2:
		a2.append(c * n)
	if c > 3:
		a2.append(3 * n)
	c = 0
ans = ans - max(a2)
print(ans)


l = list(map(int, input().split()))
ma = 0
for i in l:
	k = 0
	for j in l:
		if i == j:
			k = k + 1
		if k > 2:
			break
	if k > 1:
		if ma < k * i:
			ma = k * i
print(sum(l) - ma)


data = list(map(int, input().split()))
info = list(map(lambda x: (x, data.count(x)), data))
best = 0
for (val, count) in info:
	if count > 1:
		best = max(best, val * min(3, count))
print(sum(data) - best)


class CodeforcesTask680ASolution:

	def __init__(self):
		self.result = ''
		self.nums = []

	def read_input(self):
		self.nums = [int(x) for x in input().split(' ')]

	def process_task(self):
		self.nums.sort()
		if len(set(self.nums)) == 2:
			if max([self.nums.count(x) for x in list(set(self.nums))]) == 3:
				self.result = str(min(self.nums[0] * self.nums.count(self.nums[0]), self.nums[-1] * self.nums.count(self.nums[-1])))
			else:
				self.result = str(self.nums[0] + self.nums[-1])
		elif len(set(self.nums)) == 5:
			self.result = str(sum(self.nums))
		elif len(set(self.nums)) == 1:
			self.result = str(self.nums[0] * 2)
		elif len(set(self.nums)) == 4:
			rep = [x[0] for x in [(y, self.nums.count(y)) for y in list(set(self.nums))] if x[1] == 2][0]
			self.result = str(sum(self.nums) - 2 * rep)
		else:
			if max([self.nums.count(x) for x in list(set(self.nums))]) == 3:
				d = 3
			else:
				d = 2
			rep = [x[0] for x in [(y, self.nums.count(y)) for y in list(set(self.nums))] if x[1] > 1]
			rep.sort()
			self.result = str(sum(self.nums) - d * rep[-1])

	def get_result(self):
		return self.result
Solution = CodeforcesTask680ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


from collections import Counter
t = list(map(int, input().split()))
cnt = Counter(t)
print(sum(t) - max([2 * el if cnt[el] == 2 else 3 * el for el in cnt if cnt[el] > 1] + [0]))


a = list(map(int, input().split()))
d = {}
for i in a:
	x = a.count(i)
	if x > 1:
		d[i] = x
s = sum(a)
a = s
for i in d.keys():
	x = s - i * min(d[i], 3)
	if x < a:
		a = x
print(a)


l = [*map(int, input().split())]
tmp = {}
Ans = []
for i in l:
	if tmp.get(i, -1) == -1:
		tmp[i] = 1
	else:
		tmp[i] += 1
for i in tmp.keys():
	if tmp[i] == 2:
		Ans.append(i * 2)
	elif tmp[i] == 3:
		Ans.append(i * 3)
	elif tmp[i] > 3:
		Ans.append(i * 3)
	else:
		pass
print(sum(l) - max(Ans, default=0))


from collections import Counter
t = list(map(int, input().split(' ')))
cnt = Counter()
for tt in t:
	cnt[tt] += 1
ans = sum(t)
for (tt, n) in cnt.items():
	if n >= 2:
		ans = min(ans, sum(t) - min(n, 3) * tt)
print(ans)


def main():
	t = list(map(int, input().split()))
	sum = 0
	for v in t:
		sum += v
	ans = sum
	for i in range(5):
		ct = 0
		for j in range(5):
			if t[i] == t[j]:
				ct += 1
		if ct >= 2:
			val = sum - ct * t[i]
			if ct > 3:
				val = sum - 3 * t[i]
			ans = min(ans, val)
	print(ans)
main()


sample_dict = dict()
total = 0
for i in map(int, input().split()):
	sample_dict[i] = sample_dict.get(i, 0) + 1
	total += i
max_value = float('-inf')
for (key, value) in sample_dict.items():
	if value >= 2:
		if max_value < key * min(value, 3):
			max_value = key * min(value, 3)
if max_value == float('-inf'):
	max_value = 0
print(total - max_value)


t = list(map(int, input().split()))
mp = {}
add = 0
for i in t:
	if i not in mp:
		mp.update({i: 1})
	else:
		mp[i] += 1
	add += i
sub = 0
for i in mp:
	if mp[i] < 2:
		continue
	sub = max(sub, i * min(3, mp[i]))
print(add - sub)


dic = {}
for i in map(int, input().split()):
	dic.setdefault(i, 0)
	dic[i] += 1
maxv = 0
sumv = 0
for i in dic:
	sumv += i * dic[i]
	if dic[i] == 2:
		maxv = max(maxv, 2 * i)
	elif dic[i] >= 3:
		maxv = max(maxv, 3 * i)
print(sumv - maxv)


def cards(lst):
	(s, m) = (sum(lst), 1000)
	for i in range(len(lst)):
		count = 0
		for j in range(len(lst)):
			if lst[i] == lst[j]:
				count += 1
		if count >= 3:
			m = min(m, s - 3 * lst[i])
		elif count == 2:
			m = min(m, s - 2 * lst[i])
		else:
			m = min(m, s)
	return m
a = [int(i) for i in input().split()]
print(cards(a))


import sys
from collections import Counter
arr = list(map(int, input().split()))
d = Counter(arr)
temp = [min(v, 3) * k for (k, v) in list(d.items()) if v >= 2]
print(sum(arr) - max(temp + [0, 0]))
sys.stdout.flush()


from collections import Counter
li = list(map(int, input().split()))
count = dict(Counter(li))
ans = sum(li)
for (k, v) in count.items():
	if v >= 3:
		ans = min(ans, sum(li) - k * 3)
	elif v == 2:
		ans = min(ans, sum(li) - k * 2)
print(int(ans))


a = list(map(int, input().split()))
s = ans = sum(a)
for i in a:
	fr = a.count(i)
	if fr >= 2:
		ans = min(ans, s - min(3, fr) * i)
print(ans)


ch = input().split()
ch = [int(x) for x in ch]
(a, b, c, d, e) = (ch[0], ch[1], ch[2], ch[3], ch[4])
S = a + b + c + d + e
D = {}
for i in ch:
	if i not in D:
		D[i] = 1
	else:
		D[i] += 1
S1 = S
d = list(D.keys())
for i in range(len(d)):
	if D[d[i]] > 3:
		if S - 3 * d[i] < S1:
			S1 = S - 3 * d[i]
	elif D[d[i]] > 1:
		if S - D[d[i]] * d[i] < S1:
			S1 = S - D[d[i]] * d[i]
print(S1)


arr = [int(x) for x in input().split()]
d = {}
for i in arr:
	d[i] = d.get(i, 0) + 1
if len(d) == 5:
	print(sum(d.keys()))
else:
	a = []
	total = 0
	for i in d:
		if d[i] == 1:
			total += i
		elif d[i] < 4:
			a.append(i * d[i])
		else:
			total += (d[i] - 3) * i
	a.sort()
	total += a[0] if len(a) > 1 else 0
	print(total)


numbers = list(map(int, input().split()))
dic = {}
total = sum(numbers)
for i in range(len(numbers)):
	dic[numbers[i]] = dic.get(numbers[i], 0) + 1
discard = 0
for (key, value) in dic.items():
	if value >= 2:
		discard = max(discard, key * min(3, value))
print(total - discard)


arr = list(map(int, input().split()))
m1 = sum(arr)
for i in arr:
	if arr.count(i) == 2:
		m1 = min(m1, sum(arr) - i - i)
	elif arr.count(i) >= 3:
		m1 = min(m1, sum(arr) - i - i - i)
print(m1)


from collections import Counter
a = list(map(int, input().split()))
Q = Counter(a)
QQQ = []
for i in range(5):
	if Q[a[i]] == 2:
		QQQ.append(a[i] * 2)
	if Q[a[i]] >= 3:
		QQQ.append(a[i] * 3)
if QQQ == []:
	print(sum(a))
else:
	print(sum(a) - max(QQQ))


string = list(map(int, list(input().split())))
letters = []
indexes = []
for letter in string:
	if letter in letters:
		indexes[letters.index(letter)] += 1
	else:
		letters.append(letter)
		indexes.append(1)
dupes = [0]
for r in range(0, len(letters)):
	if indexes[r] in [3, 4, 5]:
		dupes.append(letters[r] * 3)
	elif indexes[r] == 2:
		dupes.append(letters[r] * 2)
dupes.sort()
print(sum(string) - dupes[-1])


a = list(map(int, input().split()))
count = [0] * 101
b = []
a.sort()
sum1 = 0
for i in range(5):
	count[a[i]] += 1
	if count[a[i]] >= 2:
		if not a[i] in b:
			b.append(a[i])
	sum1 += a[i]
i = len(b) - 1
if len(b) == 1 and len(b) > 0:
	sum1 -= min(count[b[i]], 3) * b[i]
elif len(b) >= 2:
	sum1 -= max(min(count[b[i]], 3) * b[i], min(count[b[i - 1]], 3) * b[i - 1])
print(sum1)


from collections import Counter
t = [int(x) for x in input().split()]
cnt = Counter(t)
s = sum(t)
ans = s
for v in cnt:
	if cnt[v] >= 3:
		ans = min(ans, s - v * 3)
	if cnt[v] >= 2:
		ans = min(ans, s - v * 2)
print(ans)


t = sorted(list(map(int, input().split())))
if len(set(t)) == 5:
	print(sum(t))
else:
	prev = 0
	total = 0
	count = 0
	output = 0
	for i in t:
		if prev != i:
			count = 0
			total = 0
		if count != 3:
			total += i
			count += 1
		if count >= 2:
			output = max(total, output)
		prev = i
	print(sum(t) - output)


a = [int(i) for i in input().split()]
s = sum(a)
ms = 0
for i in a:
	k = 0
	for j in a:
		if i == j:
			k += 1
	if k >= 3 and i * 3 > ms:
		ms = i * 3
	elif k == 2 and i * 2 > ms:
		ms = i * 2
print(s - ms)


from collections import defaultdict, deque, Counter, OrderedDict
import sys
sys.setrecursionlimit(20000)

def main():
	l = list(map(int, input().split()))
	(ans, tos) = (sum(l), 0)
	mp = defaultdict(int)
	for i in l:
		mp[i] += 1
	for k in mp:
		if mp[k] >= 3:
			tos = max(tos, k * 3)
		if mp[k] >= 2:
			tos = max(tos, k * 2)
	print(ans - tos)
main()


from collections import Counter

def solve():
	N = list(map(int, input().split()))
	S = sum(N)
	co = Counter(N)
	ans = S
	for n in co:
		if co[n] >= 3:
			ans = min(ans, S - n * 3)
		elif co[n] == 2:
			ans = min(ans, S - n * 2)
	print(ans)
solve()


import sys
import math
import collections
import bisect
import string

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	arr = get_list()
	ans = sum(arr)
	counter = collections.Counter(arr)
	val = 0
	for i in counter:
		freq = counter[i]
		if freq >= 2:
			val = max(val, min(freq, 3) * i)
	print(ans - val)


arr = [int(i) for i in input().split()]
m = [0] * len(arr)
sum = 0
j = 0
for k in range(0, len(arr)):
	sum = sum + arr[k]
	if arr.count(arr[k]) >= 2 and arr.count(arr[k]) <= 3:
		m[j] = arr.count(arr[k]) * arr[k]
		j = j + 1
	if arr.count(arr[k]) > 3:
		m[j] = 3 * arr[k]
		j = j + 1
print(sum - max(m))


t = [int(x) for x in input().split()]
minsum = sum(t)
for i in t:
	icount = t.count(i)
	if icount >= 3:
		minsum = min(minsum, sum(t) - 3 * i)
	if icount >= 2:
		minsum = min(minsum, sum(t) - 2 * i)
print(minsum)


from collections import Counter
n = list(map(int, input().split()))
c = Counter(n)
t = 0
for (k, v) in c.items():
	if v <= 3 and v >= 2:
		t = max(v * k, t)
	elif v > 3:
		t = max(3 * k, t)
print(sum(n) - t)


n = list(map(int, input().split()))
n.sort()
ans = 0
for i in range(len(n) - 1):
	if n[i] == n[i + 1]:
		ans = max(n[i] + n[i + 1], ans)
for i in range(len(n) - 2):
	if n[i] == n[i + 1] and n[i] == n[i + 2]:
		ans = max(n[i] + n[i + 1] + n[i + 2], ans)
print(sum(n) - ans)


t = list(map(int, input().split()))
p = sum(t)
for i in range(5):
	if t.count(t[i]) >= 2:
		p = min(p, sum(t) - t[i] * 2)
for i in range(5):
	if t.count(t[i]) >= 3:
		p = min(p, sum(t) - t[i] * 3)
print(p)


T = list(map(int, input().split()))
T.sort()
sumt = sum(T)
ans = sumt
for t in T:
	if T.count(t) == 2:
		ans = min(ans, sumt - t * 2)
for t in T:
	if T.count(t) >= 3:
		ans = min(ans, sumt - t * 3)
print(ans)


l = list(map(int, input().split()))
l.sort()
fin = sum(l)
res = 10 ** 9
for i in range(3):
	if l[i] == l[i + 1] == l[i + 2]:
		res = min(res, fin - l[i] - l[i + 1] - l[i + 2])
for i in range(4):
	if l[i] == l[i + 1]:
		res = min(res, fin - l[i] - l[i + 1])
print(res) if res != 10 ** 9 else print(fin)


from collections import Counter
cards = input().split()
cards = [int(i) for i in cards]
count = Counter(cards)
max_dis = 0
current_dis = -1
qtd_dis = 0
for i in count:
	if count[i] > 1:
		if i * min(count[i], 3) > max_dis:
			max_dis = i * min(count[i], 3)
print(sum(cards) - max_dis)


x1 = input().split()
l1 = []
for i in x1:
	i = int(i)
	l1.append(i)
sum1 = 100000000000
l2 = l1.copy()
for i in l2:
	c = 0
	l1 = l2.copy()
	z = l1.count(i)
	if z > 1:
		if z > 3:
			z = 3
		while c < z:
			l1.remove(i)
			c += 1
	y = sum(l1)
	if sum1 > y:
		sum1 = y
print(sum1)


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

def solve(cards):
	if len(set(cards)) == 5:
		return sum(cards)
	else:
		candidates = 0
		for card in sorted(set(cards), reverse=True):
			if cards.count(card) == 2:
				candidates = max(candidates, 2 * card)
			elif cards.count(card) >= 3:
				candidates = max(candidates, 3 * card)
				break
	return sum(cards) - candidates
print(solve(cards))


t = list(map(int, input().split()))
sumt = sum(t)
arr = []
for i in range(0, 5):
	for j in range(i, 5):
		if i != j:
			if t[i] == t[j]:
				arr.append(sumt - t[i] - t[j])
for i in range(0, 5):
	for j in range(i, 5):
		for k in range(j, 5):
			if i != j != k:
				if t[i] == t[j] == t[k]:
					arr.append(sumt - t[i] - t[j] - t[k])
if arr == []:
	print(sumt)
else:
	print(min(arr))


y = sorted(list(map(int, input().split())))
p = []
for i in range(1, len(y)):
	x = y.count(y[-i])
	if x >= 2:
		if x <= 3:
			p.append(sum(y) - y[-i] * x)
		else:
			p.append(sum(y) - y[-i] * 3)
print(sum(y) if len(p) == 0 else min(p))


arr1 = list(map(int, input().split()))
b = [arr1.count(i) for i in arr1]
ans = 0
for i in range(len(arr1)):
	if b[i] > 1:
		ans = max(ans, arr1[i] * min(b[i], 3))
print(sum(arr1) - ans)


arr = [int(x) for x in input().split()]
arr.sort()
max = 0
last = arr[0]
c = 1
for i in range(1, 5):
	if last == arr[i]:
		c += 1
	else:
		if c == 2 or c == 3:
			x = c * arr[i - 1]
			if max < x:
				max = x
		if c > 3:
			x = 3 * arr[i - 1]
			if max < x:
				max = x
		c = 1
		last = arr[i]
if c > 1:
	if c == 2 or c == 3:
		x = c * arr[4]
		if max < x:
			max = x
	if c > 3:
		x = 3 * arr[4]
		if max < x:
			max = x
sum = 0
for x in arr:
	sum += x
print(sum - max)


from collections import Counter
t = list(map(int, input().split()))
cnt = Counter(t)
res = 0
for el in cnt:
	if cnt[el] >= 3:
		res = max(res, 3 * el)
	elif cnt[el] == 2:
		res = max(res, 2 * el)
print(sum(t) - res)


l = list(map(int, input().split()))
m = []
p = []
s = []
for i in range(len(l)):
	if l[i] not in m:
		m.append(l[i])
	else:
		p.append(l[i])
		c = l.count(l[i])
		s.append(c)
if len(m) == len(l):
	print(sum(l))
else:
	t = []
	for i in range(len(p)):
		if s[i] < 3:
			d = p[i] * s[i]
			t.append(d)
		else:
			d = p[i] * 3
			t.append(d)
	g = max(t)
	h = sum(l)
	print(h - g)


a = [int(i) for i in input().split()]
s = sum(a)
mi = s
for i in a:
	n = a.count(i)
	if n > 2:
		mi = min(mi, s - 3 * i)
	elif n == 2:
		mi = min(mi, s - 2 * i)
print(mi)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
lst = get_int_list()
s = sum(lst)
n = len(lst)
m = s
for i in range(n):
	for j in range(n):
		if i != j and lst[i] == lst[j]:
			m = min(m, s - 2 * lst[i])
for i in range(n):
	for j in range(n):
		for k in range(n):
			if i != j and j != k and (i != k) and (lst[i] == lst[j] == lst[k]):
				m = min(m, s - 3 * lst[i])
print(m)


s = list(map(int, input().split()))
d = dict()
for i in s:
	if i not in d:
		d[i] = 0
	d[i] += 1
sm = sum(s)
ans = sm
for i in d.items():
	if i[1] >= 2:
		ans = min(ans, sm - i[0] * min(i[1], 3))
print(ans)


t = list(map(int, input().split()))
tot = 0
for e in t:
	tot = tot + e
res = tot
for i in range(len(t)):
	for j in range(i + 1, len(t)):
		if t[i] == t[j]:
			res = min(res, tot - 2 * t[i])
for i in range(len(t)):
	for j in range(i + 1, len(t)):
		for k in range(j + 1, len(t)):
			if t[i] == t[j] and t[j] == t[k]:
				res = min(res, tot - 3 * t[i])
print(res)


a = list(map(int, input().split()))
su = sum(a)
b = []
for i in set(a):
	b.append(i * (a.count(i) // 3) * 3)
	b.append(i * min(2, a.count(i) // 2 * 2))
print(su - max(b))


string = input()
numbers = string.split(' ')
for x in range(5):
	numbers[x] = int(numbers[x])
unique = set(numbers)
values = [0]
for x in unique:
	a = numbers.count(x)
	if a >= 2:
		if a == 2:
			values.append(x * 2)
		else:
			values.append(x * 3)
print(sum(numbers) - max(values))


mat = list(map(int, input().split()))
sat = [0]
d = {}
for i in mat:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
for j in d:
	if d[j] > 3:
		d[j] = 3
	if d[j] > 1:
		sat.append(j * d[j])
print(sum(mat) - max(sat))


a = list(map(int, input().split()))
a.sort()
b = [0]
c = 0
for i in range(1, 5):
	if a[i] != a[i - 1]:
		if i - c >= 2:
			b.append(min(i - c, 3) * a[i - 1])
		c = i
if 5 - c >= 2:
	b.append(min(5 - c, 3) * a[4])
print(sum(a) - sorted(b)[-1])


inp = input().split()
for i in range(len(inp)):
	inp[i] = int(inp[i])
bsum = sum(inp)
for i in range(len(inp)):
	occr = 0
	sum = 0
	for x in inp:
		if x == inp[i] and occr < 3:
			occr += 1
			continue
		else:
			sum += x
	if occr > 1 and sum < bsum:
		bsum = sum
print(bsum)


(k1, k2, k3, k4, k5) = map(int, input().split())
s = {}
s[k1] = s.get(k1, 0) + 1
s[k2] = s.get(k2, 0) + 1
s[k3] = s.get(k3, 0) + 1
s[k4] = s.get(k4, 0) + 1
s[k5] = s.get(k5, 0) + 1
m = 0
su = k1 + k2 + k3 + k4 + k5
for i in s:
	if s[i] == 2 or s[i] == 3:
		m = max(m, i * s[i])
	if s[i] > 3:
		m = max(m, i * 3)
print(su - m)


from collections import Counter
t = [int(x) for x in input().split()]
print(sum(t) - max([n * min(f, 3) for (n, f) in Counter(t).items() if f > 1] or [0]))


dct = {}
summ = 0
for i in input().split(sep=' '):
	parse = int(i)
	if parse in dct:
		dct[parse] += 1
	else:
		dct[parse] = 1
	summ += parse
mx = 0
for (val, count) in dct.items():
	if count == 2 or count == 3:
		mx = max(mx, count * val)
	if count > 3:
		mx = max(mx, 3 * val)
print(summ - mx)


def main():
	numbers = [int(_) for _ in input().split()]
	frequencies = {}
	for i in numbers:
		if i in frequencies:
			frequencies[i] += 1
		else:
			frequencies[i] = 1
	multiple_apperances = [i * min(3, frequencies[i]) for i in frequencies if frequencies[i] > 1]
	s = sum(numbers)
	print(s if len(multiple_apperances) < 1 else s - max(multiple_apperances))
main()


from collections import defaultdict, deque, Counter, OrderedDict
import sys
sys.setrecursionlimit(20000)

def main():
	(a, b, c, d, e) = sorted(list(map(int, input().split())))
	ans = a + b + c + d + e
	mp = defaultdict(int)
	mp[a] += 1
	mp[b] += 1
	mp[c] += 1
	mp[d] += 1
	mp[e] += 1
	tos = 0
	for k in mp:
		if mp[k] >= 3:
			tos = max(tos, k * 3)
		if mp[k] >= 2:
			tos = max(tos, k * 2)
	print(ans - tos)
main()


import collections

def minCardSum(arr):
	count = collections.Counter(arr)
	current = 0
	for num in arr:
		if count[num] > 1 and num * min(count[num], 3) > current:
			current = min(count[num], 3) * num
	return sum(arr) - current
print(minCardSum(list(map(int, input().split()))))


t = [int(x) for x in input().split()]
total = sum(t)
sumOfCards = {}
for i in range(0, 5):
	if sumOfCards.get(t[i]) == None:
		sumOfCards[t[i]] = t[i]
	elif sumOfCards[t[i]] <= 2 * t[i]:
		sumOfCards[t[i]] += t[i]
maxPoint = 0
for i in sumOfCards:
	if sumOfCards[i] > i and sumOfCards[i] > maxPoint:
		maxPoint = sumOfCards[i]
print(total - maxPoint)


def solution(l1):
	l1.sort()
	i = 0
	ans = [0]
	while i < len(l1):
		targ = l1[i]
		j = 0
		count = 0
		while j < len(l1):
			if l1[j] == targ:
				count += 1
			j += 1
		if count >= 3:
			ans.append(3 * targ)
		elif count >= 2:
			ans.append(2 * targ)
		i += 1
	ans.sort()
	ans.reverse()
	return sum(l1) - ans[0]

def answer():
	l1 = [int(x) for x in input().split()]
	print(solution(l1))
answer()


(a, b, c, d, e) = map(int, input().split())
sumout = a + b + c + d + e
s = [0, 0, a, b, c, d, e]
s.sort()
s = s[::-1]
c = 0
fortr = 0
forp1 = 0
forp2 = 0
for i in range(5):
	if s[i] == s[i + 1] == s[i + 2]:
		fortr = s[i] * 3
	elif s[i] == s[i + 1]:
		if forp1 == 0:
			forp1 = s[i] * 2
		else:
			forp2 = s[i] * 2
print(sumout - max(fortr, forp1, forp2))


from collections import defaultdict
A = list(map(int, input().split()))
A.sort()
ans = sum(A)
if A[4] == A[3]:
	ans = min(ans, sum(A[:3]))
	if A[3] == A[2]:
		ans = min(ans, sum(A[:2]))
if A[3] == A[2]:
	ans = min(ans, A[0] + A[1] + A[4])
	if A[2] == A[1]:
		ans = min(ans, A[0] + A[4])
if A[2] == A[1]:
	ans = min(ans, A[0] + A[3] + A[4])
	if A[1] == A[0]:
		ans = min(ans, A[3] + A[4])
if A[1] == A[0]:
	ans = min(ans, sum(A[2:]))
print(ans)


import atexit, io, sys, collections, math, heapq, fractions, copy, os, functools
import sys
import random
import collections
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
ais = list(map(int, input().split()))
cc = collections.Counter(ais)
s = sum(ais)
ans = s
for k in cc:
	if cc[k] >= 2:
		ans = min(ans, s - 2 * k)
	if cc[k] >= 3:
		ans = min(ans, s - 3 * k)
print(ans)


from collections import Counter
M = list(map(int, input().split()))
sum_ = sum(M)
dict_ = Counter(M)
S = []
for i in dict_.keys():
	if dict_[i] == 2:
		S.append(i * 2)
	elif dict_[i] >= 3:
		S.append(i * 3)
if S:
	x = max(S)
else:
	x = 0
print(sum_ - x)


l = list(map(int, input().split()))
c = dict([(x, l.count(x)) for x in l])
s = []
for i in c.keys():
	if c[i] == 2:
		s.append(sum(l) - 2 * i)
	elif c[i] >= 3:
		s.append(sum(l) - 3 * i)
	else:
		s.append(sum(l))
print(min(s))


li = list(map(int, input().split()))
li.sort()
sub = 0
for i in range(5):
	a = li.count(li[i])
	if a > 1:
		sub = max(min(a, 3) * li[i], sub)
print(sum(li) - sub)


cards = list(map(int, input().split()))
cards.sort()
couple = triple = 0
for i in range(4):
	if cards[i] == cards[i + 1]:
		couple = cards[i]
for i in range(3):
	if cards[i] == cards[i + 1] == cards[i + 2]:
		triple = cards[i]
print(min(sum(cards), sum(cards) - max(triple * 3, couple * 2)))


import sys
import os
from collections import Counter

def changeStdioToFile():
	path = os.path.dirname(os.path.abspath(__file__))
	sys.stdin = open(f'{path}/input.txt', 'r')
	sys.stdout = open(f'{path}/output.txt', 'w')
t = 1
for _ in range(t):
	a = [int(x) for x in input().split()]
	l = Counter(a)
	r = s = sum(a)
	for k in l:
		if l[k] > 1:
			r = min(r, s - min(3, l[k]) * int(k))
	print(r)


s = [int(j) for j in input().split()]
o = []
for i in range(5):
	if s[i] in s[i + 1:]:
		o.append(s[i])
m = sum(s)
for i in o:
	y = 0
	t = 0
	for j in s:
		if j != i or t > 2:
			y += j
		if j == i:
			t += 1
	m = min(y, m)
print(m)


l = list(map(int, input().split()))
(x, y) = ([], [])
z = []
if len(l) == len(set(l)):
	print(sum(l))
	exit()
for i in range(len(l)):
	if l.count(l[i]) == 2:
		x.append(l[i])
	elif l.count(l[i]) >= 3:
		y.append(l[i])
ans = sum(l)
x = list(set(x))
y = list(set(y))
if len(x) > 0:
	for i in range(len(x)):
		z.append(x[i] * 2)
if len(y) > 0:
	for i in range(len(y)):
		z.append(y[i] * 3)
print(ans - max(z))


a = list(map(int, input().split()))
a.sort()
s1 = 0
s2 = 0
f = True
for i in range(4):
	if a[i] == a[i + 1]:
		s1 = 2 * a[i]
for i in range(3):
	if a[i] == a[i + 1] == a[i + 2]:
		s2 = 3 * a[i]
print(sum(a, 0) - max(s1, s2))


a = list(map(int, input().split()))
s = set(a)
ans = 0
for x in s:
	if a.count(x) > 1 and x * min(3, a.count(x)) > ans:
		ans = x * min(3, a.count(x))
print(sum(a) - ans)


a = list(map(int, input().split()))
s = {}
summa = 0
for i in a:
	summa += i
	try:
		s[i] += 1
	except KeyError:
		s[i] = 1
ans = summa
for i in s:
	if s[i] == 1:
		pass
	elif s[i] == 2:
		ans = min(ans, summa - i * 2)
	else:
		ans = min(ans, summa - i * 3)
print(ans)


s = list(map(int, input().split()))
Sum = sum(s)
for i in s:
	if s.count(i) == 2 and sum(s) - 2 * i < Sum:
		Sum = sum(s) - 2 * i
	elif s.count(i) > 2 and sum(s) - 3 * i < Sum:
		Sum = sum(s) - 3 * i
print(Sum)


t = [int(x) for x in input().split(' ')]
p = [sum(t)]
for c in t:
	if t.count(c) > 1:
		p.append(sum(t) - c * min(t.count(c), 3))
print(min(p))


l = sorted(map(int, input().split()))[::-1]
(s, x) = (sum(l), 0)
for i in l:
	if l.count(i) == 2:
		if x < 2 * i:
			x = 2 * i
	if l.count(i) >= 3:
		if x < 3 * i:
			x = 3 * i
print(s - x)


list = [int(i) for i in input().split()]
som = sum(list)
list.sort(reverse=True)
res = [som]
for i in range(5):
	k = list.count(list[i])
	if k >= 2 and k <= 3:
		res.append(som - list[i] * k)
	elif k >= 4:
		res.append(som - list[i] * 3)
print(min(res))


entrada = input()
cards = entrada.split(' ')
integer_cards = []
for card in cards:
	integer_cards.append(int(card))
integer_cards.sort(reverse=True)
dict_cards = {}
for card in integer_cards:
	if dict_cards.get(card) != None:
		dict_cards[card] += 1
	else:
		dict_cards.update({card: 1})
t1 = 0
t2 = 0
for card in dict_cards:
	if dict_cards[card] == 2:
		t1 = max(t1, card)
	elif dict_cards[card] >= 3:
		t2 = max(t2, card)
if t1 * 2 > t2 * 3:
	print(sum(integer_cards) - t1 * 2)
else:
	print(sum(integer_cards) - t2 * 3)


a = list(map(int, input().split()))
b = {}
sum = 0
for i in a:
	if i not in b:
		b[i] = 1
	else:
		b[i] += 1
p = []
for (i, j) in b.items():
	if j == 1:
		sum += i
	elif j > 3:
		sum += i * (j - 3)
	else:
		p += [i * j]
if len(p) > 1:
	sum += min(p)
print(sum)


l = list(map(int, input().split()))
freq = {}
for i in l:
	if i in freq:
		freq[i] += 1
	else:
		freq[i] = 1
l1 = []
for i in freq:
	x = max(freq)
	if freq[i] >= 2:
		s = 0
		for j in l:
			if i != j:
				s = s + j
		if freq[i] > 3:
			s = s + i * (freq[i] - 3)
		l1.append(s)
if len(l1) > 0:
	print(min(l1))
else:
	s = 0
	for i in l:
		s = s + i
	print(s)


import math

def get_primes(prime_supr):
	is_prime = [0] * 2 + [1] * prime_supr
	for i in range(2, int(math.sqrt(prime_supr)) + 1):
		if is_prime[i]:
			for j in range(i * i, prime_supr + 1, i):
				is_prime[j] = 0
	return is_prime

def get_int():
	return map(int, input().split())
a = list(get_int())
a.append(0)
a.append(0)
print(sum(a) - max([i * min(a.count(i), 3) for i in a if a.count(i) > 1]))


a = list(map(int, input().split()))
a.sort()
a = a[::-1]
s = sum(a)
if a[0] == a[1] == a[2]:
	print(s - a[0] * 3)
elif a[1] == a[2] == a[3]:
	print(s - a[1] * 3)
elif a[2] == a[3] == a[4]:
	if a[0] == a[1] and a[0] * 2 > a[2] * 3:
		print(s - a[0] * 2)
	else:
		print(s - a[2] * 3)
elif a[0] == a[1]:
	print(s - a[0] * 2)
elif a[1] == a[2]:
	print(s - a[1] * 2)
elif a[2] == a[3]:
	print(s - a[2] * 2)
elif a[3] == a[4]:
	print(s - a[3] * 2)
else:
	print(s)


s = [int(i) for i in input().split()]
s.sort()
g = 10000000
for i in range(2, -1, -1):
	if s[i] == s[i + 1] == s[i + 2]:
		g = sum(s) - s[i] * 3
		break
for i in range(3, -1, -1):
	if s[i] == s[i + 1]:
		g = min(sum(s) - s[i] * 2, g)
		break
g = min(sum(s), g)
print(g)


card = [int(i) for i in input().split()]
card.sort()
c = 0
mas = [0] * 5
for i in range(5):
	if card.count(card[i]) >= 2:
		mas[i] = card[i] * 2
	if card.count(card[i]) >= 3:
		mas[i] = card[i] * 3
for i in card:
	c += i
print(c - max(mas))


mas = list(map(int, input().split()))
s = sum(mas)
ans = s
for i in range(len(mas)):
	c = mas.count(mas[i])
	if c >= 2:
		ans = min(s - min(c, 3) * mas[i], ans)
print(ans)


ar = list(map(int, input().split()))
rez = 0
for i in ar:
	if ar.count(i) != 1:
		rez = max(rez, min(ar.count(i), 3) * i)
print(sum(ar) - rez)


import collections
t = list(map(int, input().split()))
cnt = collections.Counter(t)
cnt_2 = [0]
cnt_3 = [0]
for (i, c) in cnt.most_common():
	if c == 2:
		cnt_2.append(i)
	elif c >= 3:
		cnt_3.append(i)
c2 = max(cnt_2) * 2
c3 = max(cnt_3) * 3
if c2 > c3:
	print(sum(t) - c2)
else:
	print(sum(t) - c3)


numbers = [int(x) for x in input().split()]
sum_result = []
for (i, x) in enumerate(numbers):
	sum_temp = sum(numbers)
	same_card = 0
	for (j, y) in enumerate(numbers):
		if x == y and (not i == j):
			same_card += 1
	if same_card:
		same_card += 1
	sum_result.append(sum_temp - x * min(3, same_card))
print(min(sum_result))


f = list(map(int, input().split(' ')))
d = {}
s = 0
for i in f:
	s += i
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
for i in d:
	if d[i] > 1:
		if d[i] > 3:
			d[i] = i * 3
		else:
			d[i] = i * d[i]
diff = 0
for i in d:
	if d[i] != 1 and d[i] > diff:
		diff = d[i]
s -= diff
print(s)


a = list(map(int, input().split()))
a.sort(reverse=True)
d = {}
for i in range(len(a)):
	if a[i] not in d:
		d[a[i]] = 1
	else:
		d[a[i]] += 1
f = 0
min1 = float('inf')
for i in range(len(a)):
	if d[a[i]] >= 3:
		w = sum(a) - a[i] * 3
		if min1 > w:
			min1 = w
			f = 1
	elif d[a[i]] >= 2:
		w = sum(a) - a[i] * 2
		if min1 > w:
			min1 = w
			f = 1
if f == 1:
	print(min1)
else:
	print(sum(a))


import itertools

def main():
	data = [int(v) for v in input().split()]
	freq = {}
	for d in data:
		if d not in freq:
			freq[d] = 0
		freq[d] += 1
	mv = sum(data)
	for (k, v) in freq.items():
		if v >= 2:
			mv = min(sum(data) - 2 * k, mv)
		if v >= 3:
			mv = min(sum(data) - 3 * k, mv)
	print(mv)
main()


a = [int(i) for i in input().split()]
ans = sum(a)
for i in range(5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			if a[i] == a[j] == a[k]:
				ans = min(ans, sum(a) - a[i] * 3)
		if a[i] == a[j]:
			ans = min(ans, sum(a) - a[i] * 2)
print(ans)


l = list(map(int, input().split())) + [0]
ans = sum(l)
for k in l:
	if l.count(k) >= 2:
		ans = min(sum(l) - min(l.count(k), 3) * k, ans)
print(ans)


import sys

def minSum(arr):
	num_dict = {}
	max_sum = 0
	for num in sorted(arr, reverse=True):
		max_sum += num
		num_dict[num] = num_dict.get(num, 0) + 1
	max_diff = 0
	for k in num_dict:
		v = num_dict.get(k)
		if v > 1 and v <= 3:
			diff = k * v
		elif v > 3:
			diff = k * 3
		else:
			diff = 0
		if max_diff < diff:
			max_diff = diff
	return max_sum - max_diff

def main():
	arr = list((int(x) for x in sys.stdin.readline().strip().split()))
	print(minSum(arr))
main()


tl = list(map(int, input().split()))
res = []
for t in tl:
	c = tl.count(t)
	if c == 1:
		c = 0
	elif c > 3:
		c = 3
	res += [t * c]
res.sort(reverse=True)
print(sum(tl) - res[0])


x = list(map(int, input().split()))
x_init = x.copy()
x.sort()
i = 0
while i != len(x):
	if x.count(x[i]) == 1 or x.count(x[i]) > 3:
		del x[i]
		i = -1
	i += 1
if len(x) != 0:
	(cur_max, cur_min) = (x[0], x[0])
for j in range(1, len(x)):
	if x[j] == x[j - 1]:
		cur_min += x[j]
		if j == len(x) - 1 and cur_min > cur_max:
			cur_max = cur_min
	else:
		if cur_min > cur_max:
			cur_max = cur_min
		cur_min = x[j]
if len(x) != 0:
	print(sum(x_init) - cur_max)
else:
	print(sum(x_init))


a = 5
l = [0] * 110
h = 0
m = 0
z = 3
z2 = 2
suml = 0
for a in map(int, input().split()):
	suml += a
	if l[a] < 3:
		l[a] += 1
n = len(l) - 1
while n >= 1:
	if l[n] == z:
		h = n * 3
		z += 1
	elif l[n] == z2:
		m = n * 2
		z2 += 1
	if z == 4 and z2 == 3:
		break
	n -= 1
print(suml - max(h, m))


l = list(map(int, input().split(' ')))
s = [0] * 111
sum = 0
for i in range(5):
	sum += l[i]
	s[l[i]] += 1
mx = sum
for i in range(101):
	if s[i] == 2:
		mx = min(mx, sum - i * 2)
	elif s[i] >= 3:
		mx = min(mx, sum - i * 3)
print(mx)


cin = lambda : map(int, input().split())
l = list(cin())
mset = set(l)
sbros = 0
if len(mset) < 5:
	for i in mset:
		temp = l.count(i)
		if temp >= 2 and i * 2 > sbros:
			sbros = 2 * i
		if temp >= 3 and i * 3 > sbros:
			sbros = 3 * i
print(sum(l) - sbros)


li = [int(i) for i in input().split()]
d = dict()
for i in li:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
if len(d) == 5:
	print(sum(list(d.keys())))
elif len(d) == 4:
	sm = 0
	for i in d:
		if d[i] != 2:
			sm += i
	print(sm)
elif len(d) == 3:
	(sm1, sm2, sm3) = (0, 0, 0)
	if 3 in list(d.values()):
		for i in d:
			if d[i] != 3:
				sm1 += i
		print(sm1)
	else:
		key = 0
		for i in d:
			if d[i] == 2 and key == 0:
				sm2 += i * 2
				key = i
			elif d[i] != 2:
				sm2 += i
		for i in d:
			if d[i] == 2 and key != i:
				sm3 += i * 2
			elif d[i] != 2:
				sm3 += i
		print(min(sm2, sm3))
elif len(d) == 2:
	(sm1, sm2, sm3) = (0, 0, 0)
	for i in d:
		if d[i] == 3:
			sm1 += i * 3
		elif d[i] == 2:
			sm2 += i * 2
	for i in d:
		if d[i] == 4:
			sm3 += i
		elif d[i] == 1:
			sm3 += i
	if sm1 != 0 and sm2 != 0:
		print(min(sm1, sm2))
	elif sm3 != 0:
		print(sm3)
elif len(d) == 1:
	for i in d:
		print(2 * i)


a = [int(x) for x in input().split()]
ans = sum(a)
ar = dict()
for i in a:
	if i in ar:
		ar[i] = ar[i] + 1
	else:
		ar[i] = 1
l = -1000
for i in ar:
	if i > 0:
		if (l == -1000 or min(ar[i], 3) * i > min(ar[l], 3) * l) and ar[i] >= 2:
			l = i
if l != -1000:
	ans -= min(ar[l], 3) * l
print(ans)


d = {}
t = list(map(int, input().split()))
s = sum(t)
if len(set(t)) == 1:
	l = len(t)
	if l >= 3:
		print(s - t[0] * 3)
	else:
		print(s - t[0] * l)
else:
	for i in t:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	d = sorted(d.items(), key=lambda x: (x[1], x[0]), reverse=True)
	d = list(filter(lambda x: x[1] >= 2, d))
	d = sorted(d, key=lambda x: x[1] * x[0], reverse=True)
	if len(d) == 0:
		print(s)
	else:
		print(s - d[0][0] * min(3, d[0][1]))


a = [int(x) for x in input().split()]
a.sort(reverse=True)
maxi = 0
for i in a:
	if a.count(i) >= 2:
		temp = 0
		if a.count(i) == 2:
			temp = i * 2
		else:
			temp = i * 3
		if temp > maxi:
			maxi = temp
print(sum(a) - maxi)


a = [x for x in range(5)]
(a[0], a[1], a[2], a[3], a[4]) = map(int, input().split())
a.sort()
ans = 0
for i in range(5):
	ans += a[i]
Max = 0
tsum = a[0]
count = 1
for i in range(4):
	if a[i] == a[i + 1] and count < 3:
		tsum += a[i + 1]
		count = count + 1
		if tsum > Max:
			Max = tsum
	else:
		tsum = a[i + 1]
		count = 1
ans -= Max
print(ans)


cards = list(map(int, input().split()))
sum = 0
keys = []
values = []
for card in cards:
	if card not in keys:
		keys.append(card)
		values.append(1)
	else:
		index = keys.index(card)
		values[index] += 1
	sum += card
max = 0
for (ind, k) in enumerate(keys):
	if values[ind] == 1:
		continue
	if values[ind] >= 3:
		if keys[ind] * 3 > max:
			max = 3 * keys[ind]
	elif keys[ind] * values[ind] > max:
		max = keys[ind] * values[ind]
print(str(sum - max))


def minimum(a):
	for i in range(4):
		if i + 2 <= 4 and a[i] == a[i + 1] and (a[i + 1] == a[i + 2]):
			a.pop(i)
			a.pop(i)
			a.pop(i)
			break
		elif a[i] == a[i + 1]:
			if i:
				a.pop(i)
				a.pop(i)
				break
			elif a[2] == a[3] and a[3] == a[4]:
				if 3 * a[2] > 2 * a[1]:
					a.pop(2)
					a.pop(2)
					a.pop(2)
					break
				else:
					a.pop(0)
					a.pop(0)
					break
			else:
				a.pop(0)
				a.pop(0)
				break
	return sum(a)
a = [int(i) for i in input().split()]
a = sorted(a)
a = a[::-1]
print(minimum(a))


t = sorted(list(map(int, input().split(' '))))
s = sum(t)
result = s
for i in range(4):
	if t[i] == t[i + 1]:
		result = min(result, s - sum(t[i:i + 2]))
for i in range(3):
	if t[i] == t[i + 2]:
		result = min(result, s - sum(t[i:i + 3]))
print(result)


from sys import stdin
SAMPLE = '3\n7 3 7 3 20\n7 9 3 1 8\n10 10 10 10 10\n'
DICT = {}
SUM = 0

def solve():
	min_sum = SUM
	for key in DICT:
		if DICT[key] >= 2:
			sum2 = SUM - (key * 3 if DICT[key] >= 3 else key * 2)
			min_sum = min(min_sum, sum2)
	print(min_sum)

def parse():
	global DICT, SUM
	line = stdin.readline().split()
	SUM = 0
	DICT.clear()
	for i in range(5):
		num = int(line[i])
		SUM += num
		if num in DICT:
			DICT[num] += 1
		else:
			DICT[num] = 1
	solve()
parse()


mas = {}
res = []
for i in input().split():
	x = int(i)
	if x in mas:
		mas[x] += 1
	else:
		mas[x] = 1
s = 0
for i in mas:
	s += mas[i] * i
res.append(s)
for i in mas:
	if mas[i] == 2 or mas[i] == 3:
		res.append(s - i * mas[i])
	elif mas[i] > 3:
		res.append(s - i * 3)
print(min(res), end='')


from collections import Counter
x = list(map(int, input().split(' ')))
max_removed = 0
for (num, count) in Counter(x).most_common():
	if min(count, 3) * num > max_removed and count != 1:
		max_removed = min(count, 3) * num
print(sum(x) - max_removed)


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = 1
if debug:
	test_count = inp()
for _ in range(test_count):
	a = inlt()
	ans = sum(a)
	max_discard = 0
	for x in a:
		c = a.count(x)
		if c >= 2:
			max_discard = max(max_discard, x * min(c, 3))
	print(ans - max_discard)


a = sorted(map(int, input().split()))
p = ((0, 1), (1, 2), (2, 3), (3, 4), (0, 2), (1, 3), (2, 4))
print(sum(a) - max((0 if a[i] != a[j] else (j - i + 1) * a[i] for (i, j) in p)))


a = list(map(int, input().split()))
a = sorted(a, reverse=True)
d = dict()
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
s = 0
dk = list(d.keys())
dv = list(d.values())
t = [0]
i = 0
while i < len(dk):
	if dv[i] > 1 and dv[i] <= 3:
		t.append(dv[i] * dk[i])
	elif dv[i] > 3:
		t.append(3 * dk[i])
	i = i + 1
s = sum(a)
s = s - max(t)
print(s)


a = list(map(int, input().split()))
r = list(set(a))
d = {}
for i in r:
	if a.count(i) >= 2:
		d[i] = a.count(i)
max1 = 0
for i in d:
	if d[i] > 2:
		if i * 3 > max1:
			max1 = i * 3
	elif i * 2 > max1:
		max1 = i * 2
print(sum(a) - max1)


l = list(map(int, input().split()))
setl = list(set(l))
s = sum(l)
ans = s
for i in setl:
	use = s
	if l.count(i) == 2:
		use = s - i * 2
	elif l.count(i) >= 3:
		use = s - i * 3
	if ans > use:
		ans = use
print(ans)


t = [int(x) for x in input().split()]
listOfMoreThanOne = []
if t.count(t[0]) > 1 and t[0] not in listOfMoreThanOne:
	listOfMoreThanOne.append(t[0])
if t.count(t[1]) > 1 and t[1] not in listOfMoreThanOne:
	listOfMoreThanOne.append(t[1])
if t.count(t[2]) > 1 and t[2] not in listOfMoreThanOne:
	listOfMoreThanOne.append(t[2])
if t.count(t[3]) > 1 and t[3] not in listOfMoreThanOne:
	listOfMoreThanOne.append(t[3])
if t.count(t[4]) > 1 and t[4] not in listOfMoreThanOne:
	listOfMoreThanOne.append(t[4])
greatestMinusable = 0
for i in listOfMoreThanOne:
	if i * min(3, t.count(i)) > greatestMinusable:
		greatestMinusable = i * min(3, t.count(i))
print(sum(t) - greatestMinusable)


def p1():
	l = [int(i) for i in input().split()]
	c = [0]
	for i in range(5):
		if l.count(l[i]) == 2:
			c.append(2 * l[i])
		if l.count(l[i]) >= 3:
			c.append(3 * l[i])
	print(sum(l) - max(c))

def p2():
	(n, k) = [int(i) for i in input().split()]
	t = 1
	while k * t <= n:
		t += 1
	print(k * t)

def p3():
	n = int(input())
	l = [int(i) for i in input().split()]
	i = 0
	t = 0
	f = 1
	while t < 90 and f == 1:
		t = t + 15
		if l[i] > t:
			f = 0
		else:
			t = l[i]
		i = i + 1
	print(t)
p1()


a = map(int, input().split())
t = [0] * 101
ans = 0
for x in a:
	t[x] += 1
	ans += x
mx = 0
for i in range(100, 0, -1):
	if t[i] >= 2:
		mx = max(mx, min(3, t[i]) * i)
print(ans - mx)


a = sorted(map(int, input().split()))
ans = sum(a)
for i in range(5):
	if a.count(a[i]) > 1:
		ans = min(ans, sum(a) - min(3, a.count(a[i])) * a[i])
print(ans)


arr = [int(x) for x in input().split()]
set1 = set(arr)
minsum = sum(arr)
for ele in set1:
	sum1 = sum(arr)
	if arr.count(ele) >= 2:
		count = arr.count(ele)
		if count > 2:
			temp = 0
			while temp < 3:
				sum1 -= ele
				temp += 1
		elif count == 2:
			while count != 0:
				sum1 -= ele
				count -= 1
		if minsum > sum1:
			minsum = sum1
print(minsum)


li = list(map(int, input().split()))
sm = sum(li)
mn = sm
for i in li:
	cnt = li.count(i)
	if cnt >= 2:
		mn = min(sum(li) - min(cnt, 3) * i, mn)
print(mn)


a = list(map(int, input().split()))
v = sum(a)
ans = v
for i in range(5):
	for j in range(i + 1, 5):
		if a[i] == a[j]:
			ans = min(ans, v - a[i] - a[j])
for i in range(5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			if a[i] == a[j] == a[k]:
				ans = min(ans, v - a[i] - a[j] - a[k])
print(ans)


a = list(map(int, input().split()))
S = sum(a)
res = S
for x in a:
	n = a.count(x)
	if n >= 2:
		res = min(res, S - min(3, n) * x)
print(res)


n = list(map(int, input().split()))
x = list(set(n))
x.sort()
c = [n.count(i) for i in x]
l = len(c)
if len(x) == 5:
	print(sum(n))
elif len(x) == 1:
	print(2 * x[0])
else:
	ans = 0
	for i in range(l):
		if c[i] == 2:
			ans = 2 * x[i]
	if 3 in c:
		if ans < 3 * x[c.index(3)]:
			ans = 3 * x[c.index(3)]
	elif 4 in c:
		if ans < 3 * x[c.index(4)]:
			ans = 3 * x[c.index(4)]
	print(sum(n) - ans)


read = lambda : list(map(int, input().split()))
t = sorted(read())
Sum = ans = sum(t)
a = set(t)
for i in a:
	if t.count(i) == 1:
		continue
	cur = Sum - min(3, t.count(i)) * i
	ans = min(ans, cur)
print(ans)


n = [int(x) for x in input().split()]
e = []
v = []
t = []
for i in range(len(n) - 1):
	if n[i] in t:
		continue
	count = 1
	t.append(n[i])
	for j in range(i + 1, len(n)):
		if n[j] == n[i]:
			count += 1
	if count > 1:
		e.append(n[i])
		if count < 3:
			v.append(count * n[i])
		else:
			v.append(3 * n[i])
if len(e):
	print(sum(n) - max(v))
else:
	print(sum(n))


a = list(map(int, input().split()))
b = list(set(a))
b.sort()
b.reverse()
li = []
for i in b:
	if a.count(i) == 2:
		l = i * 2
	elif a.count(i) >= 3:
		l = i * 3
	else:
		l = 0
	li.append(l)
print(sum(a) - max(li))


d = {}
summ = 0
cards = list(map(int, input().split()))
for i in range(5):
	d[cards[i]] = d.get(cards[i], 0) + 1
	summ += cards[i]
maxx = 0
for i in d:
	if d[i] >= 2:
		if d[i] == 2:
			maxx = max(maxx, 2 * i)
		elif d[i] == 3:
			maxx = max(maxx, 3 * i)
		else:
			maxx = max(maxx, 3 * i)
print(summ - maxx)


import math
arr = [int(x) for x in input().split()]
Sum = sum(arr)
l = list(set(arr))
k = []
for i in range(0, len(l)):
	k.append(arr.count(l[i]))
Min = int(Sum)
f = [Min]
for i in range(0, len(k)):
	if k[i] == 2:
		f.append(int(Sum) - 2 * l[i])
	elif k[i] >= 3:
		f.append(int(Sum) - 3 * l[i])
Min = int(min(f))
print(Min)


l = [int(i) for i in input().split()]
s = sum(l)
aux = 0
from collections import Counter
c = Counter(l)
for i in sorted(list(set(l)))[::-1]:
	if c[i] >= 3:
		aux = max(aux, 3 * i)
	elif c[i] == 2:
		aux = max(aux, c[i] * i)
print(s - aux)


A = list(map(int, input().split()))
A.sort()
ans = sum(A)
for i in range(4, 1, -1):
	if A[i] == A[i - 1] == A[i - 2]:
		ans = min(ans, sum(A) - 3 * A[i])
for i in range(4, 0, -1):
	if A[i] == A[i - 1]:
		ans = min(ans, sum(A) - 2 * A[i])
print(ans)


cards = input().split()
cards = sorted([int(card) for card in cards])
delete_card = 0
card_sum = sum(cards)
card_number = []
card_repetition = []
is_missing = True
for card in cards:
	if card_number == []:
		card_number.append(card)
		card_repetition.append(1)
		continue
	for (numeration_idx, numeration) in enumerate(card_number):
		if numeration == card:
			card_repetition[numeration_idx] += 1
			is_missing = False
	if is_missing:
		card_number.append(card)
		card_repetition.append(1)
	is_missing = True
max_subtraction = 0
for i in range(len(card_repetition)):
	if card_repetition[i] > 1:
		if card_repetition[i] > 3:
			max_subtraction_candidate = card_number[i] * 3
		else:
			max_subtraction_candidate = card_number[i] * card_repetition[i]
		if max_subtraction < max_subtraction_candidate:
			max_subtraction = max_subtraction_candidate
print(card_sum - max_subtraction)


def solve(arr):
	dct = {}
	maxx = 0
	for i in range(len(arr)):
		if arr[i] in dct:
			dct[arr[i]] += 1
		else:
			dct[arr[i]] = 1
	for j in dct.keys():
		if dct[j] >= 2:
			tmp = j * min(3, dct[j])
			if tmp > maxx:
				maxx = tmp
	return sum(arr) - maxx
arr = [int(x) for x in input().split()]
print(solve(arr))


x = input().split(' ')
x = list(map(int, x))
high_sum = 0
for i in x:
	if x.count(i) == 2:
		high_sum = max(i * 2, high_sum)
	elif x.count(i) > 2:
		high_sum = max(i * 3, high_sum)
print(sum(x) - high_sum)


t = [int(a) for a in input().split()]
num = {}
for n in t:
	num[n] = t.count(n)
removes = [0]
for (n, k) in num.items():
	if k == 2 or k == 3:
		removes.append(n * k)
	elif k >= 3:
		removes.append(n * 3)
print(sum(t) - max(removes))


cards = list(map(int, input().split()))
cards.sort()
test = []
for i in cards:
	if cards.count(i) > 1 and i not in test:
		test.append(i)
compare = 0
check = 0
number = 0
if test == []:
	print(sum(cards))
else:
	for i in test:
		compare = cards.count(i) * i
		check = max(check, compare)
		if check == compare:
			number = i
	x = cards.count(number)
	x = min(x, 3)
	for j in range(int(x)):
		cards.remove(number)
	print(sum(cards))


from operator import itemgetter
ti = list(map(int, input().split()))
ti.sort()
num = sum(ti)
num2 = num
num3 = num
for i in range(4, 1, -1):
	if ti[i] == ti[i - 1] and ti[i - 2] == ti[i]:
		num2 -= ti[i] * 3
		break
for i in range(4, 0, -1):
	if ti[i] == ti[i - 1]:
		num3 -= ti[i] * 2
		break
print(min(num2, num3))


a = list(map(int, input().split()))
k = set(a)
arr = []
if len(k) == len(a):
	print(sum(a))
else:
	for i in range(5):
		m = a[i]
		p = a.count(m)
		if p > 1 and p < 4:
			arr.append(sum(a) - p * m)
		elif p >= 4:
			arr.append(sum(a) - 3 * m)
	print(min(arr))


(a, b, c, d, e) = map(int, input().split())
li = [a, b, c, d, e]
li2 = set(li)
l = [sum(li)]
for i in li2:
	if li.count(i) >= 2:
		if li.count(i) >= 3:
			l.append(sum(li) - i * 3)
		else:
			l.append(sum(li) - i * 2)
print(min(l))


b = input()
a = list(map(int, b.split()))
m = 0
for i in range(5):
	if b.count(str(a[i])) > 1:
		if b.count(str(a[i])) <= 3:
			t = a[i] * b.count(str(a[i]))
		else:
			t = a[i] * 3
		if t > m:
			m = t
print(sum(a) - m)


a = list(map(int, input().split()))
b = 0
for i in a:
	if a.count(i) >= 2:
		b = [max(b, 2 * i), max(b, 3 * i)][a.count(i) > 2]
print(sum(a) - b)


l = list(map(int, input().split()))
ll = [0] * 101
summ = sum(l)
ll1 = [summ]
for i in range(5):
	ll[l[i]] += 1
for i in range(100, 0, -1):
	if ll[i] > 1:
		if ll[i] > 2:
			ll1.append(summ - i * 3)
		else:
			ll1.append(summ - i * 2)
print(min(ll1))


n = [int(i) for i in input().split()]
if len(set(n)) == len(n):
	print(sum(n))
else:
	l2 = [n[i] for i in range(len(n)) if 3 > n.count(n[i]) > 1]
	l3 = [n[i] for i in range(len(n)) if n.count(n[i]) > 2]
	if set(l3) != set() and set(l2) == set():
		for i in range(3):
			n.remove(max(set(l3)))
	elif set(l3) == set() and set(l2) != set():
		for i in range(2):
			n.remove(max(set(l2)))
	elif set(l3) != set() and set(l2) != set():
		if sum(l2) > sum(l3):
			for i in range(2):
				n.remove(max(set(l2)))
		else:
			for i in range(3):
				n.remove(max(set(l3)))
	print(sum(n))


t = list(map(int, input().split()))
s = sum(t)
ans = s
for i in range(5):
	c = t.count(t[i])
	if c >= 2:
		ans = min(s - min(c, 3) * t[i], ans)
print(ans)


a = list(map(int, input().split()))
sc = sum(a)
s = sc
m = set(a)
for e in m:
	c = a.count(e)
	if c > 3:
		c = 3
	if c < 2:
		c = 0
	s = min(s, sc - e * c)
print(s)


a = list(map(int, input().split()))
b = [a.count(i) for i in a]
m = 0
for i in range(5):
	if b[i] > 1:
		m = max(m, a[i] * min(b[i], 3))
print(sum(a) - m)


a = 5
a = list(map(int, input().split()))
b = []
for i in a:
	c = a.count(i)
	if c > 1:
		if c > 3:
			c = 3
		b.append(c * i)
if len(b) == 0:
	print(sum(a))
else:
	print(sum(a) - max(b))


from collections import Counter
a = list(map(int, input().split()))
d = Counter(a)
m = 0
for i in a:
	if d[i] > 1:
		m = max(m, i * max(min(d[i], 3), 2))
print(sum(a) - m)


from collections import Counter
nums = list(map(int, input().split()))
nums_sum = sum(nums)
nums_counter = Counter(nums)
best_number = sum(nums)
for num in nums_counter:
	count = nums_counter[num]
	if count == 2:
		best_number = min(best_number, nums_sum - num * 2)
	if count >= 3:
		best_number = min(best_number, nums_sum - num * 3)
print(best_number)


string = input()
lst = string.split()
for index in range(len(lst)):
	lst[index] = int(lst[index])
lst2 = []
for num in lst:
	if num not in lst2:
		lst2.append(num)
if len(lst2) == 1:
	print(lst2[0] * 2)
elif len(lst2) == 2:
	temp = sum(lst)
	three = 0
	for num in lst:
		if lst.count(num) == 3:
			three = num
	two = 0
	for num in lst:
		if lst.count(num) == 2:
			if num > two:
				two = num
	four = 0
	for num in lst:
		if lst.count(num) == 4:
			four = num
	if temp - three * 3 < temp - two * 2:
		print(temp - three * 3)
	elif four != 0:
		print(temp - four * 3)
	else:
		print(temp - two * 2)
elif len(lst2) == 4:
	temp = sum(lst)
	two = 0
	for num in lst:
		if lst.count(num) == 2:
			if num > two:
				two = num
	if two != 0:
		print(sum(lst2) - two)
	else:
		print(sum(lst2))
elif len(lst2) == 5:
	print(sum(lst2))
else:
	temp = sum(lst)
	three = 0
	for num in lst:
		if lst.count(num) == 3:
			three = num
	two = 0
	for num in lst:
		if lst.count(num) == 2:
			if num > two:
				two = num
	if temp - three * 3 < temp - two * 2:
		print(temp - three * 3)
	else:
		print(temp - two * 2)


v = list(map(int, input().split()))
maxi = 0
for i in range(5):
	c = v.count(v[i])
	if c > 3:
		c = 3
	if c >= 2:
		if c * v[i] > maxi:
			maxi = c * v[i]
print(sum(v) - maxi)


from collections import Counter
t = [int(c) for c in input().split()]
_max = 0
for (k, v) in Counter(t).items():
	if v == 2 and k * 2 > _max:
		_max = k * v
	elif v > 2 and k * min(3, v) > _max:
		_max = k * min(3, v)
print(sum(t) - _max)


from collections import Counter

def unique(lst, p_number, p_count):
	count = 0
	seen = set()
	result = []
	for x in lst:
		if count == p_count:
			break
		if p_number in seen:
			count += 1
			continue
		seen.add(x)
		result.append(x)
	return result
numbers = list(map(int, input().split()))
r_one = sum(numbers)
c = Counter(numbers)
d = dict(c)
number = -1
max_numbers = numbers[:]
count = 0
while not count >= 2 and len(max_numbers) != 0:
	ma_x = max(max_numbers)
	number = ma_x
	max_numbers.remove(number)
	count = d[ma_x]
r_two = 501
if count >= 2:
	buff = numbers[:]
	buff.remove(number)
	buff.remove(number)
	r_two = sum(buff)
number = -1
max_numbers = numbers[:]
count = 0
while not count >= 3 and len(max_numbers) != 0:
	ma_x = max(max_numbers)
	number = ma_x
	max_numbers.remove(number)
	count = d[ma_x]
r_three = 501
if count >= 3:
	buff = numbers[:]
	buff.remove(number)
	buff.remove(number)
	buff.remove(number)
	r_three = sum(buff)
print(min(r_one, r_two, r_three))


lst = list(map(int, input().split()))
data = [0] * 101
s = 0
for i in lst:
	data[i] += 1
	s += i
max_change = 0
for i in range(101):
	if data[i] > 2:
		max_change = max(max_change, i * 3)
	elif data[i] > 1:
		max_change = max(max_change, i * 2)
print(s - max_change)


arr = list(map(int, input().split()))
arr.sort()
ans = []
s = sum(arr)
if len(set(arr)) == len(arr):
	ans.append(sum(arr))
else:
	if arr[-1] == arr[-2] == arr[-3]:
		ans.append(arr[0] + arr[1])
	if arr[-4] == arr[-2] == arr[-3]:
		ans.append(arr[0] + arr[4])
	if arr[-3] == arr[-4] == arr[-5]:
		ans.append(arr[3] + arr[4])
	for i in range(5):
		for j in range(i + 1, 5):
			if arr[i] == arr[j]:
				ans.append(s - arr[i] - arr[j])
print(min(ans))


L = [int(k) for k in input().split(' ')]
ma = 600
i = 0
for j in L:
	a = L.count(j)
	if a == 2:
		suma = sum(L) - a * j
		i = 1
		if suma < ma:
			ma = suma
	elif a >= 3:
		suma = sum(L) - 3 * j
		i = 1
		if suma < ma:
			ma = suma
if i == 0:
	print(sum(L))
else:
	print(ma)


numbers = list(map(int, input().split()))
temp = list(set(numbers))
n = len(temp)
maxSum = sum(numbers)
if n == 5:
	print(maxSum)
elif n == 1:
	print(temp[0] * 2)
else:
	counter = []
	summation = []
	for i in range(n):
		m = numbers.count(temp[i])
		if m > 1 and m < 5:
			if m < 3:
				summation.append(maxSum - temp[i] * 2)
			else:
				summation.append(maxSum - temp[i] * 3)
	print(min(summation))


l = list(map(int, input().split()))
l.append(0)
l.sort(reverse=True)
if l[0] == l[2]:
	print(sum(l[3:]))
	exit(0)
elif l[1] == l[3]:
	print(l[0] + l[4])
	exit(0)
elif l[2] == l[4] and l[0] == l[1]:
	print(min(sum(l[:2]), sum(l[2:])))
	exit(0)
elif l[2] == l[4]:
	print(l[0] + l[1])
	exit(0)
else:
	for i in range(4):
		if l[i] == l[i + 1]:
			l.pop(i)
			l.pop(i)
			print(sum(l))
			exit(0)
print(sum(l))


a = []
a = list(map(int, input().split()))
a.sort()
i = 4
s = sum(a)
count = 0
b = []
b.append(0)
while i >= 0:
	k = a.count(a[i])
	if k >= 2:
		if k == 2:
			b.append(a[i] * k)
		else:
			b.append(a[i] * 3)
	i -= 1
sminus = max(b)
s = s - sminus
print(s)


L = input().split(' ')
L = list(map(int, L))
L.sort()
s1 = sum(L)
for i in range(3):
	if L[i] == L[i + 1] and L[i + 1] == L[i + 2] and (sum(L) - L[i] * 3 < s1):
		s1 = sum(L) - L[i] * 3
	elif L[i] == L[i + 1] and sum(L) - L[i] * 2 < s1:
		s1 = sum(L) - L[i] * 2
if L[3] == L[4] and sum(L) - L[3] * 2 < s1:
	s1 = sum(L) - L[3] * 2
print(s1)


a = list(map(int, input().split()))
a = sorted(a)
t = 0
q = 0
p = 0
for j in range(5):
	p += a[j]
for i in range(4, 0, -1):
	if a[i] == a[i - 2]:
		q += 3 * a[i]
		break
for k in range(4, 0, -1):
	if a[k] == a[k - 1]:
		t += 2 * a[k]
		break
print(p - max(t, q))


from collections import Counter
a = list(map(int, input().split()))
b = sum(a)
cnt = Counter(a)
x = b
for i in cnt:
	if cnt[i] >= 3:
		x = min(x, b - i * 3)
	if cnt[i] >= 2:
		x = min(x, b - i * 2)
print(x)


t = list(map(int, input().split()))
s = sum(t)
ans = s
for x in t:
	c = t.count(x)
	if c >= 2:
		ans = min(ans, s - min(c, 3) * x)
print(ans)


num_on_cards = [int(x) for x in input().split()]
discarded = 0
for num in num_on_cards:
	cnt = num_on_cards.count(num)
	if cnt > 1:
		discarded = max(discarded, num * min(cnt, 3))
print(sum(num_on_cards) - discarded)


t = [int(x) for x in input().split(' ')]
t.sort()
c = 0
for i in t:
	if t.count(i) == 1:
		c += 1
if c == 5:
	print(sum(t))
	exit()
c = 0
m = []
for i in t:
	if t.count(i) == 2:
		m.append(2 * i)
	if t.count(i) == 3:
		m.append(3 * i)
	if t.count(i) == 4:
		m.append(3 * i)
	if t.count(i) == 5:
		m.append(3 * i)
print(sum(t) - max(m))


a = list(map(int, input().split()))
b = set(a)
c = []
e = sum(a)
if len(b) == 5:
	print(e)
else:
	for i in b:
		d = a.count(i)
		if d <= 3 and d > 1:
			c.append(e - d * i)
		elif d > 3:
			c.append(e - 3 * i)
	print(min(c))


li = list(map(int, input().split()))
ki = []
for i in range(len(li)):
	k = li.count(li[i])
	if k > 1:
		if k == 2:
			ki.append(sum(li) - li[i] * 2)
		else:
			ki.append(sum(li) - li[i] * 3)
if len(ki) > 0:
	print(min(ki))
else:
	print(sum(li))


t = [int(x) for x in input().split()]
a = [0] * 101
max = 0
for i in t:
	a[i] += 1
for i in t:
	if a[i] >= 3 and i * 3 > max:
		max = i * 3
	elif a[i] == 2 and i * 2 > max:
		max = i * 2
print(sum(t) - max)


l = list(map(int, input().split()))
mn = sum(l)
for i in range(1, 101):
	if l.count(i) >= 2:
		mn = min(mn, sum(l) - i * 2)
	if l.count(i) >= 3:
		mn = min(mn, sum(l) - i * 3)
print(mn)


a = [int(i) for i in input().split()]
s = 0
for i in a:
	s += i
x = 0
for i in range(4):
	t = 1
	f = a[i]
	for j in range(i + 1, 5):
		if a[i] == a[j]:
			t += 1
	if f * min(3, t) > x and t > 1:
		x = f * min(3, t)
print(s - x)


import sys
tn = list(map(int, sys.stdin.readline().split()))
count = [0] * 101
sum = 0
for t in tn:
	count[t] += 1
	sum += t
id = 100
ans = sum
while id > 0:
	if count[id] >= 3 and sum - id * 3 < ans:
		ans = sum - id * 3
	elif count[id] >= 2 and sum - id * 2 < ans:
		ans = sum - id * 2
	id -= 1
print(ans)


x = list(map(int, input().split()))
d = {a: 0 for a in x}
s = 0
for a in x:
	d[a] += 1
	s += a
anw = s
for k in d.keys():
	if d[k] == 2:
		anw = min(anw, s - k * 2)
	elif d[k] > 2:
		anw = min(anw, s - k * 3)
print(anw)


li = list(map(int, input().split()))
r = set(li)
(p, max) = (0, 0)
for i in r:
	if li.count(i) > 1:
		if li.count(i) > 3:
			p = i * 3
		else:
			p = i * li.count(i)
		if p > max:
			max = p
print(sum(li) - max)


a = list(map(int, input().split()))
s = sum(a)
sk = set(a)
mi = []
for i in sk:
	if a.count(i) > 2:
		mi.append(3 * i)
	elif a.count(i) > 1:
		mi.append(2 * i)
if len(mi) > 0:
	print(s - max(mi))
else:
	print(s)


l = list(map(int, input().split()))
z = []
if len(set(l)) == len(l):
	print(sum(l))
else:
	for i in set(l):
		if l.count(i) > 1:
			z.append(i * min(l.count(i), 3))
	print(sum(l) - max(z))


a = list(map(int, input().split()))
a.sort()
sum_min = 0
for i in range(4):
	if a[i] == a[i + 1]:
		sum_min = a[i] * 2
for i in range(3):
	if a[i] == a[i + 1] == a[i + 2] and sum_min < a[i] * 3:
		sum_min = a[i] * 3
sumf = 0
for i in range(5):
	sumf += a[i]
print(sumf - sum_min)


t = list(map(int, input().split()))
tmp = 0
tmp2 = 0
for i in t:
	if t.count(i) == 2:
		if tmp < i * 2:
			tmp = i * 2
	if t.count(i) >= 3:
		if tmp < i * 3:
			tmp = i * 3
print(sum(t) - tmp)


l_n = list(map(int, input().split()))
d_n = {}
m = 0
for n in l_n:
	if n not in d_n:
		d_n[n] = 1
	else:
		d_n[n] += 1
	if d_n[n] >= 2 and d_n[n] <= 3:
		m = max(m, d_n[n] * n)
print(sum(l_n) - m)


from collections import Counter
l = [int(y) for y in input().split()]
s = ans = sum(l)
for (k, v) in Counter(l).items():
	if v >= 2:
		ans = min(ans, s - min(v, 3) * k)
print(ans)


nums = [int(j) for j in input().split()]
ref = 100 * [0]
sum = 0
for j in range(5):
	ref[nums[j] - 1] += 1
	sum += nums[j]
res = sum
for j in range(99, -1, -1):
	if ref[j] > 2:
		res = min(res, sum - (j + 1) * 3)
	elif ref[j] > 1:
		res = min(res, sum - (j + 1) * 2)
print(res)


c = list(map(int, input().split()))
s = sum(c)
a = [0] * 101
for i in range(5):
	a[c[i]] += 1
l = 0
for i in range(100, 0, -1):
	if a[i] > 1:
		l = max(i * min(a[i], 3), l)
print(s - l)


m = 0
list = [0 for i in range(100)]
for x in input().split():
	list[int(x) - 1] = list[int(x) - 1] + 1
	m += int(x)
sum = m
for i in range(100):
	if list[i] > 2:
		m = min(m, sum - 3 * (i + 1))
	elif list[i] == 2:
		m = min(m, sum - 2 * (i + 1))
print(m)


a1 = str(input()).split()
residarr = []
tot = 0
cnt = 0
resid = 0
for ele in a1:
	tot += int(ele)
	cnt = a1.count(ele)
	if cnt >= 2:
		if cnt > 2:
			resid = 3 * int(ele)
		else:
			resid = 2 * int(ele)
	residarr.append(resid)
ans = 0
ans = tot - int(max(residarr))
print(ans)


def main():
	t = list(map(int, input().split()))
	min_ans = t[0] + t[1] + t[2] + t[3] + t[4]
	sm = min_ans
	for i in range(5):
		for j in range(i + 1, 5):
			if t[i] == t[j]:
				min_ans = min(min_ans, sm - t[i] - t[j])
				for k in range(j + 1, 5):
					if t[i] == t[j] == t[k]:
						min_ans = min(min_ans, sm - 3 * t[i])
	print(min_ans)
main()


entrada = input()
entrada = list(map(int, entrada.split()))
total = 0
for a in entrada:
	total += a
repetidos2 = []
repetidos3 = []
novo = []
for a in entrada:
	if a in novo:
		if a in repetidos2:
			repetidos3.append(a)
		else:
			repetidos2.append(a)
	novo.append(a)
maior = total
for rep in repetidos2:
	if total - 2 * rep < maior:
		maior = total - 2 * rep
for rep in repetidos3:
	if total - 3 * rep < maior:
		maior = total - 3 * rep
print(maior)


from collections import defaultdict
l = [int(i) for i in input().split()]
d = defaultdict(int)
for i in l:
	d[i] += 1
if len(d) == 5:
	print(sum(l))
else:
	z = []
	k = list(d.keys())
	v = list(d.values())
	for i in range(len(d)):
		if v[i] == 2:
			z.append(sum(l) - k[i] * 2)
		elif v[i] == 3:
			z.append(sum(l) - k[i] * 3)
		elif v[i] > 3:
			z.append(sum(l) - k[i] * 3)
	print(min(z))


from collections import defaultdict
X = list(map(int, input().split()))
MyDict = defaultdict(int)
for i in X:
	MyDict[i] += 1
MAX = 0
for i in MyDict.keys():
	if MyDict[i] == 2 and i * 2 > MAX:
		MAX = i * 2
	elif MyDict[i] >= 3 and i * 3 > MAX:
		MAX = i * 3
print(sum(X) - MAX)


import sys, math
z = list(map(int, input().split()))
s = sum(z)
min_ = s
for i in range(len(z)):
	f = z.count(z[i])
	if f >= 3:
		min_ = min(min_, s - 3 * z[i])
	elif f == 2:
		min_ = min(min_, s - 2 * z[i])
print(min_)


import sys
import math
import bisect
import itertools
import random

def main():
	A = list(map(int, input().split()))
	d = dict()
	for a in A:
		if a not in d:
			d[a] = 0
		d[a] += 1
	min_val = sum(A)
	for a in d:
		if d[a] >= 2:
			val = sum(A) - a * 2
			min_val = min(min_val, val)
		if d[a] >= 3:
			val = sum(A) - a * 3
			min_val = min(min_val, val)
	print(min_val)
main()


l = []
l.extend(map(int, input().split()))
l.sort()
high = []
x = 0
resL = []
for i in range(len(l)):
	res = sum(l)
	count1 = l.count(l[i])
	if count1 == 2 or count1 == 3:
		x = res - count1 * l[i]
		resL.append(x)
	elif count1 > 3:
		x = res - 2 * l[i]
		y = res - 3 * l[i]
		print(min(x, y))
		break
else:
	if len(resL) > 1:
		print(min(resL))
	else:
		print(res)


t = list(map(int, input().split()))
ans = 0
for i in t:
	k = t.count(i)
	if k >= 2:
		ans = max(ans, min(k, 3) * i)
print(sum(t) - ans)


def sum(a):
	s = 0
	for i in a:
		s = s + i
	return s
a = list(map(int, input().split()))
a.sort()
b = list(set(a))
b.sort()
i = 0
d = []
c = []
x = sum(a)
if len(a) == len(b):
	print(x)
else:
	while len(a) != 0:
		if a[0] == b[0]:
			c.append(a[0])
			del a[0]
			if len(c) > 3:
				del c[len(c) - 1]
				d.append(c)
				c = []
			if len(a) == 0:
				if len(c) < 4 and len(c) > 1:
					d.append(c)
		else:
			if len(c) <= 3 and len(c) > 1:
				d.append(c)
			del b[0]
			c = []
	z = []
	for i in range(len(d)):
		z.append(x - sum(d[i]))
	print(min(z))


(a, b, c, d, e) = sorted([int(i) for i in input().split()])
max = 0
if (d == e) & (c == d):
	if c * 3 > max:
		max = c * 3
if (d == b) & (c == d):
	if c * 3 > max:
		max = c * 3
if (a == b) & (c == a):
	if c * 3 > max:
		max = c * 3
if a == b:
	if b * 2 > max:
		max = b * 2
if c == b:
	if b * 2 > max:
		max = c * 2
if c == d:
	if d * 2 > max:
		max = d * 2
if d == e:
	if e * 2 > max:
		max = e * 2
print(a + b + c + d + e - max)


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 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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 pf(s):
	return print(s, flush=True)

def main():
	a = LI()
	c = collections.Counter(a)
	s = r = sum(a)
	for (k, v) in c.items():
		if v > 1:
			t = s - k * min(v, 3)
			if r > t:
				r = t
	return r
print(main())


lst = input().split(' ')
lst = [int(x) for x in lst]
max_sum = 0
max_num = 0
for num in lst:
	tot = 0
	count = 0
	for l in lst:
		if l == num and count < 3:
			tot += l
			count += 1
	if tot > max_sum and count > 1:
		max_sum = tot
		max_num = num
tot = 0
for i in lst:
	tot += i
tot = tot - max_sum
print(tot)


def main():
	(*l,) = map(int, input().split())
	res = [0]
	for x in l:
		if l.count(x) > 1:
			res.append(min(l.count(x), 3) * x)
	print(sum(l) - max(res))
main()


a = list(map(int, input().split()))
x = []
for i in a:
	if a.count(i) >= 2 and i not in x:
		x.append(i)
f = 0
z = 0
for i in x:
	if i * a.count(i) > z:
		z = i * a.count(i)
		f = i
for i in range(3):
	if f in a:
		a.remove(f)
print(sum(a))


l = list(map(int, input().split()))
z = []
s = sum(l)
l = list(reversed(sorted(l)))
for i in l:
	z.append(l.count(i))
m = 0
mm = 0
for i in range(5):
	if z[i] == 1:
		pass
	if z[i] == 2:
		if 2 * l[i] > m:
			m = 2 * l[i]
	if z[i] >= 3:
		mm = 3 * l[i]
if m == mm == 0:
	print(s)
elif m < mm:
	print(s - mm)
else:
	print(s - m)


t = sorted(list(map(int, input().split())))
b = []
for i in range(5):
	if t.count(t[i]) > 1:
		if t.count(t[i]) > 3:
			b.append(t[i] * 3)
		else:
			b.append(t[i] * t.count(t[i]))
if len(b) == 0:
	print(sum(t))
else:
	print(sum(t) - max(b))


a = list(map(int, input().split()))
d = {}
s = 0
for i in a:
	s += i
	if i not in d.keys():
		d[i] = 1
	else:
		d[i] += 1
possible = []
for i in d.keys():
	if d[i] == 2:
		possible.append(2 * i)
	elif d[i] == 3:
		possible.append(3 * i)
	elif d[i] > 3:
		possible.append(3 * i)
if possible != []:
	print(s - max(possible))
else:
	print(s)


a = list(map(int, input().split()))
(ans, temp) = (sum(a), 0)
b = sorted(set(a), reverse=True)
for i in b:
	if a.count(i) >= 3:
		temp = max(temp, 3 * i)
	elif a.count(i) == 2:
		temp = max(temp, 2 * i)
print(ans - temp)


def main():
	a = list(map(int, input().split()))
	if len(a) == len(set(a)):
		print(sum(a))
	else:
		s = sum(a)
		b = list()
		c = set(a)
		for i in c:
			if a.count(i) >= 3:
				b.append(s - i * 3)
			elif a.count(i) == 2:
				b.append(s - i * 2)
		print(min(b))
main()


a = list(map(int, input().split()))
b = [0, 0, 0, 0, 0]
for i in range(5):
	b[i] = a.count(a[i])
mini = sum(a)
for i in range(5):
	if a.count(a[i]) == 2 or a.count(a[i]) == 3:
		mini = min(mini, sum(a) - b[i] * a[i])
	if a.count(a[i]) == 4 or a.count(a[i]) == 5:
		mini = min(mini, sum(a) - 3 * a[i])
print(mini)


a = list(map(int, input().split()))
b2 = [0] * 101
b3 = [0] * 101
for x in a:
	b2[x] += 1
	b3[x] += 1
for i in range(100, 0, -1):
	if b3[i] >= 3:
		b3[i] -= 3
		break
for i in range(100, 0, -1):
	if b2[i] >= 2:
		b2[i] -= 2
		break
print(min(sum((i * x for (i, x) in enumerate(b2))), sum((i * x for (i, x) in enumerate(b3)))))


s = [int(i) for i in input().split()]
sum = 0
kol = [1, 1, 1, 1]
for i in s:
	sum += i
sim = 0
for i in s[1:]:
	if i == s[0]:
		kol[0] += 1
for i in s[2:]:
	if i == s[1]:
		kol[1] += 1
for i in s[3:]:
	if i == s[2]:
		kol[2] += 1
if s[3] == s[4]:
	kol[3] += 1
for i in range(4):
	if kol[i] > 1:
		if kol[i] == 2:
			if sim < s[i] * 2:
				sim = s[i] * 2
		elif sim < s[i] * 3:
			sim = s[i] * 3
sum -= sim
print(sum)


from collections import Counter
a = Counter(map(int, input().split()))
s = sum((b * c for (b, c) in a.items()))
res = s
for (b, c) in a.items():
	if c >= 2:
		res = min(res, s - 2 * b)
	if c >= 3:
		res = min(res, s - 3 * b)
print(res)


_ = list(map(int, input().split()))
__ = list(set(_))
_____ = []
if _.count(__[0]) == len(_):
	print(sum(_) - __[0] * 3)
else:
	for ___ in range(len(__)):
		if _.count(__[___]) > 1:
			tmp = _.copy()
			______ = 0
			for ____ in range(_.count(__[___])):
				______ += 1
				if ______ == 4:
					break
				tmp.remove(__[___])
			_____.append(sum(tmp))
	print(min(_____) if len(_____) > 0 else sum(_))


def main_function():
	cards = [int(i) for i in input().split(' ')]
	sums = sum(cards)
	dict = {}
	for i in cards:
		if not i in dict:
			dict[i] = 1
		else:
			dict[i] += 1
	max = 0
	for i in dict:
		if dict[i] == 2 and i * 2 > max:
			max = i * 2
		if dict[i] >= 3 and i * 3 > max:
			max = i * 3
	return sums - max
print(main_function())


l = list(map(int, input().split()))
try:
	r = max((x * min(3, l.count(x)) for x in l if l.count(x) >= 2))
	print(sum(l) - r)
except:
	print(sum(l))


cards = [int(x) for x in input().split()]
cardset = sorted(set(cards))[::-1]
cardcount = [cards.count(x) for x in cardset]
(total, maxv) = (0, 0)
for i in range(len(cardset)):
	total += cardset[i] * cardcount[i]
	if cardcount[i] > 1:
		atual = cardset[i] * (2 if cardcount[i] == 2 else 3)
		if maxv < atual:
			maxv = atual
print(total - maxv)


p = list(map(int, input().split()))
t = list(set(p))
s = sum(p)
plo = []
if len(p) == len(set(p)):
	print(sum(p))
else:
	for item in t:
		if p.count(item) == 1:
			pass
		elif p.count(item) < 3:
			plo.append(s - item * 2)
		else:
			plo.append(s - item * 3)
	print(min(plo))


t = sorted(list(map(int, input().split())))
sumka = sum(t)
sum3 = 0
for i in range(1, 4):
	if t[i - 1] == t[i] == t[i + 1]:
		sum3 = t[i - 1] + t[i] + t[i + 1]
		del t[i - 1]
		del t[i - 1]
		del t[i - 1]
		break
sum2 = 0
if sum3 != 0:
	if t[0] == t[1]:
		sum2 = t[0] + t[1]
else:
	sum2 = 0
	for i in range(4):
		if t[i] == t[i + 1]:
			sm = t[i] + t[i + 1]
			if sm > sum2:
				sum2 = sm
out = 0
if sum2 < sum3:
	out = sumka - sum3
elif sum2 > sum3:
	out = sumka - sum2
elif sum2 == 0 and sum3 == 0:
	out = sumka
elif sum2 == sum3:
	out = sumka - sum2
print(out)


l = list(map(int, input().split()))
k = [[i, l.count(i)] for i in set(l) if l.count(i) >= 2]
for i in range(len(k)):
	if k[i][1] > 3:
		k[i][1] = 3
	k[i] = k[i][0] * k[i][1]
k.append(0)
print(sum(l) - max(k))


t = list(map(int, input().split()))
r = list(set(t))
if len(r) == len(t):
	print(sum(t))
else:
	E = 999
	for i in range(len(r)):
		p = sum(t) - r[i] * int(t.count(r[i]) > 1) * min(3, t.count(r[i]))
		E = min(E, p)
	print(E)


arr = list(map(int, input().split()))
counts = dict()
mx = -1
for i in arr:
	if i in counts:
		counts[i] += 1
	else:
		counts[i] = 1
for (k, v) in counts.items():
	if v >= 2:
		mx = max(mx, k * min(v, 3))
if mx != -1:
	print(sum(arr) - mx)
else:
	print(sum(arr))


s = [int(i) for i in input().split()]
s.sort()
r = s.copy()
d = [0]
for i in range(len(s) - 2):
	if s[i] == s[i + 1] == s[i + 2]:
		d.append(3 * s[i])
		r[i] = r[i + 1] = r[i + 2] = 0
for i in range(len(s) - 1):
	if r[i] == r[i + 1] and r[i] != 0:
		d.append(2 * r[i])
print(sum(s) - max(d))


from collections import Counter
from math import inf

def solve(t):
	c = Counter(t)
	mini = sum(t)
	for (i, v) in c.items():
		if v > 2:
			mini = min(mini, sum(t) - 3 * i)
		elif v > 1:
			mini = min(mini, sum(t) - 2 * i)
	return mini

def main():
	t = list(map(int, input().split()))
	print(solve(t))
main()


l = input().split()
s = 0
for i in range(5):
	l[i] = int(l[i])
	s += l[i]
l.sort()
f = []
i = 4
cn = 1
while i > 0:
	if l[i] == l[i - 1] and i != 1:
		cn += 1
	elif l[i] == l[i - 1] and i == 1:
		cn += 1
		if cn > 2:
			f.append([3, s - 3 * l[i]])
		else:
			f.append([cn, s - cn * l[i]])
	else:
		if cn > 2:
			f.append([3, s - 3 * l[i]])
		else:
			f.append([cn, s - cn * l[i]])
		cn = 1
	i -= 1
mi = s
s = len(f)
for i in range(s):
	if f[i][0] > 1 and f[i][1] < mi:
		mi = f[i][1]
print(mi)


t = list(map(int, input().split()))
d = dict()
for i in t:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
ans = 0
for (k, v) in d.items():
	if v >= 2:
		ans = max(ans, min(v, 3) * k)
print(sum(t) - ans)


from collections import Counter
arr = list(map(int, input().split()))
freq = Counter(arr)
mx = 0
for (key, val) in freq.items():
	if val > 1:
		mx = max(key * min(3, val), mx)
print(sum(arr) - mx)


d = {}
l = list(map(int, input().split()))
s = sum(l)
for i in l:
	d[i] = d.get(i, 0) + 1
ans = s
for i in d:
	if 2 <= d[i]:
		ans = min(ans, s - i * min(3, d[i]))
print(ans)


n = list(map(int, input().split()))
n.sort(reverse=True)
st = set()
MIN = 0
for i in range(len(n)):
	if n.count(n[i]) >= 3:
		MIN = sum(n) - 3 * n[i]
		st.add(MIN)
	elif n.count(n[i]) >= 2:
		MIN = sum(n) - 2 * n[i]
		st.add(MIN)
	else:
		continue
else:
	MIN = sum(n)
	st.add(MIN)
print(min(st))


l = list(map(int, input().split()))
c = list(filter(lambda x: l.count(x) > 1, l))
c = list(set(c))
f = []
if c != []:
	d = max(c)
	if l.count(d) > 2:
		f = f + [sum(l) - 3 * d]
	elif l.count(d) == 2:
		f = f + [sum(l) - 2 * d]
	r = [l.count(i) for i in c]
	e = r.index(max(r))
	if max(r) > 2:
		f = f + [sum(l) - 3 * c[e]]
	elif max(r) == 2:
		f = f + [sum(l) - 2 * c[e]]
	print(min(f))
else:
	print(sum(l))


l = list(map(int, input().split()))
(a, b, x, y) = (0, 0, 0, 0)
for i in range(5):
	if l.count(l[i]) >= 3:
		(x, y) = (3, max(l[i], y))
	elif l.count(l[i]) == 2:
		(a, b) = (2, max(l[i], b))
if y != 0 or b != 0:
	if y * 3 > b * 2:
		print(sum(l) - y * 3)
	else:
		print(sum(l) - b * 2)
else:
	print(sum(l))


a = list(map(int, input().split()))
b = set(a)
z = {}
q = 0
for i in a:
	if a.count(i) > 1:
		z[i] = a.count(i)
for i in z:
	if z[i] > 2:
		if i * 3 > q:
			q = i * 3
	elif i * 2 > q:
		q = i * 2
print(sum(a) - q)


a = list(map(int, input().split()))
a.sort(reverse=True)
sum = 0
cum = 0
flag = 0
b = []
for i in a:
	sum += i
for i in a:
	if a.count(i) >= 2:
		cum = min(a.count(i), 3) * i
		b.append(cum)
		flag = 1
if flag == 1:
	print(sum - max(b))
else:
	print(sum)


__author__ = 'Utena'
from collections import defaultdict
s = list(map(int, input().split()))
m = defaultdict(int)
m1 = defaultdict(int)
for a in s:
	m[a] += 1
for a in s:
	if m[a] > 1:
		m1[a] = min(m[a], 3) * a
	else:
		m1[a] = 0
print(sum(s) - max(m1.values()))


t = list(map(int, input().split()))
mapp = [0] * 101
for i in t:
	if mapp[i] < 3:
		mapp[i] += 1
remove = 0
for i in range(100, 0, -1):
	if mapp[i] > 1 and remove < mapp[i] * i:
		remove = mapp[i] * i
print(sum(t) - remove)


a = list(map(int, input().split()))
b = list(set(a))
ans = []
for i in b:
	ans.append(sum(a) - (a.count(i) if a.count(i) >= 2 and a.count(i) <= 3 else 3 if a.count(i) > 3 else 0) * i)
print(min(ans))


l = list(map(int, input().split()))
if len(set(l)) == len(l):
	print(sum(l))
else:
	l1 = list(set(l))
	l1.sort()
	m = 0
	for i in l:
		if l.count(i) >= 2:
			m1 = i * min(3, l.count(i))
			if m1 > m:
				m = m1
	print(sum(l) - m)


arr = list(map(int, input().split()))
a = sum(arr)
if len(set(arr)) == len(arr):
	print(a)
else:
	m = 0
	for n in set(arr):
		q = min(3, arr.count(n))
		if q > 1:
			m = max(m, n * q)
	print(a - m)


l = list(map(int, input().split()))
s = set(l)
y = [0]
for i in s:
	x = l.count(i)
	if x == 1:
		continue
	else:
		y.append(min(3, x) * i)
print(sum(l) - max(y))


import sys
arr = sorted(list(map(int, input().split())), reverse=True)
res = sum(arr)
r = 0
for num in arr:
	cnt = arr.count(num)
	if cnt >= 2 and cnt <= 3:
		r = max(num * cnt, r)
	elif cnt > 3:
		r = num * 3
print(res - r)


hand = list(map(int, input().split(' ')))

def card_remove(hand):
	hand.sort()
	max = 0
	for i in range(0, 4):
		if hand[i] == hand[i + 1]:
			if hand[i] * 2 > max:
				max = hand[i] * 2
	for i in range(0, 3):
		if hand[i] == hand[i + 1] == hand[i + 2]:
			if hand[i] * 3 > max:
				max = hand[i] * 3
	print(sum(hand) - max)
card_remove(hand)


t = list(map(int, input().split()))
digits = set(t)
minsum = sum(t)
if len(digits) == len(t):
	print(minsum)
else:
	for i in digits:
		q = t.copy()
		if q.count(i) == 2:
			q.remove(i)
			q.remove(i)
			if sum(q) < minsum:
				minsum = sum(q)
		elif q.count(i) >= 3:
			q.remove(i)
			q.remove(i)
			q.remove(i)
			if sum(q) < minsum:
				minsum = sum(q)
	print(minsum)


arr = [int(x) for x in input().split()]
s = sum(arr)
ans = s
for x in arr:
	c = 0
	for y in arr:
		if x == y:
			c += 1
	if c == 2:
		ans = min(ans, s - x * min(c, 2))
	elif c > 2:
		ans = min(ans, s - x * min(c, 3))
print(ans)


inp = list(map(int, input().split()))
z = set(inp)
table = []
tot = sum(inp)
table.append(tot)
for i in z:
	if inp.count(i) >= 3:
		table.append(tot - i * 3)
	elif inp.count(i) >= 2:
		table.append(tot - i * 2)
print(min(table))


t = list(map(int, input().split()))
triples = [s for s in t if t.count(s) >= 3]
doubles = [s for s in t if t.count(s) == 2]
triples.sort()
doubles.sort()
m = 0
if triples:
	m = 3 * triples[-1]
if doubles:
	m = max(m, 2 * doubles[-1])
print(sum(t) - m)


ip = list(map(int, input().split()))
ans = sum(ip)
s = []
for i in ip:
	if ip.count(i) >= 2:
		s.append(min(3, ip.count(i)) * i)
try:
	print(ans - max(s))
except:
	print(ans)


x = list(map(int, input().split()))
b = []
b.append(sum(x))
a = set(x)
a = list(a)
for i in a:
	ans = 0
	if x.count(i) == 3 or x.count(i) == 2:
		for j in x:
			if j != i:
				ans += j
	elif x.count(i) == 4:
		ans += i
		for j in x:
			if j != i:
				ans += j
	elif x.count(i) == 5:
		ans = i * 2
	if ans != 0:
		b.append(ans)
print(min(b))


list_of_cards = list(map(int, input().split(' ')))
cards = {}
for card in set(list_of_cards):
	if list_of_cards.count(card) > 1:
		times = list_of_cards.count(card) if list_of_cards.count(card) <= 3 else 3
		cards[card] = times * card
if cards:
	print(sum(list_of_cards) - max(cards.values()))
else:
	print(sum(list_of_cards))


string = input()
list1 = string.split(' ', 5)
numbers = []
numbers2 = []
total = 0
for i in range(0, len(list1)):
	numbers.append(int(list1[i]))
total = sum(numbers)
repeatedList = []
for j in numbers:
	if j in repeatedList:
		continue
	elif numbers.count(j) > 1:
		repeatedList.append(j)
if len(repeatedList) == 0:
	print(total)
else:
	sumList = [total] * len(repeatedList)
	countList = []
	for element in repeatedList:
		if numbers.count(element) > 3:
			countList.append(3)
		else:
			countList.append(numbers.count(element))
	newList = []
	for ii in range(len(repeatedList)):
		summ = sumList[ii] - countList[ii] * repeatedList[ii]
		newList.append(summ)
	minimum = min(newList)
	print(minimum)


from sys import stdin as Si, maxsize as m
from math import floor as F
from collections import defaultdict as dt, Counter as Co
from operator import itemgetter as ig
from math import pi
L = tuple(map(int, Si.readline().split()))
(H, Max) = (Co(L), 0)
for (k, v) in H.items():
	if v > 1:
		Max = max(Max, k * min(v, 3))
print(sum(L) - Max)


class CountDict(dict):

	def __missing__(self, key):
		return 0
cards = [int(i) for i in input().split(' ')]
counts = CountDict()
for l in cards:
	counts[l] += 1
total_sum = sum([d * counts[d] for d in counts.keys()])
sub_amounts = [0]
for (digit, count) in counts.items():
	if count > 1:
		max_mult = min(3, count)
		sub_amounts.append(digit * max_mult)
print(total_sum - max(sub_amounts))


m = list(map(int, input().split()))
m.sort(reverse=True)
count = 1
now = m[0]
sums = [0]
for i in range(1, 5):
	if m[i] == now:
		count += 1
	else:
		if count == 2:
			sums.append(2 * now)
		elif count > 2:
			sums.append(3 * now)
		now = m[i]
		count = 1
if count == 2:
	sums.append(2 * now)
elif count > 2:
	sums.append(3 * now)
ans = sum(m) - max(sums)
print(ans)


L = sorted([int(x) for x in input().split()])
if len(set(L)) == len(L):
	print(sum(L))
else:
	S = set()
	A = []
	for i in range(5):
		if L.count(L[i]) > 1:
			S = S.union({L[i]})
	for i in S:
		if L.count(i) == 2:
			A.append(2 * i)
		else:
			A.append(3 * i)
	print(sum(L) - max(A))


import functools
import operator
lul = input().split()
lul1 = [int(i) for i in lul]
lul2 = [int(i) for i in lul]
lul1.sort(reverse=True)
lul2.sort()
lent1 = lul1.__len__()
r1 = 0
for i in range(lent1):
	if i < lent1 - 1 and lul1[i] == lul1[i + 1]:
		if i < lent1 - 2 and lul1[i + 1] == lul1[i + 2]:
			r1 += lul1[i + 2]
			lul1.remove(lul1[i + 2])
		r1 += lul1[i + 1]
		lul1.remove(lul1[i + 1])
		r1 += lul1[i]
		lul1.remove(lul1[i])
		break
lent2 = lul.__len__()
r2 = 0
for i in range(lent2):
	if i < lent2 - 1 and lul2[i] == lul2[i + 1]:
		if i < lent2 - 2 and lul2[i + 1] == lul2[i + 2]:
			r2 += lul2[i + 2]
			lul2.remove(lul2[i + 2])
		r2 += lul2[i + 1]
		lul2.remove(lul2[i + 1])
		r2 += lul2[i]
		lul2.remove(lul2[i])
		break
r1 = functools.reduce(operator.add, lul1)
r2 = functools.reduce(operator.add, lul2)
print(min(r1, r2))


t = list(map(int, input().split()))
tot = 0
for i in range(1, 6):
	tot += t[i - 1]
t.sort()
ans = tot
for i in range(0, 5):
	if i + 2 < 5 and t[i + 2] == t[i]:
		ans = min(ans, tot - 3 * t[i])
	elif i + 1 < 5 and t[i + 1] == t[i]:
		ans = min(ans, tot - 2 * t[i])
print(ans)


from collections import defaultdict
l = list(map(int, input().split()))
d = defaultdict(int)
t = sum(l)
for li in l:
	d[li] += 1
s3 = s2 = None
for k in d:
	if d[k] >= 3:
		s3 = 3 * k
	elif d[k] == 2:
		s2 = 2 * k if s2 == None or s2 < 2 * k else s2
if s2 != None and s3 != None:
	t -= s2 if s2 > s3 else s3
elif s2 != None:
	t -= s2
elif s3 != None:
	t -= s3
print(t)


l = [int(e) for e in input().split()]
lst = []
for e in l:
	if l.count(e) != 1:
		lst.append(sum(l) - e * min(3, l.count(e)))
if lst != []:
	print(min(lst))
else:
	print(sum(l))


l = list(map(int, input().split()))
a = list(set(l))
if len(a) == 1:
	print(2 * a[0])
else:
	(r, z) = ([], [])
	for x in range(len(a)):
		if 1 < l.count(a[x]) < 4:
			r.append(a[x] * l.count(a[x]))
		else:
			z.append(a[x])
	if len(r) == 0 or len(r) == 1:
		print(sum(z))
	else:
		print(sum(z) + min(r))


from collections import Counter
data = list(map(int, input().split()))
data1 = Counter()
ans = []
for i in data:
	data1[i] += 1
for i in data1:
	if data1[i] >= 2:
		ans.append([i, data1[i]])
max1 = 0
for i in ans:
	max1 = max(i[0] * min(i[1], 3), max1)
print(sum(data) - max1)


cards = list(map(int, input().split()))
c = 0
for i in cards:
	if cards.count(i) >= 2 and i * cards.count(i) > c:
		if cards.count(i) > 3:
			c = i * 3
		else:
			c = i * cards.count(i)
print(sum(cards) - c)


L = list(map(int, input().split()))
L.sort()
P = [sum(L)]
c = 1
for i in range(1, 5):
	if L[i] == L[i - 1]:
		c += 1
	if c == 3 or L[i] != L[i - 1]:
		if c > 1:
			P = P + [P[0] - c * L[i - 1]]
		c = 1
if c > 1:
	P += [P[0] - c * L[4]]
print(min(P))


def solve(arr):
	d = {}
	for i in arr:
		if d.get(i):
			d[i] += 1
		else:
			d[i] = 1
	max_val = 0
	for i in d:
		if d[i] > 1:
			count = d[i] if d[i] <= 3 else 3
			if count * int(i) > max_val:
				max_val = count * int(i)
	return sum(arr) - max_val

def main():
	arr = list(map(int, input().split(' ')))
	print(solve(arr))
main()


l = list(map(int, input().split()))
l.sort()
sm1 = 0
sm2 = 0
x = sum(l)
for i in l:
	if l.count(i) >= 3:
		sm1 = 3 * i
	if l.count(i) == 2:
		sm2 = 2 * i
print(x - max(sm1, sm2))


l = list(map(int, input().split()))
c = 0
for i in l:
	if l.count(i) == 2:
		c = max(i * 2, c)
	elif l.count(i) > 2:
		c = max(i * 3, c)
print(sum(l) - c)


n = list(map(int, input().split()))
n.sort(reverse=True)
sum_all = 0
for i in n:
	sum_all += i
min_sum = sum_all
for i in range(len(n) - 1):
	if n[i] == n[i + 1]:
		s = sum_all - n[i] * 2
		if i + 2 < 5 and n[i] == n[i + 2]:
			s -= n[i]
		if s < min_sum:
			min_sum = s
print(min_sum)


s = input().split(' ')
s = map(int, s)
s = sorted(s)
t = list(set(s))
freq = [0] * len(t)
soma = [0] * len(t)
somaTotal = sum(s)
if len(t) == 5:
	print(sum(s))
else:
	for i in range(len(s)):
		for j in range(len(t)):
			if s[i] == t[j]:
				freq[j] += 1
				soma[j] += s[i]
	minimo = somaTotal
	for i in range(len(t)):
		if freq[i] == 3 or freq[i] == 2:
			minimo = min(minimo, somaTotal - soma[i])
		elif freq[i] > 3:
			minimo = min(minimo, somaTotal - 3 * t[i])
	print(minimo)


def findDuplicate(cards):
	duplicates = []
	for i in range(len(cards)):
		card = cards[i]
		counter = 0
		for j in range(len(cards)):
			next_card = cards[j]
			if counter < 2 and i != j and (card == next_card):
				counter += 1
		if counter >= 1:
			check = True
			for dupli in duplicates:
				if dupli[0] == card:
					check = False
			if check:
				duplicates.append([card, counter + 1])
	return duplicates

def main():
	cards = input()
	cards = cards.split()
	somatorio = 0
	for card in cards:
		somatorio += int(card)
	duplicates = findDuplicate(cards)
	min_somatorio = somatorio
	for dupla in duplicates:
		if somatorio - int(dupla[1]) * int(dupla[0]) < min_somatorio:
			min_somatorio = somatorio - int(dupla[1]) * int(dupla[0])
	print(min_somatorio)
main()


def main():
	cards = list(map(int, input().split()))
	s = sum(cards)
	unique_cards = set(cards)
	max_cut = 0
	for card in unique_cards:
		count = cards.count(card)
		if count == 1:
			count = 0
		elif count > 3:
			count = 3
		max_cut = max(max_cut, card * count)
	print(s - max_cut)
main()


arr = [int(i) for i in input().split()]
s = sum(arr)
l = [sum(arr)]
for i in arr:
	if arr.count(i) == 2:
		l.append(s - 2 * i)
	elif arr.count(i) >= 3:
		l.append(s - 3 * i)
print(min(l))


a = input().split()
s = 0
for i in range(5):
	a[i] = int(a[i])
	s = s + a[i]
maxx = 0
for i in range(5):
	for t in range(4):
		for r in range(3):
			if i != t and i != r and (t != r):
				if a[i] == a[t] and a[i] == a[r]:
					if maxx < 3 * a[i]:
						maxx = 3 * a[i]
				elif a[i] == a[t]:
					if maxx < 2 * a[i]:
						maxx = 2 * a[i]
				elif a[i] == a[r]:
					if maxx < 2 * a[i]:
						maxx = 2 * a[i]
				elif a[r] == a[t]:
					if maxx < 2 * a[r]:
						maxx = 2 * a[r]
print(s - maxx)


t = list(map(int, input().split()))
t.sort()
res = sum(t)
if t[2] == t[4] or t[2] == t[0] or (t[1] == t[2] == t[3] and t[2] > 0):
	res = min(res, sum(t) - t[2] * 3)
for i in range(4):
	if t[i] == t[i + 1]:
		res = min(res, sum(t) - t[i] * 2)
print(res)


t = list(map(int, input().split(' ')))
t.sort()
s = set(t)
summ = sum(t)
a = []
a2 = []
c = 0
if len(s) == 1:
	print(2 * t[0])
elif len(s) == 2:
	if t[1] == t[2] and t[2] == t[3]:
		print(summ - 3 * t[1])
	else:
		print(summ - max(3 * t[2], 2 * t[0], 2 * t[4]))
elif len(s) == 3:
	for j in range(0, 4):
		if t[j] == t[j + 1]:
			a2.append(t[j])
			c += 1
		else:
			a.append(c)
			c = 0
	if max(a) == 2:
		summ -= 3 * t[2]
	else:
		summ -= 2 * max(a2)
	print(summ)
elif len(s) == 4:
	for j in range(0, 4):
		if t[j] == t[j + 1]:
			summ -= 2 * t[j]
	print(summ)
else:
	print(summ)


lst = [int(i) for i in input().split()]
sum1 = sum(lst)
min1 = sum1
for i in lst:
	nd = 0
	for j in lst:
		if i == j:
			nd += 1
	if nd > 3:
		nd = 3
	c = sum1 - i * nd
	if c < min1 and nd > 1:
		min1 = c
print(min1)


s = input()
A = []
for i in s.split():
	A.append(int(i))
A.sort(reverse=True)
B = []
a = 0
count = 1
for j in range(0, 4):
	if A[j + 1] == A[j]:
		count = count + 1
		if count == 3:
			a = A[j]
			B.append(A[j])
			break
	elif A[j + 1] != A[j]:
		if count == 2:
			B.append(A[j])
		count = 1
if j == 3 and count == 2:
	B.append(A[j])
if a == 0 and len(B) > 0:
	print(sum(A) - B[0] * 2)
elif a != 0 and len(B) > 0:
	if B[0] * 2 > B[-1] * 3:
		print(sum(A) - B[0] * 2)
	else:
		print(sum(A) - B[-1] * 3)
else:
	print(sum(A))


a = [int(i) for i in input().split()]
b = set(a)
ans = sum(a)
cs = 0
count = 0
for i in b:
	for j in a:
		if i == j:
			count += 1
	if count > 1:
		count = min(4, count + 1)
	for j in a:
		if j == i:
			if count == 1:
				cs += j
			else:
				count -= 1
		else:
			cs += j
	ans = min(ans, cs)
	cs = 0
	count = 0
print(ans)


def arr_inp():
	return [int(x) for x in input().split()]
a = arr_inp()
a.sort()
(ix, out) = (0, sum(a))
while ix < 5:
	a_copy = a.copy()
	c = a.count(a[ix])
	if c >= 2:
		for i in range(min(3, c)):
			a_copy.remove(a[ix])
		out = min(out, sum(a_copy))
	ix += c
print(out)


x = list(map(int, input().split()))
t = [-1] * len(x)
(j, y) = (0, 0)
c = True
for i in range(len(x)):
	if x.count(x[i]) == 2 or x.count(x[i]) == 3:
		t[j] = x.count(x[i]) * x[i]
		j += 1
		c = False
	elif x.count(x[i]) > 3:
		t[j] = x[i] * 3
		j += 1
		c = False
for k in range(len(x)):
	y += x[k]
if c == True:
	print(y)
else:
	r = max(t)
	print(y - r)


import math
data = input()
c = []
repeated = []
sum_values = []

def get_repeated():
	for i in range(4):
		for j in range(i + 1, 5):
			if c[i] == c[j]:
				repeated.append(c[i])
				break

def check(num):
	for k in range(len(repeated)):
		if num == repeated[k]:
			return True
	return False

def calculate():
	for i in range(5):
		summ = 0
		counter = 0
		if check(c[i]):
			for j in range(5):
				if c[j] != c[i]:
					summ += c[j]
				else:
					counter += 1
					if counter > 3:
						summ += c[j]
		else:
			for j in range(5):
				summ += c[j]
		sum_values.append(summ)

def min():
	min = sum_values[0]
	for i in range(1, 5):
		if sum_values[i] < min:
			min = sum_values[i]
	return min
for i in range(4):
	c.append(int(data[:data.find(' ')]))
	data = data[data.find(' ') + 1:]
c.append(int(data))
get_repeated()
calculate()
print(min())


N = list(map(int, input().split()))
Ans = sum(N)
for n in N:
	c = N.count(n)
	if c > 1:
		Ans = min(Ans, sum(N) - min(c, 3) * n)
print(Ans)


l = list(map(int, input().split()))
ans = t = sum(l)
for i in range(5):
	for j in range(i + 1, 5):
		if l[i] == l[j] and t - l[i] - l[j] < ans:
			ans = t - l[i] - l[j]
for i in range(5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			if l[i] == l[j] == l[k] and t - l[i] - l[j] - l[k] < ans:
				ans = t - l[i] - l[j] - l[k]
print(ans)


t = input().split()
(total, diff) = (0, 0)
for i in t:
	total += int(i)
	p = t.count(i)
	if p >= 3:
		if 3 * int(i) > diff:
			diff = 3 * int(i)
	elif p == 2:
		if 2 * int(i) > diff:
			diff = 2 * int(i)
print(total - diff)


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
a = L()
suma = sum(a)
cnt = Counter(a)
ans = suma
for i in cnt:
	if cnt[i] >= 2:
		ans = min(ans, suma - 2 * i)
	if cnt[i] >= 3:
		ans = min(ans, suma - 3 * i)
print(ans)


l = [int(x) for x in input().split()]
l.sort()
i = 4
m = 0
s = 0
while i > -1:
	if l.count(l[i]) == 2:
		if i - 1 >= 0:
			s = l[i] + l[i - 1]
		i = i - 1
		if s > m:
			m = s
	elif l.count(l[i]) > 2:
		if i - 2 >= 0:
			s = l[i] + l[i - 1] + l[i - 2]
		i = i - 2
		if s > m:
			m = s
	i = i - 1
print(sum(l) - m)


line = str(input()).split()
line = [int(it) for it in line]
line.sort()
rest = dict()
for i in range(5):
	rest[line[i]] = rest.setdefault(line[i], 0) + 1
candidate = [0]
for (k, v) in rest.items():
	v = min(3, v)
	if v > 1:
		candidate.append(k * v)
print(sum(line) - max(candidate))


import sys
t = list(map(int, sys.stdin.readline().split()))
d = dict()
for i in range(5):
	if t[i] in d:
		d[t[i]] += 1
	else:
		d[t[i]] = 1
s = sum(t)
ans = s
for k in d:
	if d[k] > 1:
		ans = min(ans, s - k * min(3, d[k]))
print(ans)


t = list(map(int, input().split()))
ans = 0
for i in t:
	c = t.count(i)
	if c == 1:
		continue
	ans = max(ans, min(3, c) * i)
print(sum(t) - ans)


from sys import stdin, stdout
arr = list(map(int, stdin.readline().split()))
sl = len(set(arr))
s = sum(arr)
arr.sort()
if len(arr) == sl:
	ans = s
elif sl == 1:
	ans = arr[0] + arr[1]
else:
	map = {}
	for i in arr:
		try:
			map[i] += 1
		except:
			map[i] = 1
	arr = list(set(arr))
	for i in arr:
		if map[i] < 2:
			map[i] = 0
		elif map[i] > 3:
			map[i] = 3
	if sl == 3:
		ans = s - max(map[arr[0]] * arr[0], map[arr[1]] * arr[1], map[arr[2]] * arr[2])
	elif sl == 2:
		ans = s - max(map[arr[0]] * arr[0], map[arr[1]] * arr[1])
	else:
		ans = s - max(map[arr[0]] * arr[0], map[arr[1]] * arr[1], map[arr[2]] * arr[2], map[arr[3]] * arr[3])
stdout.write(str(ans) + '\n')


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	l = li()
	s = 0
	d = {}
	for i in l:
		d[i] = d.get(i, 0) + 1
		s += i
	x = [s]
	for i in d:
		if d[i] >= 3:
			x.append(s - 3 * i)
		elif d[i] >= 2:
			x.append(s - 2 * i)
	print(min(x))
for _ in range(1):
	solve()


a = [int(i) for i in input().split()]
c = [0] * 101
ss = 0
for i in a:
	c[i] += 1
	ss += i
m = 0
for i in range(101):
	if c[i] > 1 and i * min(c[i], 3) > m:
		m = i * min(c[i], 3)
print(ss - m)


nums = list(map(int, input().split()))
totalSum = sum(nums)
ans = totalSum
if len(nums) != len(set(nums)):
	for x in nums:
		if nums.count(x) > 1 and nums.count(x) < 4 and (ans > totalSum - x * nums.count(x)):
			ans = totalSum - x * nums.count(x)
		if nums.count(x) >= 4 and ans > totalSum - x * 3:
			ans = totalSum - x * 3
print(ans)


from collections import Counter
cards = [int(x) for x in input().split(' ')]
card_counter = Counter(cards)
discardable_cards_saving = {k: k * min(v, 3) for (k, v) in card_counter.items() if v > 1}
(saving, card_to_discard) = max(((v, k) for (k, v) in discardable_cards_saving.items()), default=(0, None))
print(sum(cards) - saving)


def count(a, x):
	ans = 0
	for y in a:
		if x == y:
			ans += 1
	return ans
a = list(map(int, input().split()))
s = sum(a)
ans = s
for x in a:
	v = count(a, x)
	if 2 <= v:
		ans = min(ans, s - min(v, 3) * x)
print(ans)


l = list(map(int, input().split()))
s = set(l)
b = []
for i in s:
	c = l.count(i)
	if c == 1:
		continue
	else:
		b.append(min(c, 3) * i)
if len(b) == 0:
	print(sum(l))
else:
	print(sum(l) - max(b))


import sys
t = sys.stdin.readline().split()
t = [int(x) for x in t]
t.sort()
ans = sum(t)
for el in t:
	c = t.count(el)
	if c > 1:
		if c > 3:
			c = 3
		tmpAns = sum(t) - el * c
		if tmpAns < ans:
			ans = tmpAns
print(ans)


(a, b, c, d, e) = sorted(list(map(int, input().split())))
z = a + b + c + d + e
(p, q, r, s, t, u, v) = (0, 0, 0, 0, 0, 0, 0)
if a == b:
	p = a + b
if b == c:
	q = b + c
if c == d:
	r = c + d
if d == e:
	s = d + e
if a == b == c:
	t = a + b + c
if b == c == d:
	u = b + c + d
if c == d == e:
	v = c + d + e
print(z - max([p, q, r, s, t, u, v]))


arr = list(map(int, input().split(' ')))
li = {}
for i in list(set(arr)):
	if arr.count(i) >= 2:
		li[i] = arr.count(i)
x = sum(arr)
res = x
for i in li:
	y = li.get(i)
	if y > 3:
		y = 3
	if x - i * y < res:
		res = x - i * y
print(res)


l = list(map(int, input().split()))
s = sum(l)
a = list(set(l))
c = []
for i in a:
	x = l.count(i)
	if x >= 3:
		c.append(3 * i)
	elif x >= 2:
		c.append(2 * i)
	else:
		c.append(0)
print(s - max(c))


T = list(map(int, input().split()))
pairs = [0] + [t for t in set(T) if T.count(t) > 1]
triplets = [0] + [t for t in set(T) if T.count(t) > 2]
print(sum(T) - max(2 * max(pairs), 3 * max(triplets)))


t = list(map(int, input().split()))
t.sort(reverse=True)
print(sum(t) - max(t[4] + t[3] if t[4] == t[3] else 0, t[3] + t[2] if t[3] == t[2] else 0, t[2] + t[1] if t[2] == t[1] else 0, t[1] + t[0] if t[1] == t[0] else 0, t[4] + t[3] + t[2] if t[4] == t[3] == t[2] else 0, t[3] + t[2] + t[1] if t[3] == t[2] == t[1] else 0, t[2] + t[1] + t[0] if t[2] == t[1] == t[0] else 0))


import sys
input = sys.stdin.readline
c = list(map(int, input().split()))
r = 0
for i in set(c):
	if c.count(i) >= 3:
		r = max(r, 3 * i)
	elif c.count(i) == 2:
		r = max(r, 2 * i)
print(sum(c) - r)


def cnt(s, v):
	ans = 0
	for i in s:
		if i == v:
			ans += 1
	if ans < 2:
		return 0
	if ans > 3:
		return 3
	return ans
s = [int(z) for z in input().split()]
mx = 0
for i in range(1000):
	mx = max(mx, cnt(s, i) * i)
print(sum(s) - mx)


a = list(map(int, input().split()))
a.sort()
now = sum(a)
n = 5
dif = 0
for i in range(1, n):
	if a[i] == a[i - 1]:
		if i - 2 >= 0:
			if a[i - 2] == a[i - 1]:
				dif = max(dif, a[i] + a[i - 1] + a[i - 2])
			else:
				dif = max(dif, a[i] + a[i - 1])
		else:
			dif = max(dif, a[i] + a[i - 1])
print(now - dif)


cards = input().split()
cards = [int(x) for x in cards]
numeros = []
contador = []
total = 0
for i in cards:
	total += i
	if i in numeros:
		contador[numeros.index(i)] += 1
	else:
		numeros.append(i)
		contador.append(1)
maximo = 0
for i in range(len(numeros)):
	if contador[i] > 3:
		contador[i] = 3
	if contador[i] > 1 and numeros[i] * contador[i] > maximo:
		maximo = numeros[i] * contador[i]
print(total - maximo)


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	A = read_ints()
	A.sort()
	G = Counter(A)
	d1 = sum(A)
	for i in reversed(range(len(A))):
		if G[A[i]] >= 2:
			d1 -= A[i] * 2
			break
	d2 = sum(A)
	for i in reversed(range(len(A))):
		if G[A[i]] >= 3:
			d2 -= A[i] * 3
			break
	print(min(d1, d2))

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

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

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

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

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


numbers = list(map(int, input().split()))
total = sum(numbers)
best = total
for i in range(101):
	n_of_value = 0
	for n in numbers:
		if n == i:
			n_of_value += 1
	if n_of_value >= 2:
		sub = i * min(n_of_value, 3)
		current = total - sub
		best = min(best, current)
print(best)


nums = list((int(x) for x in input().split()))
total = sum(nums)
a = [0 for i in range(101)]
for x in nums:
	a[x] += 1
maxremove = 0
index = 100
while index >= 0:
	if a[index] >= 3:
		remove = 3 * index
		if remove > maxremove:
			maxremove = remove
	elif a[index] == 2:
		remove = 2 * index
		if remove > maxremove:
			maxremove = remove
	index -= 1
print(total - maxremove)


l = list(map(int, input().split()))
maxx = 0
for i in set(l):
	if l.count(i) >= 2:
		maxx = max(min(3, l.count(i)) * i, maxx)
print(sum(l) - maxx)


a = list(map(int, input().split()))
a.sort()
ma = 0
s = sum(a)
for i in range(3):
	if a[i] == a[i + 1] and a[i] == a[i + 2]:
		ma = max(ma, a[i] * 3)
	if a[i] == a[i + 1]:
		ma = max(ma, a[i] * 2)
if a[3] == a[4]:
	ma = max(ma, a[3] * 2)
print(s - ma)


import time
t = [int(i) for i in input().split()]
start = time.time()
s = sum(t)
d = {}
for i in t:
	if i in d.keys():
		d[i] += 1
	else:
		d[i] = 1
ans = s
for i in d.keys():
	if d[i] == 1:
		continue
	elif d[i] == 2:
		m = 2 * i
	else:
		m = 3 * i
	if s - m < ans:
		ans = s - m
print(ans)


c = input().split(' ')
c = [int(i) for i in c]
s = sum(c)
mx = 0
for i in c:
	cc = c.count(i)
	if cc > 3:
		cc = 3
	if cc > 1:
		if mx < i * cc:
			mx = i * cc
print(s - mx)


cards = list(map(int, input().split()))
result = sum(cards)
for i in range(5):
	cnt = cards.count(cards[i])
	cnt = min(cnt, 3)
	if cnt not in [2, 3]:
		continue
	result = min(result, sum(cards) - cnt * cards[i])
print(result)


l = list(map(int, input().split()))
s = list(set(l))
d = {}
sum = 0
for i in s:
	if l.count(i) > 1:
		d[i] = l.count(i)
for i in l:
	sum += i
c = [sum]
for i in d:
	if d[i] >= 3:
		c.append(sum - i * 3)
	elif d[i] == 2:
		c.append(sum - i * 2)
print(min(c))


t = list(map(int, input().split()))
best = sum(t)
for x in t:
	if t.count(x) == 1:
		continue
	best = min(best, sum(t) - x * min(3, t.count(x)))
print(best)


l = list(map(int, input().split()))
s = sum(l)
x = set([(l.count(i), i) for i in l])
x = list(x)
m = 10000000000
if len(x) == 1:
	print(x[0][1] * 2)
elif len(x) == len(l):
	print(sum(l))
else:
	for (i, j) in x:
		if i <= 3 and i > 1:
			s = s - j * i
			m = min(m, s)
			s = sum(l)
		elif i > 3:
			s = s - j * 3
			m = min(m, s)
			s = sum(l)
	print(m)


t = list(map(int, input().split()))
if set(t) == t:
	print(sum(t))
else:
	sum = sum(t)
	minsum = sum
	for i in set(t):
		if t.count(i) == 1:
			continue
		tmp = sum
		if t.count(i) == 2:
			tmp -= i * 2
		else:
			tmp -= i * 3
		if tmp < minsum:
			minsum = tmp
	print(minsum)


a = list(map(int, input().split()))
b = [0] * 150
ma = 0
for i in range(5):
	b[a[i]] += 1
	if b[a[i]] > 1:
		if b[a[i]] * a[i] > ma and b[a[i]] < 4:
			ma = b[a[i]] * a[i]
print(sum(a) - ma)


hand = list(map(int, input().split()))
kinds = []
numbs = []
for o in hand:
	flag = True
	for a in range(0, len(kinds)):
		if kinds[a] == o:
			numbs[a] += 1
			flag = False
	if flag:
		kinds.append(o)
		numbs.append(1)
flag = False
maks = 0
res = 0
for o in range(0, len(numbs)):
	if numbs[o] >= 2 and kinds[o] * numbs[o] > maks:
		maks = kinds[o] * min(numbs[o], 3)
		pret = o
		flag = True
	res += kinds[o] * numbs[o]
print(res - maks)


a = list(map(int, input().split()))
a.sort()
arr = []
arr.append(a[0] + a[1] + a[2] + a[3] + a[4])
if a[2] == a[3] == a[4]:
	arr.append(a[0] + a[1])
if a[1] == a[2] == a[3]:
	arr.append(a[0] + a[4])
if a[0] == a[1] == a[2]:
	arr.append(a[3] + a[4])
if a[0] == a[1]:
	arr.append(a[2] + a[3] + a[4])
if a[1] == a[2]:
	arr.append(a[0] + a[3] + a[4])
if a[2] == a[3]:
	arr.append(a[0] + a[1] + a[4])
if a[3] == a[4]:
	arr.append(a[0] + a[1] + a[2])
print(min(arr))


cards = input().split()
cards = sorted([int(x) for x in cards], reverse=True)
biggest = []
most_repeated = []
tokens = 1
counter = 1
current = 0
big_count = 0
try:
	for z in cards:
		if z == cards[counter] == cards[counter + 1]:
			most_repeated.append(z)
			most_repeated.append(cards[counter])
			most_repeated.append(cards[counter + 1])
			break
		else:
			counter += 1
except IndexError:
	pass
counter = 1
try:
	for y in cards:
		if y == cards[counter]:
			current = y
			break
		else:
			counter += 1
except IndexError:
	pass
counter = 1
for num in cards:
	if num == current:
		big_count += 1
if big_count <= 2:
	for m in range(0, big_count):
		biggest.append(current)
elif big_count >= 3:
	for m in range(0, 3):
		biggest.append(current)
solution = min(sum(cards) - sum(biggest), sum(cards) - sum(most_repeated))
print(solution)


A = [int(i) for i in input().split()]
a = sum(A)
A.sort()
d = {}
for i in A:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
ans = a
for k in d:
	if d[k] >= 2:
		ans = min(ans, a - min(d[k], 3) * k)
print(ans)


li = list(map(int, input().split()))
li.sort()
s = sum(li)
x = s
for i in range(5):
	if i <= 3 and li[i] == li[i + 1]:
		x = min(x, s - (li[i] + li[i + 1]))
	if i <= 2 and li[i] == li[i + 1] == li[i + 2]:
		x = min(x, s - (li[i] + li[i + 1] + li[i + 2]))
print(x)