#include <bits/stdc++.h>
using namespace std;
int p[11];
int n = 5;
int a[11][11];
int check() {
  int res = 0;
  for (int j = 1; j < n; j++)
    for (int i = j; i < n; i += 2) {
      int x = p[i - 1];
      int y = p[i];
      res += a[x][y] + a[y][x];
    }
  return res;
}
int main() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
  int ans = 0;
  for (int i = 0; i < n; i++) p[i] = i;
  do {
    ans = max(ans, check());
  } while (next_permutation(p, p + n));
  cout << ans;
}
