import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 所要時間のリスト
		int[] times = new int[5];
		input(times);

		// 0〜4の順列を生成
		List<int[]> sequences = sequence(new int[] { 0, 1, 2, 3, 4 });
//		sequences.stream().map(e -> Arrays.toString(e)).forEach(System.out::println);

		int minTime = Integer.MAX_VALUE;
		int[] order = new int[5];
		for (int[] seq : sequences) {
			for (int i = 0; i < order.length; i++) {
				order[i] = times[seq[i]];
			}
			int time = calcTime(order, minTime);
			minTime = (time < minTime) ? time : minTime;
//			System.out.printf("%s => %d\n", Arrays.toString(order), time);
		}
		System.out.println(minTime);
	}

	/**
	 * 配列で与えられた要素の順列を返す
	 * 
	 * @param members
	 * @return
	 */
	private static List<int[]> sequence(int[] members) {
		List<int[]> sequences = new ArrayList<>();
		sequence0(members, new int[members.length], 0, sequences);
		return sequences;
	}

	private static void sequence0(int[] members, int[] array, int digit, List<int[]> seq) {
		for (int m : members) {
			array[digit] = m;
			if (digit == array.length - 1) {
				seq.add(Arrays.copyOf(array, array.length));
			} else {
				sequence0(subArray(m, members), array, digit + 1, seq);
			}
		}
	}

	// memnbers の要素から m を除いた配列を返す
	private static int[] subArray(int m, int[] members) {
		int[] ret = new int[members.length - 1];
		for (int i = 0, j = 0; i < members.length; i++) {
			if (members[i] != m) {
				ret[j++] = members[i];
			}
		}
		return ret;
	}

	private static void input(int[] times) {
		try (Scanner scan = new Scanner(System.in)) {
			for (int i = 0; i < 5; i++) {
				times[i] = scan.nextInt();
			}
		}
	}

	// order は注文する料理の所要時間配列
	private static int calcTime(int[] order, int maxTime) {
		int t = 0;
		for (int i = 0; i < order.length; i++) {
			t += order[i]; // 完成時刻
			if ((i != order.length - 1) && (t % 10 != 0)) {
				t += (10 - (t % 10));
			}
			// 最大時間を越えたらそれ以上計算しない
			if(t >= maxTime) {
				return t;
			}
		}
		return t;
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		// 所要時間のリスト
		int[] times = new int[5];
		input(times);

		// 0〜4の順列を生成
		List<int[]> sequences = sequence(new int[] { 0, 1, 2, 3, 4 });
//		sequences.stream().map(e -> Arrays.toString(e)).forEach(System.out::println);

		int minTime = Integer.MAX_VALUE;
		int[] order = new int[5];
		for (int[] seq : sequences) {
			for (int i = 0; i < order.length; i++) {
				order[i] = times[seq[i]];
			}
			int time = calcTime(order, minTime);
			minTime = (time < minTime) ? time : minTime;
//			System.out.printf("%s => %d\n", Arrays.toString(order), time);
		}
		System.out.println(minTime);
	}

	/**
	 * 配列で与えられた要素の順列を返す
	 * 
	 * @param members
	 * @return
	 */
	private static List<int[]> sequence(int[] members) {
		List<int[]> sequences = new ArrayList<>();
		sequence0(members, new int[members.length], 0, sequences);
		return sequences;
	}

	private static void sequence0(int[] members, int[] array, int digit, List<int[]> seq) {
		for (int m : members) {
			array[digit] = m;
			if (digit == array.length - 1) {
				seq.add(Arrays.copyOf(array, array.length));
			} else {
				sequence0(subArray(m, members), array, digit + 1, seq);
			}
		}
	}

	// memnbers の要素から m を除いた配列を返す
	private static int[] subArray(int m, int[] members) {
		int[] ret = new int[members.length - 1];
		for (int i = 0, j = 0; i < members.length; i++) {
			if (members[i] != m) {
				ret[j++] = members[i];
			}
		}
		return ret;
	}

	private static void input(int[] times) {
		try (Scanner scan = new Scanner(System.in)) {
			for (int i = 0; i < 5; i++) {
				times[i] = scan.nextInt();
			}
		}
	}

	// order は注文する料理の所要時間配列
	private static int calcTime(int[] order, int maxTime) {
		int t = 0;
		for (int i = 0; i < order.length; i++) {
			t += order[i]; // 完成時刻
			if ((i != order.length - 1) && (t % 10 != 0)) {
				t += (10 - (t % 10));
			}
			// 最大時間を越えたらそれ以上計算しない
			if(t >= maxTime) {
				return t;
			}
		}
		return t;
	}
} Main public static void main(String[] args) {
		// 所要時間のリスト
		int[] times = new int[5];
		input(times);

		// 0〜4の順列を生成
		List<int[]> sequences = sequence(new int[] { 0, 1, 2, 3, 4 });
//		sequences.stream().map(e -> Arrays.toString(e)).forEach(System.out::println);

		int minTime = Integer.MAX_VALUE;
		int[] order = new int[5];
		for (int[] seq : sequences) {
			for (int i = 0; i < order.length; i++) {
				order[i] = times[seq[i]];
			}
			int time = calcTime(order, minTime);
			minTime = (time < minTime) ? time : minTime;
//			System.out.printf("%s => %d\n", Arrays.toString(order), time);
		}
		System.out.println(minTime);
	} main {
		// 所要時間のリスト
		int[] times = new int[5];
		input(times);

		// 0〜4の順列を生成
		List<int[]> sequences = sequence(new int[] { 0, 1, 2, 3, 4 });
//		sequences.stream().map(e -> Arrays.toString(e)).forEach(System.out::println);

		int minTime = Integer.MAX_VALUE;
		int[] order = new int[5];
		for (int[] seq : sequences) {
			for (int i = 0; i < order.length; i++) {
				order[i] = times[seq[i]];
			}
			int time = calcTime(order, minTime);
			minTime = (time < minTime) ? time : minTime;
//			System.out.printf("%s => %d\n", Arrays.toString(order), time);
		}
		System.out.println(minTime);
	} int[] times = new int[5]; times new int[5] 5 input(times) input times List<int[]> sequences = sequence(new int[] { 0, 1, 2, 3, 4 }); sequences sequence(new int[] { 0, 1, 2, 3, 4 }) sequence new int[] { 0, 1, 2, 3, 4 } int minTime = Integer.MAX_VALUE; minTime Integer.MAX_VALUE Integer Integer.MAX_VALUE int[] order = new int[5]; order new int[5] 5 for (int[] seq : sequences) {
			for (int i = 0; i < order.length; i++) {
				order[i] = times[seq[i]];
			}
			int time = calcTime(order, minTime);
			minTime = (time < minTime) ? time : minTime;
//			System.out.printf("%s => %d\n", Arrays.toString(order), time);
		} int[] seq sequences {
			for (int i = 0; i < order.length; i++) {
				order[i] = times[seq[i]];
			}
			int time = calcTime(order, minTime);
			minTime = (time < minTime) ? time : minTime;
//			System.out.printf("%s => %d\n", Arrays.toString(order), time);
		} {
			for (int i = 0; i < order.length; i++) {
				order[i] = times[seq[i]];
			}
			int time = calcTime(order, minTime);
			minTime = (time < minTime) ? time : minTime;
//			System.out.printf("%s => %d\n", Arrays.toString(order), time);
		} for (int i = 0; i < order.length; i++) {
				order[i] = times[seq[i]];
			} int i = 0; int i = 0; i 0 i < order.length i order.length order order.length i++ i++ i {
				order[i] = times[seq[i]];
			} {
				order[i] = times[seq[i]];
			} order[i] = times[seq[i]] order[i] order i times[seq[i]] times seq[i] seq i int time = calcTime(order, minTime); time calcTime(order, minTime) calcTime order minTime minTime = (time < minTime) ? time : minTime minTime (time < minTime) ? time : minTime (time < minTime) time minTime time minTime System.out.println(minTime) System.out.println System.out System System.out minTime String[] args args /**
	 * 配列で与えられた要素の順列を返す
	 * 
	 * @param members
	 * @return
	 */
	private static List<int[]> sequence(int[] members) {
		List<int[]> sequences = new ArrayList<>();
		sequence0(members, new int[members.length], 0, sequences);
		return sequences;
	} sequence {
		List<int[]> sequences = new ArrayList<>();
		sequence0(members, new int[members.length], 0, sequences);
		return sequences;
	} List<int[]> sequences = new ArrayList<>(); sequences new ArrayList<>() sequence0(members, new int[members.length], 0, sequences) sequence0 members new int[members.length] members.length members members.length 0 sequences return sequences; sequences int[] members members private static void sequence0(int[] members, int[] array, int digit, List<int[]> seq) {
		for (int m : members) {
			array[digit] = m;
			if (digit == array.length - 1) {
				seq.add(Arrays.copyOf(array, array.length));
			} else {
				sequence0(subArray(m, members), array, digit + 1, seq);
			}
		}
	} sequence0 {
		for (int m : members) {
			array[digit] = m;
			if (digit == array.length - 1) {
				seq.add(Arrays.copyOf(array, array.length));
			} else {
				sequence0(subArray(m, members), array, digit + 1, seq);
			}
		}
	} for (int m : members) {
			array[digit] = m;
			if (digit == array.length - 1) {
				seq.add(Arrays.copyOf(array, array.length));
			} else {
				sequence0(subArray(m, members), array, digit + 1, seq);
			}
		} int m members {
			array[digit] = m;
			if (digit == array.length - 1) {
				seq.add(Arrays.copyOf(array, array.length));
			} else {
				sequence0(subArray(m, members), array, digit + 1, seq);
			}
		} {
			array[digit] = m;
			if (digit == array.length - 1) {
				seq.add(Arrays.copyOf(array, array.length));
			} else {
				sequence0(subArray(m, members), array, digit + 1, seq);
			}
		} array[digit] = m array[digit] array digit m if (digit == array.length - 1) {
				seq.add(Arrays.copyOf(array, array.length));
			} else {
				sequence0(subArray(m, members), array, digit + 1, seq);
			} digit == array.length - 1 digit array.length - 1 array.length array array.length 1 {
				seq.add(Arrays.copyOf(array, array.length));
			} seq.add(Arrays.copyOf(array, array.length)) seq.add seq Arrays.copyOf(array, array.length) Arrays.copyOf Arrays array array.length array array.length {
				sequence0(subArray(m, members), array, digit + 1, seq);
			} sequence0(subArray(m, members), array, digit + 1, seq) sequence0 subArray(m, members) subArray m members array digit + 1 digit 1 seq int[] members members int[] array array int digit digit List<int[]> seq seq // memnbers の要素から m を除いた配列を返す
	private static int[] subArray(int m, int[] members) {
		int[] ret = new int[members.length - 1];
		for (int i = 0, j = 0; i < members.length; i++) {
			if (members[i] != m) {
				ret[j++] = members[i];
			}
		}
		return ret;
	} subArray {
		int[] ret = new int[members.length - 1];
		for (int i = 0, j = 0; i < members.length; i++) {
			if (members[i] != m) {
				ret[j++] = members[i];
			}
		}
		return ret;
	} int[] ret = new int[members.length - 1]; ret new int[members.length - 1] members.length - 1 members.length members members.length 1 for (int i = 0, j = 0; i < members.length; i++) {
			if (members[i] != m) {
				ret[j++] = members[i];
			}
		} int i = 0, j = 0; int i = 0 i 0 j = 0; j 0 i < members.length i members.length members members.length i++ i++ i {
			if (members[i] != m) {
				ret[j++] = members[i];
			}
		} {
			if (members[i] != m) {
				ret[j++] = members[i];
			}
		} if (members[i] != m) {
				ret[j++] = members[i];
			} members[i] != m members[i] members i m {
				ret[j++] = members[i];
			} ret[j++] = members[i] ret[j++] ret j++ j members[i] members i return ret; ret int m m int[] members members private static void input(int[] times) {
		try (Scanner scan = new Scanner(System.in)) {
			for (int i = 0; i < 5; i++) {
				times[i] = scan.nextInt();
			}
		}
	} input {
		try (Scanner scan = new Scanner(System.in)) {
			for (int i = 0; i < 5; i++) {
				times[i] = scan.nextInt();
			}
		}
	} try (Scanner scan = new Scanner(System.in)) {
			for (int i = 0; i < 5; i++) {
				times[i] = scan.nextInt();
			}
		} {
			for (int i = 0; i < 5; i++) {
				times[i] = scan.nextInt();
			}
		} Scanner scan = new Scanner(System.in) Scanner scan = new Scanner(System.in) new Scanner(System.in) for (int i = 0; i < 5; i++) {
				times[i] = scan.nextInt();
			} int i = 0; int i = 0; i 0 i < 5 i 5 i++ i++ i {
				times[i] = scan.nextInt();
			} {
				times[i] = scan.nextInt();
			} times[i] = scan.nextInt() times[i] times i scan.nextInt() scan.nextInt scan int[] times times // order は注文する料理の所要時間配列
	private static int calcTime(int[] order, int maxTime) {
		int t = 0;
		for (int i = 0; i < order.length; i++) {
			t += order[i]; // 完成時刻
			if ((i != order.length - 1) && (t % 10 != 0)) {
				t += (10 - (t % 10));
			}
			// 最大時間を越えたらそれ以上計算しない
			if(t >= maxTime) {
				return t;
			}
		}
		return t;
	} calcTime {
		int t = 0;
		for (int i = 0; i < order.length; i++) {
			t += order[i]; // 完成時刻
			if ((i != order.length - 1) && (t % 10 != 0)) {
				t += (10 - (t % 10));
			}
			// 最大時間を越えたらそれ以上計算しない
			if(t >= maxTime) {
				return t;
			}
		}
		return t;
	} int t = 0; t 0 for (int i = 0; i < order.length; i++) {
			t += order[i]; // 完成時刻
			if ((i != order.length - 1) && (t % 10 != 0)) {
				t += (10 - (t % 10));
			}
			// 最大時間を越えたらそれ以上計算しない
			if(t >= maxTime) {
				return t;
			}
		} int i = 0; int i = 0; i 0 i < order.length i order.length order order.length i++ i++ i {
			t += order[i]; // 完成時刻
			if ((i != order.length - 1) && (t % 10 != 0)) {
				t += (10 - (t % 10));
			}
			// 最大時間を越えたらそれ以上計算しない
			if(t >= maxTime) {
				return t;
			}
		} {
			t += order[i]; // 完成時刻
			if ((i != order.length - 1) && (t % 10 != 0)) {
				t += (10 - (t % 10));
			}
			// 最大時間を越えたらそれ以上計算しない
			if(t >= maxTime) {
				return t;
			}
		} t += order[i] t order[i] order i if ((i != order.length - 1) && (t % 10 != 0)) {
				t += (10 - (t % 10));
			} (i != order.length - 1) && (t % 10 != 0) (i != order.length - 1) i order.length - 1 order.length order order.length 1 (t % 10 != 0) t % 10 t 10 0 {
				t += (10 - (t % 10));
			} t += (10 - (t % 10)) t (10 - (t % 10)) 10 (t % 10) t 10 if(t >= maxTime) {
				return t;
			} t >= maxTime t maxTime {
				return t;
			} return t; t return t; t int[] order order int maxTime maxTime public class Main {
	public static void main(String[] args) {
		// 所要時間のリスト
		int[] times = new int[5];
		input(times);

		// 0〜4の順列を生成
		List<int[]> sequences = sequence(new int[] { 0, 1, 2, 3, 4 });
//		sequences.stream().map(e -> Arrays.toString(e)).forEach(System.out::println);

		int minTime = Integer.MAX_VALUE;
		int[] order = new int[5];
		for (int[] seq : sequences) {
			for (int i = 0; i < order.length; i++) {
				order[i] = times[seq[i]];
			}
			int time = calcTime(order, minTime);
			minTime = (time < minTime) ? time : minTime;
//			System.out.printf("%s => %d\n", Arrays.toString(order), time);
		}
		System.out.println(minTime);
	}

	/**
	 * 配列で与えられた要素の順列を返す
	 * 
	 * @param members
	 * @return
	 */
	private static List<int[]> sequence(int[] members) {
		List<int[]> sequences = new ArrayList<>();
		sequence0(members, new int[members.length], 0, sequences);
		return sequences;
	}

	private static void sequence0(int[] members, int[] array, int digit, List<int[]> seq) {
		for (int m : members) {
			array[digit] = m;
			if (digit == array.length - 1) {
				seq.add(Arrays.copyOf(array, array.length));
			} else {
				sequence0(subArray(m, members), array, digit + 1, seq);
			}
		}
	}

	// memnbers の要素から m を除いた配列を返す
	private static int[] subArray(int m, int[] members) {
		int[] ret = new int[members.length - 1];
		for (int i = 0, j = 0; i < members.length; i++) {
			if (members[i] != m) {
				ret[j++] = members[i];
			}
		}
		return ret;
	}

	private static void input(int[] times) {
		try (Scanner scan = new Scanner(System.in)) {
			for (int i = 0; i < 5; i++) {
				times[i] = scan.nextInt();
			}
		}
	}

	// order は注文する料理の所要時間配列
	private static int calcTime(int[] order, int maxTime) {
		int t = 0;
		for (int i = 0; i < order.length; i++) {
			t += order[i]; // 完成時刻
			if ((i != order.length - 1) && (t % 10 != 0)) {
				t += (10 - (t % 10));
			}
			// 最大時間を越えたらそれ以上計算しない
			if(t >= maxTime) {
				return t;
			}
		}
		return t;
	}
} public class Main {
	public static void main(String[] args) {
		// 所要時間のリスト
		int[] times = new int[5];
		input(times);

		// 0〜4の順列を生成
		List<int[]> sequences = sequence(new int[] { 0, 1, 2, 3, 4 });
//		sequences.stream().map(e -> Arrays.toString(e)).forEach(System.out::println);

		int minTime = Integer.MAX_VALUE;
		int[] order = new int[5];
		for (int[] seq : sequences) {
			for (int i = 0; i < order.length; i++) {
				order[i] = times[seq[i]];
			}
			int time = calcTime(order, minTime);
			minTime = (time < minTime) ? time : minTime;
//			System.out.printf("%s => %d\n", Arrays.toString(order), time);
		}
		System.out.println(minTime);
	}

	/**
	 * 配列で与えられた要素の順列を返す
	 * 
	 * @param members
	 * @return
	 */
	private static List<int[]> sequence(int[] members) {
		List<int[]> sequences = new ArrayList<>();
		sequence0(members, new int[members.length], 0, sequences);
		return sequences;
	}

	private static void sequence0(int[] members, int[] array, int digit, List<int[]> seq) {
		for (int m : members) {
			array[digit] = m;
			if (digit == array.length - 1) {
				seq.add(Arrays.copyOf(array, array.length));
			} else {
				sequence0(subArray(m, members), array, digit + 1, seq);
			}
		}
	}

	// memnbers の要素から m を除いた配列を返す
	private static int[] subArray(int m, int[] members) {
		int[] ret = new int[members.length - 1];
		for (int i = 0, j = 0; i < members.length; i++) {
			if (members[i] != m) {
				ret[j++] = members[i];
			}
		}
		return ret;
	}

	private static void input(int[] times) {
		try (Scanner scan = new Scanner(System.in)) {
			for (int i = 0; i < 5; i++) {
				times[i] = scan.nextInt();
			}
		}
	}

	// order は注文する料理の所要時間配列
	private static int calcTime(int[] order, int maxTime) {
		int t = 0;
		for (int i = 0; i < order.length; i++) {
			t += order[i]; // 完成時刻
			if ((i != order.length - 1) && (t % 10 != 0)) {
				t += (10 - (t % 10));
			}
			// 最大時間を越えたらそれ以上計算しない
			if(t >= maxTime) {
				return t;
			}
		}
		return t;
	}
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 所要時間のリスト
		int[] times = new int[5];
		input(times);

		// 0〜4の順列を生成
		List<int[]> sequences = sequence(new int[] { 0, 1, 2, 3, 4 });
//		sequences.stream().map(e -> Arrays.toString(e)).forEach(System.out::println);

		int minTime = Integer.MAX_VALUE;
		int[] order = new int[5];
		for (int[] seq : sequences) {
			for (int i = 0; i < order.length; i++) {
				order[i] = times[seq[i]];
			}
			int time = calcTime(order, minTime);
			minTime = (time < minTime) ? time : minTime;
//			System.out.printf("%s => %d\n", Arrays.toString(order), time);
		}
		System.out.println(minTime);
	}

	/**
	 * 配列で与えられた要素の順列を返す
	 * 
	 * @param members
	 * @return
	 */
	private static List<int[]> sequence(int[] members) {
		List<int[]> sequences = new ArrayList<>();
		sequence0(members, new int[members.length], 0, sequences);
		return sequences;
	}

	private static void sequence0(int[] members, int[] array, int digit, List<int[]> seq) {
		for (int m : members) {
			array[digit] = m;
			if (digit == array.length - 1) {
				seq.add(Arrays.copyOf(array, array.length));
			} else {
				sequence0(subArray(m, members), array, digit + 1, seq);
			}
		}
	}

	// memnbers の要素から m を除いた配列を返す
	private static int[] subArray(int m, int[] members) {
		int[] ret = new int[members.length - 1];
		for (int i = 0, j = 0; i < members.length; i++) {
			if (members[i] != m) {
				ret[j++] = members[i];
			}
		}
		return ret;
	}

	private static void input(int[] times) {
		try (Scanner scan = new Scanner(System.in)) {
			for (int i = 0; i < 5; i++) {
				times[i] = scan.nextInt();
			}
		}
	}

	// order は注文する料理の所要時間配列
	private static int calcTime(int[] order, int maxTime) {
		int t = 0;
		for (int i = 0; i < order.length; i++) {
			t += order[i]; // 完成時刻
			if ((i != order.length - 1) && (t % 10 != 0)) {
				t += (10 - (t % 10));
			}
			// 最大時間を越えたらそれ以上計算しない
			if(t >= maxTime) {
				return t;
			}
		}
		return t;
	}
}
