import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[][] team = new int[20][5];
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 5; j++) {
team[i][j] = input.nextInt();
}
}
int maxSum = 0;
for (int i = 0; i < 20; i++)
for (int j = 0; j < 20; j++)
for (int k = 0; k < 20; k++)
for (int h = 0; h < 20; h++)
for (int g = 0; g < 20; g++)
if ((i != j && i != k && i != h && i != g) && (j != k && j != h && j != g) && (k != h && k != g) && h != g) {
int max = team[i][0] + team[j][1] + team[k][2] + team[h][3] + team[g][4];
if (max > maxSum)
maxSum = max;
}
System.out.println(maxSum);
input.close();
}
}