#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
	int ans = 0;
	int abcde[5];
	int junban[5];
	map<int,int> one;

	for (int i = 0; i < 5; i++)
		cin >> abcde[i];

	for (int i = 0; i < 5; i++)
		one[abcde[i] % 10] = i;

	for (int i = 0; i < 5; i++)
	{
		if (i % 2 == 0)
		{
			junban[i] = one.rbegin()->first;
			one.erase(one.rbegin()->first);
		}
		else
		{
			junban[i] = one.begin()->first;
			one.erase(one.abegin()->first);
		}

		
	}

	for (int i = 0; i < 5; i++)
		ans += abcde[junban[i]];

	cout << ans;

	return 0;
}