www.acmicpc.net/problem/2484
# 주사위 네개
# https://www.acmicpc.net/problem/2484 (구현)
def reward():
# 3 3 3 3 => [(3, 4)]
# 3 3 6 3 => [(3, 3), (6, 1)]
# 2 2 6 6 => [(2, 2), (6, 2)]
# 2 2 6 4 => [(2, 2), (6, 1), (4, 1)]
# 2 3 4 5 => [(5, 1), (4, 1), (3, 1), (2, 1)]
a = sorted(list(map(int, input().split())))
d = dict()
for x in a:
if x in d:
d[x] += 1
else:
d[x] = 1
d = sorted(d.items(), key=lambda x: (x[1], x[0]), reverse=True)
if d[0][1] == 4:
return 50000 + d[0][0] * 5000
elif d[0][1] == 3:
return 10000 + d[0][0] * 1000
elif d[0][1] == 2 and d[1][1] == 2:
return 2000 + d[0][0] * 500 + d[1][0] * 500
elif d[0][1] == 2:
return 1000 + d[0][0] * 100
else:
return d[0][0] * 100
n = int(input())
max_money = max(reward() for _ in range(n))
print(max_money)