#include <iostream>
#include <vector>
using namespace std;

int main() {
	vector<int> MENU;
	int min = 0;
	int m = 5;
	for (int i = 0; i < m; i++) {
		cin >> MENU[i];
	}

	for (int i = 0; i < m; i++) {

		if (min < (min + MENU[i]) % 10) {
			min += MENU[i];
			MENU.erase(MENU.begin() + i);
			m -= 1
		}
	}

	cout << min << endl;
	return 0;
}