#include <bits/stdc++.h>
using namespace std;
long a[6][6];
int x[5];
long fun(int n, int m) {
  long r = a[x[n]][x[m]] + a[x[m]][x[n]];
  return r;
}
int main() {
  for (int i = 1; i < 6; i++)
    for (int j = 1; j < 6; j++) cin >> a[i][j];
  long result = 0;
  x[0] = 1;
  x[1] = 2;
  x[2] = 3;
  x[3] = 4;
  x[4] = 5;
  do {
    long t = fun(0, 1) + fun(1, 2) + fun(2, 3) * 2 + fun(3, 4) * 2;
    result = max(result, t);
  } while (next_permutation(x, x + 5));
  cout << result << endl;
  return 0;
}
