#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<iomanip>
typedef long long int llint ;
using namespace std;

map<pair<int, int>, llint> rights;
map<pair<int, int>, llint> lefts;
int main() {
	int n,all[200][200];
	pair<int, int> maxe,maxo;
	llint maxen=-1, maxon=-1;
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> all[i][j];
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n-1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j<=i) {
				leftpair.first = 0;
				leftpair.second = i-j;
			}
			else {
				leftpair.first = n-1;
				leftpair.second = n-1-j+i;
			}
			rights[rightpair]+=all[i][j];
			lefts[leftpair] += all[i][j];
		}

	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n - 1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j <= i) {
				leftpair.first = 0;
				leftpair.second = i - j;
			}
			else {
				leftpair.first = n - 1;
				leftpair.second = n - 1 - j + i;
			}
			llint val = rights[rightpair] + lefts[leftpair] - all[i][j];
			if ((i + j) % 2) {
				if (val > maxon) {
					maxo = make_pair(i, j);
					maxon = val;
				}
			}
			else {
				if (val > maxen) {
					maxe = make_pair(i, j);
					maxen = val;
				}

			}
		}
	}
	cout << maxen + maxon << endl;
	cout << maxe.first << ' ' << maxe.second<<' ';
	cout << maxo.first << ' ' << maxo.second;
//	system("pause");
	return 0;
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<iomanip>
typedef long long int llint ;
using namespace std;

llint rights[2001][2001];
llint lefts[2001][2001];
int main() {
	int n,all[2001][2001];
	pair<int, int> maxe,maxo;
	llint maxen=-1, maxon=-1;
	cin >> n;
	if(n==2000){

    cout<<"IN";
}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> all[i][j];
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n-1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j<=i) {
				leftpair.first = 0;
				leftpair.second = i-j;
			}
			else {
				leftpair.first = n-1;
				leftpair.second = n-1-j+i;
			}
			rights[rightpair.first][rightpair.second]+=all[i][j];
			lefts[leftpair.first][leftpair.second] += all[i][j];
		}

	if(n==2000 &&i>1800){

    cout<<i;
}
	}
if(n==2000){

    cout<<"OUT";
}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n - 1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j <= i) {
				leftpair.first = 0;
				leftpair.second = i - j;
			}
			else {
				leftpair.first = n - 1;
				leftpair.second = n - 1 - j + i;
			}
			llint val = rights[rightpair.first][rightpair.second] + lefts[leftpair.first][leftpair.second] - all[i][j];
			if ((i + j) % 2) {
				if (val > maxon) {
					maxo = make_pair(i, j);
					maxon = val;
				}
			}
			else {
				if (val > maxen) {
					maxe = make_pair(i, j);
					maxen = val;
				}

			}
		}
	}
	cout << maxen + maxon << endl;
	cout << maxe.first+1 << ' ' << maxe.second+1<<' ';
	cout << maxo.first+1 << ' ' << maxo.second+1;
//	system("pause");
	return 0;
}


#include <iostream>
#include <cstdio>

using namespace std;
const int NMAX = 2014;
long long d1[2*NMAX], d2[2*NMAX], sol[2];
pair < int , int > v[2];
int a[NMAX][NMAX];
inline void Update(const int c,const int i,const int j,const long long val){
    if(val > sol[c]){
        sol[c] = val;
        v[c].first = i;
        v[c].second = j;
    }
}
int main(){
    int n;
    cin >> n;
    sol[0] = sol[1] = -1;
    for(int i = 1;i <= n; ++i)
        for(int j = 1;j <= n; ++j){
            int x;
            cin >> a[i][j];
            d1[i+j] += a[i][j];
            d2[i-j+n] += a[i][j];
        }
    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
            Update((i+j)&1,i,j,d1[i+j]+d2[i-j+n]-a[i][j]);
    cout<<sol[0]+sol[1]<<"\n";
    if(v[0] > v[1])
        swap(v[0],v[1]);
    cout<<v[0].first<<" "<<v[0].second<<" ";
    cout<<v[1].first<<" "<<v[1].second<<"\n";
    return 0;
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<iomanip>
typedef long long int llint ;
using namespace std;

llint rights[2001][2001];
llint lefts[2001][2001];
int main() {
	int n,all[2001][2001];
	pair<int, int> maxe,maxo;
	llint maxen=-1, maxon=-1;
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> all[i][j];
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n-1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j<=i) {
				leftpair.first = 0;
				leftpair.second = i-j;
			}
			else {
				leftpair.first = n-1;
				leftpair.second = n-1-j+i;
			}
			rights[rightpair.first][rightpair.second]+=all[i][j];
			lefts[leftpair.first][leftpair.second] += all[i][j];
		}

	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n - 1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j <= i) {
				leftpair.first = 0;
				leftpair.second = i - j;
			}
			else {
				leftpair.first = n - 1;
				leftpair.second = n - 1 - j + i;
			}
			llint val = rights[rightpair.first][rightpair.second] + lefts[leftpair.first][leftpair.second] - all[i][j];
			if ((i + j) % 2) {
				if (val > maxon) {
					maxo = make_pair(i, j);
					maxon = val;
				}
			}
			else {
				if (val > maxen) {
					maxe = make_pair(i, j);
					maxen = val;
				}

			}
		}
	}
	cout << maxen + maxon << endl;
	cout << maxe.first+1 << ' ' << maxe.second+1<<' ';
	cout << maxo.first+1 << ' ' << maxo.second+1;
//	system("pause");
	return 0;
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<iomanip>
typedef long long int llint ;
using namespace std;

llint rights[2001][2001];
llint lefts[2001][2001];
int main() {
	int n,all[2001][2001];
	pair<int, int> maxe,maxo;
	llint maxen=-1, maxon=-1;
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> all[i][j];
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n-1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j<=i) {
				leftpair.first = 0;
				leftpair.second = i-j;
			}
			else {
				leftpair.first = n-1;
				leftpair.second = n-1-j+i;
			}
			rights[rightpair.first][rightpair.second]+=all[i][j];
			lefts[leftpair.first][leftpair.second] += all[i][j];
		}

	}
if(n==2000){

    cout<<"OUT";
}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n - 1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j <= i) {
				leftpair.first = 0;
				leftpair.second = i - j;
			}
			else {
				leftpair.first = n - 1;
				leftpair.second = n - 1 - j + i;
			}
			llint val = rights[rightpair.first][rightpair.second] + lefts[leftpair.first][leftpair.second] - all[i][j];
			if ((i + j) % 2) {
				if (val > maxon) {
					maxo = make_pair(i, j);
					maxon = val;
				}
			}
			else {
				if (val > maxen) {
					maxe = make_pair(i, j);
					maxen = val;
				}

			}
		}
	}
	cout << maxen + maxon << endl;
	cout << maxe.first+1 << ' ' << maxe.second+1<<' ';
	cout << maxo.first+1 << ' ' << maxo.second+1;
//	system("pause");
	return 0;
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<iomanip>
typedef long long int llint ;
using namespace std;

llint rights[2001][2001];
llint lefts[2001][2001];
int main() {
	int n,all[2001][2001];
	pair<int, int> maxe,maxo;
	llint maxen=-1, maxon=-1;
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> all[i][j];
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n-1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j<=i) {
				leftpair.first = 0;
				leftpair.second = i-j;
			}
			else {
				leftpair.first = n-1;
				leftpair.second = n-1-j+i;
			}
			rights[rightpair.first][rightpair.second]+=all[i][j];
			lefts[leftpair.first][leftpair.second] += all[i][j];
		}

	}

	if (n == 2000) {
		cout << "OUT";

	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n - 1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j <= i) {
				leftpair.first = 0;
				leftpair.second = i - j;
			}
			else {
				leftpair.first = n - 1;
				leftpair.second = n - 1 - j + i;
			}
			llint val = rights[rightpair.first][rightpair.second] + lefts[leftpair.first][leftpair.second] - all[i][j];
			if ((i + j) % 2) {
				if (val > maxon) {
					maxo = make_pair(i, j);
					maxon = val;
				}
			}
			else {
				if (val > maxen) {
					maxe = make_pair(i, j);
					maxen = val;
				}

			}
		}
	}
	cout << maxen + maxon << endl;
	cout << maxe.first+1 << ' ' << maxe.second+1<<' ';
	cout << maxo.first+1 << ' ' << maxo.second+1;
	system("pause");
	return 0;
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<iomanip>
typedef long long int llint ;
using namespace std;

llint rights[2001][2001];
llint lefts[2001][2001];
int main() {
	int n,all[2001][2001];
	pair<int, int> maxe,maxo;
	llint maxen=-1, maxon=-1;
	cin >> n;
	if(n==2000){

    cout<<"IN";
}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> all[i][j];
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n-1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j<=i) {
				leftpair.first = 0;
				leftpair.second = i-j;
			}
			else {
				leftpair.first = n-1;
				leftpair.second = n-1-j+i;
			}
			rights[rightpair.first][rightpair.second]+=all[i][j];
			lefts[leftpair.first][leftpair.second] += all[i][j];
		}

	if(n==2000 &&i>1200){

    cout<<i;
}
	}
if(n==2000){

    cout<<"OUT";
}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n - 1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j <= i) {
				leftpair.first = 0;
				leftpair.second = i - j;
			}
			else {
				leftpair.first = n - 1;
				leftpair.second = n - 1 - j + i;
			}
			llint val = rights[rightpair.first][rightpair.second] + lefts[leftpair.first][leftpair.second] - all[i][j];
			if ((i + j) % 2) {
				if (val > maxon) {
					maxo = make_pair(i, j);
					maxon = val;
				}
			}
			else {
				if (val > maxen) {
					maxe = make_pair(i, j);
					maxen = val;
				}

			}
		}
	}
	cout << maxen + maxon << endl;
	cout << maxe.first+1 << ' ' << maxe.second+1<<' ';
	cout << maxo.first+1 << ' ' << maxo.second+1;
//	system("pause");
	return 0;
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<iomanip>
typedef long long int llint ;
using namespace std;

llint rights[2000][2000];
llint lefts[2000][2000];
int main() {
	int n,all[2000][2000];
	pair<int, int> maxe,maxo;
	llint maxen=-1, maxon=-1;
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> all[i][j];
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n-1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j<=i) {
				leftpair.first = 0;
				leftpair.second = i-j;
			}
			else {
				leftpair.first = n-1;
				leftpair.second = n-1-j+i;
			}
			rights[rightpair.first][rightpair.second]+=all[i][j];
			lefts[leftpair.first][leftpair.second] += all[i][j];
		}

	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n - 1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j <= i) {
				leftpair.first = 0;
				leftpair.second = i - j;
			}
			else {
				leftpair.first = n - 1;
				leftpair.second = n - 1 - j + i;
			}
			llint val = rights[rightpair.first][rightpair.second] + lefts[leftpair.first][leftpair.second] - all[i][j];
			if ((i + j) % 2) {
				if (val > maxon) {
					maxo = make_pair(i, j);
					maxon = val;
				}
			}
			else {
				if (val > maxen) {
					maxe = make_pair(i, j);
					maxen = val;
				}

			}
		}
	}
	cout << maxen + maxon << endl;
	cout << maxe.first+1 << ' ' << maxe.second+1<<' ';
	cout << maxo.first+1 << ' ' << maxo.second+1;
//	system("pause");
	return 0;
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<iomanip>
typedef long long int llint ;
using namespace std;

llint rights[2001][2001];
llint lefts[2001][2001];
int main() {
	int n,all[2001][2001];
	    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif
    cin.sync_with_stdio(false);
	pair<int, int> maxe,maxo;
	llint maxen=-1, maxon=-1;
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> all[i][j];
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n-1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j<=i) {
				leftpair.first = 0;
				leftpair.second = i-j;
			}
			else {
				leftpair.first = n-1;
				leftpair.second = n-1-j+i;
			}
			rights[rightpair.first][rightpair.second]+=all[i][j];
			lefts[leftpair.first][leftpair.second] += all[i][j];
		}

	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n - 1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j <= i) {
				leftpair.first = 0;
				leftpair.second = i - j;
			}
			else {
				leftpair.first = n - 1;
				leftpair.second = n - 1 - j + i;
			}
			llint val = rights[rightpair.first][rightpair.second] + lefts[leftpair.first][leftpair.second] - all[i][j];
			if ((i + j) % 2) {
				if (val > maxon) {
					maxo = make_pair(i, j);
					maxon = val;
				}
			}
			else {
				if (val > maxen) {
					maxe = make_pair(i, j);
					maxen = val;
				}

			}
		}
	}
	cout << maxen + maxon << endl;
	cout << maxe.first+1 << ' ' << maxe.second+1<<' ';
	cout << maxo.first+1 << ' ' << maxo.second+1;
//	system("pause");
	return 0;
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<iomanip>
typedef long long int llint ;
using namespace std;

llint rights[2001][2001];
llint lefts[2001][2001];
int main() {
	int n,all[2001][2001];
	pair<int, int> maxe,maxo;
	llint maxen=-1, maxon=-1;
	cin >> n;
	if(n==2000){

    cout<<"IN";
}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> all[i][j];
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n-1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j<=i) {
				leftpair.first = 0;
				leftpair.second = i-j;
			}
			else {
				leftpair.first = n-1;
				leftpair.second = n-1-j+i;
			}
			rights[rightpair.first][rightpair.second]+=all[i][j];
			lefts[leftpair.first][leftpair.second] += all[i][j];
		}

	}
if(n==2000){

    cout<<"OUT";
}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n - 1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j <= i) {
				leftpair.first = 0;
				leftpair.second = i - j;
			}
			else {
				leftpair.first = n - 1;
				leftpair.second = n - 1 - j + i;
			}
			llint val = rights[rightpair.first][rightpair.second] + lefts[leftpair.first][leftpair.second] - all[i][j];
			if ((i + j) % 2) {
				if (val > maxon) {
					maxo = make_pair(i, j);
					maxon = val;
				}
			}
			else {
				if (val > maxen) {
					maxe = make_pair(i, j);
					maxen = val;
				}

			}
		}
	}
	cout << maxen + maxon << endl;
	cout << maxe.first+1 << ' ' << maxe.second+1<<' ';
	cout << maxo.first+1 << ' ' << maxo.second+1;
//	system("pause");
	return 0;
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<iomanip>
typedef long long int llint ;
using namespace std;

llint rights[2001][2001];
llint lefts[2001][2001];
int main() {
	int n,all[2001][2001];
	pair<int, int> maxe,maxo;
	llint maxen=-1, maxon=-1;
	cin >> n;
	if(n==2000){

    cout<<"IN";
}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> all[i][j];
			if(n==2000)
		    	cout<<"INNED"<<i;

			pair<int, int> rightpair;
			pair<int, int>leftpair;
				if(n!=2000){
			if (i + j >= n) {
				rightpair.first = n-1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j<=i) {
				leftpair.first = 0;
				leftpair.second = i-j;
			}
			else {
				leftpair.first = n-1;
				leftpair.second = n-1-j+i;
			}
			rights[rightpair.first][rightpair.second]+=all[i][j];
			lefts[leftpair.first][leftpair.second] += all[i][j];
				}
		}

	if(n==2000 && i%1900==0){

    cout<<i;
}
	}
if(n==2000){

    cout<<"OUT";
}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n - 1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j <= i) {
				leftpair.first = 0;
				leftpair.second = i - j;
			}
			else {
				leftpair.first = n - 1;
				leftpair.second = n - 1 - j + i;
			}
			llint val = rights[rightpair.first][rightpair.second] + lefts[leftpair.first][leftpair.second] - all[i][j];
			if ((i + j) % 2) {
				if (val > maxon) {
					maxo = make_pair(i, j);
					maxon = val;
				}
			}
			else {
				if (val > maxen) {
					maxe = make_pair(i, j);
					maxen = val;
				}

			}
		}
	}
	cout << maxen + maxon << endl;
	cout << maxe.first+1 << ' ' << maxe.second+1<<' ';
	cout << maxo.first+1 << ' ' << maxo.second+1;
//	system("pause");
	return 0;
}


#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
#include<iomanip>
typedef long long int llint ;
using namespace std;

llint rights[2001][2001];
llint lefts[2001][2001];
int main() {
	int n,all[2001][2001];
	pair<int, int> maxe,maxo;
	llint maxen=-1, maxon=-1;
	cin >> n;
	if(n==2000){

    cout<<"IN";
}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> all[i][j];
			pair<int, int> rightpair;
			pair<int, int>leftpair;
				if(n!=2000){
			if (i + j >= n) {
				rightpair.first = n-1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j<=i) {
				leftpair.first = 0;
				leftpair.second = i-j;
			}
			else {
				leftpair.first = n-1;
				leftpair.second = n-1-j+i;
			}
			rights[rightpair.first][rightpair.second]+=all[i][j];
			lefts[leftpair.first][leftpair.second] += all[i][j];
				}
		}

	}
if(n!=2000){

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			pair<int, int> rightpair;
			pair<int, int>leftpair;
			if (i + j >= n) {
				rightpair.first = n - 1;
				rightpair.second = i + j - n + 1;
			}
			else {
				rightpair.first = 0;
				rightpair.second = i + j;
			}
			if (j <= i) {
				leftpair.first = 0;
				leftpair.second = i - j;
			}
			else {
				leftpair.first = n - 1;
				leftpair.second = n - 1 - j + i;
			}
			llint val = rights[rightpair.first][rightpair.second] + lefts[leftpair.first][leftpair.second] - all[i][j];
			if ((i + j) % 2) {
				if (val > maxon) {
					maxo = make_pair(i, j);
					maxon = val;
				}
			}
			else {
				if (val > maxen) {
					maxe = make_pair(i, j);
					maxen = val;
				}

			}
		}
	}
}
	cout << maxen + maxon << endl;
	cout << maxe.first+1 << ' ' << maxe.second+1<<' ';
	cout << maxo.first+1 << ' ' << maxo.second+1;
//	system("pause");
	return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;

using namespace std;

//1.template<class T1> void deb(T1 e){cout<<e<<endl;}
//2.template<class T1,class T2> void deb(T1 e1,T2 e2){cout<<e1<<" "<<e2<<endl;}
//3.template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
//5.template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;}
//6.template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;}
//template <class T> T lcm(T a, T b){return (a/__gcd(a,b)) * b;}
//ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
//ll power(ll x, ll y){if( y == 0)return 1;ll temp = power(x, y/2);return (y%2==0?temp*temp:x*temp*temp);}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};
#define SZ 2000

ll pd[SZ*2+3],sd[SZ*2+3];
ll board[SZ+3][SZ+3];
ll maxInfo[SZ+3][SZ+3];

int main()
{
    ll n;
    cin>>n;
    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=n; j++)
        {
            cin>>board[i][j];
            pd[i+n-j]+=board[i][j];
            sd[i-1+j]+=board[i][j];
        }
    }
    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=n; j++)
        {
            maxInfo[i][j] = pd[i+n-j]+sd[i-1+j];
            //cout<<maxInfo[i][j]<<" ";
        }
        //cout<<endl;
    }

    ll black = -1,white = -1;
    ll br,bc,wr,wc;
    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=n; j++)
        {
            if((i+j)%2==0)
            {
                if(black<maxInfo[i][j])
                {
                    black = maxInfo[i][j];
                    br = i,bc=j;
                }
            }
            else
            {
                if(white<maxInfo[i][j])
                {
                    white = maxInfo[i][j];
                    wr = i,wc=j;
                }
            }
        }
    }
    cout<<black+white-board[br][bc]-board[wr][wc]<<endl;
    cout<<br<<" "<<bc<<" "<<wr<<" "<<wc<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;
#define SZ 2005

using namespace std;

template<class T1> void deb(T1 e)
{
    cout<<e<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}
template <class T> T lcm(T a, T b)
{
    return (a/__gcd(a,b)) * b;
}
ll bigmod(ll a,ll b,ll m)
{
    if(b == 0) return 1%m;
    ll x = bigmod(a,b/2,m);
    x = (x * x) % m;
    if(b % 2 == 1) x = (x * a) % m;
    return x;
}
ll power(ll x, ll y)
{
    if( y == 0)return 1;
    ll temp = power(x, y/2);
    return (y%2==0?temp*temp:x*temp*temp);
}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};

/*****************************************************************************************************/

ll board[SZ][SZ];
ll pd[2*SZ+5];
ll sd[2*SZ+5];

int main()
{
    ll n;
    cin>>n;
    for(ll i=0; i<n; i++)
    {
        for(ll j=0; j<n; j++)
        {
            cin>>board[i][j];
            pd[(n-1)+(i-j)]+=board[i][j];
            sd[i+j]+=board[i][j];
        }
    }
    ll evenX,evenY,oddX,oddY,evenMax,oddMax;
    evenX=evenY=oddX=oddY=evenMax=oddMax=-1;
    for(ll i=n-1; i>=0; i--)
    {
        for(ll j=n-1; j>=0; j--)
        {
            if((i+j)%2==0)
            {
                if(evenMax<pd[(n-1)+(i-j)]+sd[i+j]-board[i][j])
                {
                    evenMax = pd[(n-1)+(i-j)]+sd[i+j]-board[i][j];
                    evenX = i,evenY = j;
                }
            }
            else
            {
                if(oddMax<pd[(n-1)+(i-j)]+sd[i+j]-board[i][j])
                {
                    oddMax = pd[(n-1)+(i-j)]+sd[i+j]-board[i][j];
                    oddX = i, oddY = j;
                }
            }
        }
    }
    cout<<evenMax+oddMax<<endl;
    cout<<++evenX<<" "<<++evenY<<" "<<++oddX<<" "<<++oddY<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;
#define SZ 2014

using namespace std;

template<class T1> void deb(T1 e)
{
    cout<<e<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}
template <class T> T lcm(T a, T b)
{
    return (a/__gcd(a,b)) * b;
}
ll bigmod(ll a,ll b,ll m)
{
    if(b == 0) return 1%m;
    ll x = bigmod(a,b/2,m);
    x = (x * x) % m;
    if(b % 2 == 1) x = (x * a) % m;
    return x;
}
ll power(ll x, ll y)
{
    if( y == 0)return 1;
    ll temp = power(x, y/2);
    return (y%2==0?temp*temp:x*temp*temp);
}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};

/*****************************************************************************************************/

ll board[SZ][SZ];
ll pd[2*SZ+5];
ll sd[2*SZ+5];

int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            cin>>board[i][j];
            pd[(n-1)+(i-j)]+=board[i][j];
            sd[i+j]+=board[i][j];
        }
    }
    int evenX,evenY,oddX,oddY;
    ll evenMax,oddMax;
    evenX=evenY=oddX=oddY=-1;
    evenMax=oddMax=-1;
    for(int i=n-1; i>=0; i--)
    {
        for(int j=n-1; j>=0; j--)
        {
            if((i+j)%2==0)
            {
                if(evenMax<pd[(n-1)+(i-j)]+sd[i+j]-board[i][j])
                {
                    evenMax = pd[(n-1)+(i-j)]+sd[i+j]-board[i][j];
                    evenX = i,evenY = j;
                }
            }
            else
            {
                if(oddMax<pd[(n-1)+(i-j)]+sd[i+j]-board[i][j])
                {
                    oddMax = pd[(n-1)+(i-j)]+sd[i+j]-board[i][j];
                    oddX = i, oddY = j;
                }
            }
        }
    }
    cout<<evenMax+oddMax<<endl;
    cout<<++evenX<<" "<<++evenY<<" "<<++oddX<<" "<<++oddY<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;
#define SZ 2005

using namespace std;

template<class T1> void deb(T1 e)
{
    cout<<e<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}
template <class T> T lcm(T a, T b)
{
    return (a/__gcd(a,b)) * b;
}
ll bigmod(ll a,ll b,ll m)
{
    if(b == 0) return 1%m;
    ll x = bigmod(a,b/2,m);
    x = (x * x) % m;
    if(b % 2 == 1) x = (x * a) % m;
    return x;
}
ll power(ll x, ll y)
{
    if( y == 0)return 1;
    ll temp = power(x, y/2);
    return (y%2==0?temp*temp:x*temp*temp);
}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};

/*****************************************************************************************************/

ll board[SZ][SZ];
ll pd[2*SZ+5];
ll sd[2*SZ+5];

int main()
{
    ll n;
    cin>>n;
    for(ll i=0; i<n; i++)
    {
        for(ll j=0; j<n; j++)
        {
            cin>>board[i][j];
            pd[(n-1)+(i-j)]+=board[i][j];
            sd[i+j]+=board[i][j];
        }
    }
    ll evenX,evenY,oddX,oddY,evenMax,oddMax;
    evenX=evenY=oddX=oddY=evenMax=oddMax=-1;
    for(ll i=0; i<n; i++)
    {
        for(ll j=0; j<n; j++)
        {
            if((i+j)%2==0)
            {
                if(evenMax<pd[(n-1)+(i-j)]+sd[i+j])
                {
                    evenMax = pd[(n-1)+(i-j)]+sd[i+j];
                    evenX = i,evenY = j;
                }
            }
            else
            {
                if(oddMax<pd[(n-1)+(i-j)]+sd[i+j])
                {
                    oddMax = pd[(n-1)+(i-j)]+sd[i+j];
                    oddX = i, oddY = j;
                }
            }
        }
    }
    cout<<evenMax+oddMax-board[evenX][evenY]-board[oddX][oddY]<<endl;
    cout<<++evenX<<" "<<++evenY<<" "<<++oddX<<" "<<++oddY<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;

using namespace std;

//1.template<class T1> void deb(T1 e){cout<<e<<endl;}
//2.template<class T1,class T2> void deb(T1 e1,T2 e2){cout<<e1<<" "<<e2<<endl;}
//3.template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
//5.template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;}
//6.template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;}
//template <class T> T lcm(T a, T b){return (a/__gcd(a,b)) * b;}
//ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
//ll power(ll x, ll y){if( y == 0)return 1;ll temp = power(x, y/2);return (y%2==0?temp*temp:x*temp*temp);}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};
#define SZ 2000

ll pd[SZ*2+3],sd[SZ*2+3];
ll board[SZ+3][SZ+3];
ll maxInfo[SZ+3][SZ+3];

int main()
{
    ll n;
    cin>>n;
    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=n; j++)
        {
            cin>>board[i][j];
            pd[i+n-j]+=board[i][j];
            sd[i-1+j]+=board[i][j];
        }
    }
    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=n; j++)
        {
            maxInfo[i][j] = pd[i+n-j]+sd[i-1+j];
            //cout<<maxInfo[i][j]<<" ";
        }
        //cout<<endl;
    }

    ll black = -1,white = -1;
    ll br,bc,wr,wc;
    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=n; j++)
        {
            ll pri = i+n-j;
            ll sec = i-1+j;
            if(n%2==0)
            {
                if(pri%2==0&&sec%2==1&&black<maxInfo[i][j])
                {
                    black = max(black,maxInfo[i][j]);
                    br = i,bc = j;
                }
                else if(pri%2==1&&sec%2==0&&white<maxInfo[i][j])
                {
                    white = max(white,maxInfo[i][j]);
                    wr = i,wc = j;
                }
            }
            else
            {
                if(pri%2==1&&sec%2==1&&black<maxInfo[i][j])
                {
                    black = max(black,maxInfo[i][j]);
                    br = i,bc = j;
                }
                else if(pri%2==0&&sec%2==0&&white<maxInfo[i][j])
                {
                    white = max(white,maxInfo[i][j]);
                    wr = i,wc = j;
                }
            }
        }
    }
    cout<<black+white-board[br][bc]-board[wr][wc]<<endl;
    cout<<br<<" "<<bc<<" "<<wr<<" "<<wc<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;
#define SZ 2014

using namespace std;

template<class T1> void deb(T1 e)
{
    cout<<e<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}
template <class T> T lcm(T a, T b)
{
    return (a/__gcd(a,b)) * b;
}
ll bigmod(ll a,ll b,ll m)
{
    if(b == 0) return 1%m;
    ll x = bigmod(a,b/2,m);
    x = (x * x) % m;
    if(b % 2 == 1) x = (x * a) % m;
    return x;
}
ll power(ll x, ll y)
{
    if( y == 0)return 1;
    ll temp = power(x, y/2);
    return (y%2==0?temp*temp:x*temp*temp);
}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};

/*****************************************************************************************************/

ll board[SZ][SZ];
ll pd[2*SZ+5];
ll sd[2*SZ+5];

int main()
{
    cin.sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            cin>>board[i][j];
            pd[(n-1)+(i-j)]+=board[i][j];
            sd[i+j]+=board[i][j];
        }
    }
    int evenX,evenY,oddX,oddY;
    ll evenMax,oddMax;
    evenX=evenY=oddX=oddY=-1;
    evenMax=oddMax=-1;
    for(int i=n-1; i>=0; i--)
    {
        for(int j=n-1; j>=0; j--)
        {
            if((i+j)%2==0)
            {
                if(evenMax<pd[(n-1)+(i-j)]+sd[i+j]-board[i][j])
                {
                    evenMax = pd[(n-1)+(i-j)]+sd[i+j]-board[i][j];
                    evenX = i,evenY = j;
                }
            }
            else
            {
                if(oddMax<pd[(n-1)+(i-j)]+sd[i+j]-board[i][j])
                {
                    oddMax = pd[(n-1)+(i-j)]+sd[i+j]-board[i][j];
                    oddX = i, oddY = j;
                }
            }
        }
    }
    cout<<evenMax+oddMax<<endl;
    cout<<++evenX<<" "<<++evenY<<" "<<++oddX<<" "<<++oddY<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;

using namespace std;

//1.template<class T1> void deb(T1 e){cout<<e<<endl;}
//2.template<class T1,class T2> void deb(T1 e1,T2 e2){cout<<e1<<" "<<e2<<endl;}
//3.template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
//5.template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;}
//6.template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;}
//template <class T> T lcm(T a, T b){return (a/__gcd(a,b)) * b;}
//ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
//ll power(ll x, ll y){if( y == 0)return 1;ll temp = power(x, y/2);return (y%2==0?temp*temp:x*temp*temp);}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};
#define SZ 2000

ll pd[SZ*2+3],sd[SZ*2+3];

int main()
{
    ll n,tmp;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            cin>>tmp;
            pd[i+n-j]+=tmp;
            sd[i-1+j]+=tmp;
        }
    }
//    for(int i=1;i<=(2*n-1);i++)cout<<pd[i]<<" ";
//    cout<<endl;
//    for(int i=1;i<=(2*n-1);i++)cout<<sd[i]<<" ";
//    cout<<endl;
    ll mAx = -1,pd_odd_loc,sd_odd_loc,pd_evn_loc,sd_evn_loc;
    for(int i=1; i<=(2*n-1); i+=2)
    {
        if(pd[i]>mAx)
        {
            mAx = pd[i];
            pd_odd_loc = i;
        }
    }
    mAx = -1;
    for(int i=1; i<=(2*n-1); i+=2)
    {
        if(sd[i]>mAx)
        {
            mAx = sd[i];
            sd_odd_loc = i;
        }
    }
    mAx = -1;
    for(int i=2; i<=(2*n-1); i+=2)
    {
        if(pd[i]>mAx)
        {
            mAx = pd[i];
            pd_evn_loc = i;
        }
    }
    mAx = -1;
    for(int i=2; i<=(2*n-1); i+=2)
    {
        if(sd[i]>mAx)
        {
            mAx = sd[i];
            sd_evn_loc = i;
        }
    }
    //deb(pd_odd_loc,sd_evn_loc,pd_evn_loc,sd_odd_loc);
    ll i1 = (pd_odd_loc+sd_evn_loc-n+1)/2;
    ll j1 = (sd_evn_loc+1-pd_odd_loc+n)/2;
    ll i2 = (pd_evn_loc+sd_odd_loc-n+1)/2;
    ll j2 = (sd_odd_loc+1-pd_evn_loc+n)/2;
    cout<<i2<<" "<<j2<<" "<<i1<<" "<<j1<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;

using namespace std;

//1.template<class T1> void deb(T1 e){cout<<e<<endl;}
//2.template<class T1,class T2> void deb(T1 e1,T2 e2){cout<<e1<<" "<<e2<<endl;}
//3.template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
//5.template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;}
//6.template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;}
//template <class T> T lcm(T a, T b){return (a/__gcd(a,b)) * b;}
//ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
//ll power(ll x, ll y){if( y == 0)return 1;ll temp = power(x, y/2);return (y%2==0?temp*temp:x*temp*temp);}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};
#define SZ 2000

ll pd[SZ*2+3],sd[SZ*2+3];
ll board[SZ+3][SZ+3];

int main()
{
    ll n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            cin>>board[i][j];
            pd[i+n-j]+=board[i][j];
            sd[i-1+j]+=board[i][j];
        }
    }
//    for(int i=1;i<=(2*n-1);i++)cout<<pd[i]<<" ";
//    cout<<endl;
//    for(int i=1;i<=(2*n-1);i++)cout<<sd[i]<<" ";
//    cout<<endl;
    ll mAx = -1,pd_odd_loc,sd_odd_loc,pd_evn_loc,sd_evn_loc;
    for(int i=1; i<=(2*n-1); i+=2)
    {
        if(pd[i]>mAx)
        {
            mAx = pd[i];
            pd_odd_loc = i;
        }
    }
    mAx = -1;
    for(int i=1; i<=(2*n-1); i+=2)
    {
        if(sd[i]>mAx)
        {
            mAx = sd[i];
            sd_odd_loc = i;
        }
    }
    mAx = -1;
    for(int i=2; i<=(2*n-1); i+=2)
    {
        if(pd[i]>mAx)
        {
            mAx = pd[i];
            pd_evn_loc = i;
        }
    }
    mAx = -1;
    for(int i=2; i<=(2*n-1); i+=2)
    {
        if(sd[i]>mAx)
        {
            mAx = sd[i];
            sd_evn_loc = i;
        }
    }
    //deb(pd_odd_loc,sd_evn_loc,pd_evn_loc,sd_odd_loc);
    ll i1 = (pd_odd_loc+sd_evn_loc-n+1)/2;
    ll j1 = (sd_evn_loc+1-pd_odd_loc+n)/2;
    ll i2 = (pd_evn_loc+sd_odd_loc-n+1)/2;
    ll j2 = (sd_odd_loc+1-pd_evn_loc+n)/2;
    cout<<pd[pd_odd_loc]+sd[sd_evn_loc]+pd[pd_evn_loc]+sd[sd_odd_loc]-board[i1][j1]-board[i2][j2]<<endl;
    cout<<i2<<" "<<j2<<" "<<i1<<" "<<j1<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;
#define SZ 2005

using namespace std;

template<class T1> void deb(T1 e)
{
    cout<<e<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}
template <class T> T lcm(T a, T b)
{
    return (a/__gcd(a,b)) * b;
}
ll bigmod(ll a,ll b,ll m)
{
    if(b == 0) return 1%m;
    ll x = bigmod(a,b/2,m);
    x = (x * x) % m;
    if(b % 2 == 1) x = (x * a) % m;
    return x;
}
ll power(ll x, ll y)
{
    if( y == 0)return 1;
    ll temp = power(x, y/2);
    return (y%2==0?temp*temp:x*temp*temp);
}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};

/*****************************************************************************************************/

ll board[SZ][SZ];
ll pd[2*SZ+5];
ll sd[2*SZ+5];

int main()
{
    ll n;
    cin>>n;
    for(ll i=0; i<n; i++)
    {
        for(ll j=0; j<n; j++)
        {
            cin>>board[i][j];
            pd[(n-1)+(i-j)]+=board[i][j];
            sd[i+j]+=board[i][j];
        }
    }
    ll evenX,evenY,oddX,oddY,evenMax,oddMax;
    evenX=evenY=oddX=oddY=evenMax=oddMax=-1;
    for(ll i=n-1; i>=0; i--)
    {
        for(ll j=n-1; j>=0; j--)
        {
            if((i+j)%2==0)
            {
                if(evenMax<pd[(n-1)+(i-j)]+sd[i+j])
                {
                    evenMax = pd[(n-1)+(i-j)]+sd[i+j];
                    evenX = i,evenY = j;
                }
            }
            else
            {
                if(oddMax<pd[(n-1)+(i-j)]+sd[i+j])
                {
                    oddMax = pd[(n-1)+(i-j)]+sd[i+j];
                    oddX = i, oddY = j;
                }
            }
        }
    }
    cout<<evenMax+oddMax<<endl;
    cout<<++evenX<<" "<<++evenY<<" "<<++oddX<<" "<<++oddY<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;

using namespace std;

//1.template<class T1> void deb(T1 e){cout<<e<<endl;}
//2.template<class T1,class T2> void deb(T1 e1,T2 e2){cout<<e1<<" "<<e2<<endl;}
//3.template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
//5.template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;}
//6.template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;}
//template <class T> T lcm(T a, T b){return (a/__gcd(a,b)) * b;}
//ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
//ll power(ll x, ll y){if( y == 0)return 1;ll temp = power(x, y/2);return (y%2==0?temp*temp:x*temp*temp);}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};
#define SZ 2000

ll pd[SZ*2+3],sd[SZ*2+3];
ll board[SZ+3][SZ+3];
ll maxInfo[SZ+3][SZ+3];

int main()
{
    ll n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            cin>>board[i][j];
            pd[i+n-j]+=board[i][j];
            sd[i-1+j]+=board[i][j];
        }
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            maxInfo[i][j] = pd[i+n-j]+sd[i-1+j];
            //cout<<maxInfo[i][j]<<" ";
        }
        //cout<<endl;
    }

    ll black = -1,white = -1;
    int br,bc,wr,wc;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            int pri = i+n-j;
            int sec = i-1+j;
            if(n%2==0)
            {
                if(pri%2==0&&sec%2==1&&black<maxInfo[i][j])
                {
                    black = max(black,maxInfo[i][j]);
                    br = i,bc = j;
                }
                else if(pri%2==1&&sec%2==0&&white<maxInfo[i][j])
                {
                    white = max(white,maxInfo[i][j]);
                    wr = i,wc = j;
                }
            }
            else
            {
                if(pri%2==1&&sec%2==1&&black<maxInfo[i][j])
                {
                    black = max(black,maxInfo[i][j]);
                    br = i,bc = j;
                }
                else if(pri%2==0&&sec%2==0&&white<maxInfo[i][j])
                {
                    white = max(white,maxInfo[i][j]);
                    wr = i,wc = j;
                }
            }
        }
    }
    cout<<black+white-board[br][bc]-board[wr][wc]<<endl;
    cout<<br<<" "<<bc<<" "<<wr<<" "<<wc<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fread(name) freopen(name,"r",stdin);
#define fwrite(name) freopen(name","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;
#define reduceCinCoutTime ios_base::sync_with_stdio(false)
#define SZ 2014

using namespace std;

template<class T1> void deb(T1 e){cout<<e<<endl;}
template<class T1,class T2> void deb(T1 e1,T2 e2){cout<<e1<<" "<<e2<<endl;}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;}
template <class T> T lcm(T a, T b){return (a/__gcd(a,b)) * b;}
ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
ll power(ll x, ll y){if( y == 0)return 1;ll temp = power(x, y/2);return (y%2==0?temp*temp:x*temp*temp);}

//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};

/*****************************************************************************************************/

ll board[SZ][SZ];
ll pd[2*SZ+5];
ll sd[2*SZ+5];

int main()
{
    //fread("input.txt");
    reduceCinCoutTime;
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            cin>>board[i][j];
            pd[(n-1)+(i-j)]+=board[i][j];
            sd[i+j]+=board[i][j];
        }
    }
    int evenX,evenY,oddX,oddY;
    ll evenMax,oddMax;
    evenX=evenY=oddX=oddY=-1;
    evenMax=oddMax=-1;
    for(int i=n-1; i>=0; i--)
    {
        for(int j=n-1; j>=0; j--)
        {
            if((i+j)%2==0)
            {
                if(evenMax<pd[(n-1)+(i-j)]+sd[i+j]-board[i][j])
                {
                    evenMax = pd[(n-1)+(i-j)]+sd[i+j]-board[i][j];
                    evenX = i,evenY = j;
                }
            }
            else
            {
                if(oddMax<pd[(n-1)+(i-j)]+sd[i+j]-board[i][j])
                {
                    oddMax = pd[(n-1)+(i-j)]+sd[i+j]-board[i][j];
                    oddX = i, oddY = j;
                }
            }
        }
    }
    cout<<evenMax+oddMax<<endl;
    cout<<++evenX<<" "<<++evenY<<" "<<++oddX<<" "<<++oddY<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;
#define SZ 2005

using namespace std;

template<class T1> void deb(T1 e)
{
    cout<<e<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}
template <class T> T lcm(T a, T b)
{
    return (a/__gcd(a,b)) * b;
}
ll bigmod(ll a,ll b,ll m)
{
    if(b == 0) return 1%m;
    ll x = bigmod(a,b/2,m);
    x = (x * x) % m;
    if(b % 2 == 1) x = (x * a) % m;
    return x;
}
ll power(ll x, ll y)
{
    if( y == 0)return 1;
    ll temp = power(x, y/2);
    return (y%2==0?temp*temp:x*temp*temp);
}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};

/*****************************************************************************************************/

ll board[SZ][SZ];
ll pd[2*SZ+5];
ll sd[2*SZ+5];

int main()
{
    ll n;
    cin>>n;
    for(ll i=0; i<n; i++)
    {
        for(ll j=0; j<n; j++)
        {
            cin>>board[i][j];
            pd[(n-1)+(i-j)]+=board[i][j];
            sd[i+j]+=board[i][j];
        }
    }
    ll evenX,evenY,oddX,oddY,evenMax,oddMax;
    evenX=evenY=oddX=oddY=evenMax=oddMax=-1;
    for(ll i=n-1; i>=0; i--)
    {
        for(ll j=n-1; j>=0; j--)
        {
            if((i+j)%2==0)
            {
                if(evenMax<pd[(n-1)+(i-j)]+sd[i+j]-board[i][j])
                {
                    evenMax = pd[(n-1)+(i-j)]+sd[i+j];
                    evenX = i,evenY = j;
                }
            }
            else
            {
                if(oddMax<pd[(n-1)+(i-j)]+sd[i+j]-board[i][j])
                {
                    oddMax = pd[(n-1)+(i-j)]+sd[i+j];
                    oddX = i, oddY = j;
                }
            }
        }
    }
    cout<<evenMax+oddMax<<endl;
    cout<<++evenX<<" "<<++evenY<<" "<<++oddX<<" "<<++oddY<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;

using namespace std;

//1.template<class T1> void deb(T1 e){cout<<e<<endl;}
//2.template<class T1,class T2> void deb(T1 e1,T2 e2){cout<<e1<<" "<<e2<<endl;}
//3.template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
//5.template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;}
//6.template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;}
//template <class T> T lcm(T a, T b){return (a/__gcd(a,b)) * b;}
//ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
//ll power(ll x, ll y){if( y == 0)return 1;ll temp = power(x, y/2);return (y%2==0?temp*temp:x*temp*temp);}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};
#define SZ 2000

ll pd[SZ*2+3],sd[SZ*2+3];
ll board[SZ+3][SZ+3];
ll maxInfo[SZ+3][SZ+3];

int main()
{
    ll n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            cin>>board[i][j];
            pd[i+n-j]+=board[i][j];
            sd[i-1+j]+=board[i][j];
        }
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            maxInfo[i][j] = pd[i+n-j]+sd[i-1+j];
        }
    }
    ll black = -1,white = -1;
    int br,bc,wr,wc;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            int pri = i+n-j;
            int sec = i-1+j;
            if(n%2==0)
            {
                if(pri%2==0&&sec%2==1&&black<maxInfo[i][j])
                {
                    black = max(black,maxInfo[i][j]);
                    br = i,bc = j;
                }
                else if(white<maxInfo[i][j])
                {
                    white = max(white,maxInfo[i][j]);
                    wr = i,wc = j;
                }
            }
            else
            {
                if(pri%2==1&&sec%2==1&&black<maxInfo[i][j])
                {
                    black = max(black,maxInfo[i][j]);
                    br = i,bc = j;
                }
                else if(white<maxInfo[i][j])
                {
                    white = max(white,maxInfo[i][j]);
                    wr = i,wc = j;
                }
            }
        }
    }
    cout<<black+white-board[br][bc]-board[wr][wc]<<endl;
    cout<<br<<" "<<bc<<" "<<wr<<" "<<wc<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;

using namespace std;

//1.template<class T1> void deb(T1 e){cout<<e<<endl;}
//2.template<class T1,class T2> void deb(T1 e1,T2 e2){cout<<e1<<" "<<e2<<endl;}
//3.template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<endl;}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
//5.template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;}
//6.template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;}
//template <class T> T lcm(T a, T b){return (a/__gcd(a,b)) * b;}
//ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
//ll power(ll x, ll y){if( y == 0)return 1;ll temp = power(x, y/2);return (y%2==0?temp*temp:x*temp*temp);}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};
#define SZ 2000

ll pd[SZ*2+3],sd[SZ*2+3];
ll board[SZ+3][SZ+3];
ll maxInfo[SZ+3][SZ+3];

int main()
{
    ll n;
    cin>>n;
    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=n; j++)
        {
            cin>>board[i][j];
            pd[i+n-j]+=board[i][j];
            sd[i-1+j]+=board[i][j];
        }
    }
    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=n; j++)
        {
            maxInfo[i][j] = pd[i+n-j]+sd[i-1+j];
            //cout<<maxInfo[i][j]<<" ";
        }
        //cout<<endl;
    }

    ll black = -1,white = -1;
    ll br,bc,wr,wc;
    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=n; j++)
        {
            if((i+j)%2==0)
            {
                if(black<=maxInfo[i][j])
                {
                    black = maxInfo[i][j];
                    br = i,bc=j;
                }
            }
            else
            {
                if(white<=maxInfo[i][j])
                {
                    white = maxInfo[i][j];
                    wr = i,wc=j;
                }
            }
        }
    }
    cout<<black+white-board[br][bc]-board[wr][wc]<<endl;
    cout<<br<<" "<<bc<<" "<<wr<<" "<<wc<<endl;
    return 0;
}


/**
    "In the name of Allah, the Most Gracious, the Most Merciful."
*/
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <limits.h>
#include <limits>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <assert.h>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
#define inf (1<<28)
#define mp make_pair
#define pii pair<int,int>
#define fs first
#define sc second
#define pob pop_back
#define vec_ vector
#define clr(a) a.clear()
#define pb push_back
#define eps 1E-7
#define sf scanf
#define pf printf
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define fop   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define scch(a) scanf(" %c",&a)
#define scll1(a) scanf(" %I64d",&a)
#define scll2(a,b) scanf(" %I64d %I64d",&a,&b)
#define scll3(a,b,c) scanf(" %I64d %I64d %I64d",&a,&b,&c)
#define sci1(a) scanf(" %d",&a)
#define sci2(a,b) scanf(" %d %d",&a,&b)
#define sci3(a,b,c) scanf(" %d %d %d",&a,&b,&c)
#define scd1(a) scanf(" %lf",&a)
#define scd2(a,b) scanf(" %lf %lf",&a,&b)
#define scd3(a,b,c) scanf(" %lf %lf %lf",&a,&b,&c)
#define sz(a) a.size()
#define ll long long
#define ull unsigned long long
#define dd double
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;
#define SZ 2005

using namespace std;

template<class T1> void deb(T1 e)
{
    cout<<e<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2)
{
    cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
{
    cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
{
    cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}
template <class T> T lcm(T a, T b)
{
    return (a/__gcd(a,b)) * b;
}
ll bigmod(ll a,ll b,ll m)
{
    if(b == 0) return 1%m;
    ll x = bigmod(a,b/2,m);
    x = (x * x) % m;
    if(b % 2 == 1) x = (x * a) % m;
    return x;
}
ll power(ll x, ll y)
{
    if( y == 0)return 1;
    ll temp = power(x, y/2);
    return (y%2==0?temp*temp:x*temp*temp);
}
//int X[]={1,1,2,2,-1,-1,-2,-2};//knight move//
//int Y[]={2,-2,1,-1,2,-2,1,-1};//knight move//
//int X[]={0,-1,-1,-1,0,1,1,1};
//int Y[]={-1,-1,0,1,1,1,0,-1};
//int X[]={-1,0,1,0};
//int Y[]={0,1,0,-1};

/*****************************************************************************************************/

int board[SZ][SZ];
int pd[2*SZ+5];
int sd[2*SZ+5];

int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            cin>>board[i][j];
            pd[(n-1)+(i-j)]+=board[i][j];
            sd[i+j]+=board[i][j];
        }
    }
    int evenX,evenY,oddX,oddY,evenMax,oddMax;
    evenX=evenY=oddX=oddY=evenMax=oddMax=-1;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            if((i+j)%2==0)
            {
                if(evenMax<pd[(n-1)+(i-j)]+sd[i+j])
                {
                    evenMax = pd[(n-1)+(i-j)]+sd[i+j];
                    evenX = i,evenY = j;
                }
            }
            else
            {
                if(oddMax<pd[(n-1)+(i-j)]+sd[i+j])
                {
                    oddMax = pd[(n-1)+(i-j)]+sd[i+j];
                    oddX = i, oddY = j;
                }
            }
        }
    }
    cout<<evenMax+oddMax-board[evenX][evenY]-board[oddX][oddY]<<endl;
    cout<<++evenX<<" "<<++evenY<<" "<<++oddX<<" "<<++oddY<<endl;
    return 0;
}


import java.util.*;
public class a{
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int[] ar=new int[2*n+1];

		for(int i=0;i<ar.length;i++)
			ar[i]=in.nextInt();

		for(int i=0;i<ar.length;i++){
			if(i%2==1){
				if(ar[i-1]<ar[i]&&ar[i]>ar[i+1]&&k>0){
					ar[i]--;
					k--;
				}
			}
		}

		System.out.println(Arrays.toString(ar).replaceAll("[\\[,\\]]",""));
	}
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(), k = sc.nextInt();
        int[] arr = new int[2*n + 1];

        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }

        test(arr, n, k);
    }

    private static void test(int[] arr, int n, int k) {
        for (int i = 0; i < arr.length; i++) {
            if ((i+1) % 2 == 0 && k > 0) {
                System.out.print(arr[i] - 1);
                k--;
            } else {
                System.out.print(arr[i]);
            }
            System.out.print(" ");
        }
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(), k = sc.nextInt();
        int[] arr = new int[2*n + 1];

        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }

        test(arr, n, k);
    }

    private static void test(int[] arr, int n, int k) {
        for (int i = 0; i < arr.length; i++) {
            if ((i+1) % 2 == 0 && k > 0 && isSafe(arr, i)) {
                System.out.print(arr[i] - 1);
                k--;
            } else {
                System.out.print(arr[i]);
            }
            System.out.print(" ");
        }
    }

    private static boolean isSafe(int[] arr, int i) {
        return (i > 0) && arr[i-1] < arr[i] - 1 && arr[i+1] < arr[i] - 1;
    }
}


package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(), k = sc.nextInt();
        int[] arr = new int[2*n + 1];

        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }

        test(arr, n, k);
    }

    private static void test(int[] arr, int n, int k) {
        for (int i = 0; i < arr.length; i++) {
            if ((i+1) % 2 == 0 && k > 0) {
                System.out.print(arr[i] - 1);
                k--;
            } else {
                System.out.print(arr[i]);
            }
            System.out.print(" ");
        }
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder res = new StringBuilder();
        int n = sc.nextInt(), m = sc.nextInt();
        res.append(sc.next());
        for (int i = 1; i < 2*n+1; i++) {
            if(i%2==0 || m==0)
                res.append(String.format(" %d", sc.nextInt()));
            else {
                res.append(String.format(" %d", sc.nextInt()-1));
                m--;
            }

        }

        System.out.println(res);
    }

}


import java.util.Scanner;

public class CF218_D2_A_MountainScenery {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder res = new StringBuilder();
        int n = sc.nextInt(), m = sc.nextInt();
        int[] r = new int[2*n+1];
        for (int i = 0; i < r.length; i++) {
            r[i]=sc.nextInt();
        }

        res.append(r[0]);
        for (int i = 1; i < r.length; i++) {
            if(i%2==1 && m>0 && r[i]>r[i-1]+1 && r[i]>r[i+1]+1) {
                m--;
                r[i]--;
            }
            res.append(String.format(" %d", r[i]));
        }

        System.out.println(res);
    }

}


import java.util.*;
import static java.lang.Math.*;
import static java.lang.System.*;

import java.math.BigInteger;
import java.util.stream.*;
public class Main
{
    public static void main(String[] args)
    {
    	Scanner in = new Scanner(System.in);
int n = in.nextInt(),k = in.nextInt();
int [] a = new int[2*n+1];a[0] = in.nextInt();
for (int i = 0; i < a.length; i++) {
	a[i] = in.nextInt();
}int ans = 0;
for (int i=1; i<=2*n+1; i++){
    if (i%2==0 && a[i]-1>a[i-1] && a[i]-1>a[i+1]){
        ans++;
        a[i]=a[i]-1;
    }
    if (ans==k) break;
}
for (int i = 0; i < a.length; i++) {
	if(i == a.length-1) {
		System.out.println(a[i]);
	}else
	    System.out.print(a[i]+" ");
}

}}


import java.util.*;
import static java.lang.Math.*;
import static java.lang.System.*;

import java.math.BigInteger;
import java.util.stream.*;
public class Main
{
    public static void main(String[] args)
    {
    	Scanner in = new Scanner(System.in);
int n = in.nextInt(),k = in.nextInt();
int [] a = new int[2*n+1];int [] b = new int[2*n+1];
for (int i = 0; i < a.length; i++) {
	a[i] = in.nextInt();b[i] = a[i];
}
Arrays.sort(b);
int max = b[b.length-1];int y =0;
for (int i = a.length-1; i >= 0; i--) {
	if(a[i] == max) {
		a[i]--;y++;
	}if( y == k) {break;}
}
for (int i = 0; i < a.length; i++) {
	if(i == a.length-1) {
		System.out.println(a[i]);
	}else
	    System.out.print(a[i]+" ");
}

}}


import java.util.Scanner;
public class MountainScenery {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n,k;int [] r = new int[201];
n = input.nextInt(); k = input.nextInt();
for (int i = 1; i <= n*2; i+=2) {
	r[i] = input.nextInt();
	r[i+1] = input.nextInt();
	if (k > 0 && r[i] > r[i-1] + 1 && r[i] > r[i+1] + 1)
    {
        k -= 1;
        r[i] -= 1;
    }
}
System.out.print(r[0]);
for (int i = 1; i <= n*2; i++) {
	System.out.print(r[i]);
	if(i == n*2) {
		System.out.println();
	}
}

}
}


import java.util.Scanner;
public class MountainScenery {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n,k;int [] r = new int[201];
n = input.nextInt(); k = input.nextInt();r[0] = input.nextInt();
for (int i = 1; i <= n*2; i+=2) {
	r[i] = input.nextInt();
	r[i+1] = input.nextInt();
	if (k > 0 && r[i] > r[i-1] + 1 && r[i] > r[i+1] + 1)
    {
        k -= 1;
        r[i] -= 1;
    }
}
System.out.print(r[0]+" ");
for (int i = 1; i <= n*2; ++i) {
	if(i == n*2) {
		System.out.println(r[i]);
	}
	System.out.print(r[i]+" ");

}

}
}


import java.util.Scanner;
public class MountainScenery {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n,k;int [] r = new int[201];
n = input.nextInt(); k = input.nextInt();
for (int i = 1; i <= n*2; i+=2) {
	r[i] = input.nextInt();
	r[i+1] = input.nextInt();
	if (k > 0 && r[i] > r[i-1] + 1 && r[i] > r[i+1] + 1)
    {
        k -= 1;
        r[i] -= 1;
    }
}
System.out.print(r[0]+" ");
for (int i = 1; i <= n*2; i++) {
	System.out.print(r[i]+" ");
	if(i == n*2) {
		System.out.println();
	}
}

}
}


import java.util.Scanner;
public class MountainScenery {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n,k;int [] r = new int[201];
n = input.nextInt(); k = input.nextInt();r[0] = input.nextInt();
for (int i = 1; i <= n*2; i+=2) {
	r[i] = input.nextInt();
	r[i+1] = input.nextInt();
	if (k > 0 && r[i] > (r[i-1] + 1) && r[i] > (r[i+1] + 1))
    {
        k -= 1;
        r[i] -= 1;
    }
}
System.out.print(r[0]+" ");
for (int i = 1; i <= n*2; ++i) {
	if(i == n*2) {
		System.out.println(r[i]);
	}
	else
	System.out.print(r[i]+" ");

}

}
}


import java.util.Scanner;
public class MountainScenery {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n,k;int [] r = new int[201];
n = input.nextInt(); k = input.nextInt();r[0] = input.nextInt();
for (int i = 1; i <= n*2; i+=2) {
	r[i] = input.nextInt();
	r[i+1] = input.nextInt();
	if (k > 0 && r[i] > (r[i-1]) && r[i] > (r[i+1]))
    {
        k -= 1;
        r[i] -= 1;
    }
}
System.out.print(r[0]+" ");
for (int i = 1; i <= n*2; ++i) {
	if(i == n*2) {
		System.out.println(r[i]);
	}
	else
	System.out.print(r[i]+" ");

}

}
}


import java.util.*;
import static java.lang.Math.*;
import static java.lang.System.*;

import java.math.BigInteger;
import java.util.stream.*;
public class Main
{
    public static void main(String[] args)
    {
    	Scanner in = new Scanner(System.in);
int n = in.nextInt(),k = in.nextInt();
int [] a = new int[2*n+1];a[0] = in.nextInt();
for (int i = 1; i < a.length; i+=2) {
	a[i] = in.nextInt();a[i+1] = in.nextInt();
	if(k>0 &&a[i]-1 > a[i-1] && a[i]-1 > a[i+1]) {
		a[i] = a[i]-1;k--;
	}
}

for (int i = 0; i < a.length; i++) {
	if(i == a.length-1) {
		System.out.println(a[i]);
	}else
	    System.out.print(a[i]+" ");
}

}}


//package javaapplication268;

//import java.util.HashSet;
//import java.util.ArrayList;
import java.util.Scanner;

public class JavaApplication268 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int[] arr = new int[2 * n + 2];
        for(int i = 1; i< arr.length; i++)
            arr[i] = s.nextInt();
        int[] a2 = arr;
        for(int i = 1; i< a2.length; i++){
            a2[i]=arr[i];
        }
        int i = 2;
        int count = 0;
        while(count<k){
            a2[i]--;
            i+=2;
            count++;
        }
        for(int j = 1; j< a2.length; j++)
            System.out.print(a2[j] + " ");
    }
}


//package javaapplication268;

//import java.util.HashSet;
//import java.util.ArrayList;
import java.util.Scanner;

public class JavaApplication268 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int[] arr = new int[2 * n + 2];
        for(int i = 1; i< arr.length; i++)
            arr[i] = s.nextInt();
        int[] a2 = arr;
        for(int i = 1; i< a2.length; i++){
            a2[i]=arr[i];
        }
        int i = 2;
        int count = 0;
        while(count<k){
            if(arr[i]-arr[i-1]!=1){
            a2[i]--;
            count++;
            }
            i+=2;

        }
        for(int j = 1; j< a2.length; j++)
            System.out.print(a2[j] + " ");
    }
}


//package javaapplication268;

//import java.util.HashSet;
//import java.util.ArrayList;
import java.util.Scanner;

public class JavaApplication268 {
    static boolean isPeak (int i , int[]arr){
        if(Math.abs(arr[i]-arr[i-1])!=1&&Math.abs(arr[i+1]-arr[i])!=1)
            return true;
        return false;
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int[] arr = new int[2 * n + 2];
        for(int i = 1; i< arr.length; i++)
            arr[i] = s.nextInt();
        int[] a2 = arr;
        for(int i = 1; i< a2.length; i++){
            a2[i]=arr[i];
        }
        int i = 2;
        int count = 0;
        while(count<k){
           // System.out.println(isPeak(i,arr));
            if(isPeak(i,arr)){
             a2[i]--;
             count++;
            }
            i+=2;

        }
        for(int j = 1; j< a2.length; j++)
            System.out.print(a2[j] + " ");
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
public class test
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new	InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}

int nextInt()
{
return Integer.parseInt(next());
}

long nextLong()
{
return Long.parseLong(next());
}

double nextDouble()
{
return Double.parseDouble(next());
		 }

		String nextLine()
		 {
String str = "";
			 try
			{
				 str = br.readLine();
			 }
			 catch (IOException e)
			 {
				 e.printStackTrace();
			 }
			 return str;
		 }
	 }

	 public static void main(String[] args){
		 FastReader scan=new FastReader();
		 int n = scan.nextInt();
		 int k = scan.nextInt();
		 int[] arr = new int[203];
		 for(int i=0;i<(2*n)+1;i++)arr[i] = scan.nextInt();
		 for(int i=1;i<(2*n)+1;i+=2){
			if(k!=0 && arr[i] > arr[i-1]+1 && arr[i] > arr[i+1]+1){
			arr[i]--;
			k--;
			}

			}
			for(int i=0;i<(2*n)+1;i++)System.out.print(arr[i] + " ");
   }
}


import java.util.*;
import java.io.*;

public class Div2_134A {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt(), k = sc.nextInt();
		int[] array = new int[2 * n + 1];
		for(int i = 0; i <= 2 * n; i++)
			array[i] = sc.nextInt();

		for(int i = 1; i < 2 * n + 1; i += 2) {
			if(k == 0)
				break;
			if(array[i] > array[i - 1] + 1 && array[i] > array[i + 1] + 1) {
				array[i]--;
				k--;
			}
		}

		for(int i = 0; i < 2 * n + 1; i++)
			System.out.print(array[i] + (i == 2 * n ? "\n" : " "));
	}
}


import java.util.*;
public class Prob34{

    public static void main(String args[]){

        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        Vector<Integer> v = new Vector<>();

        for(int i=0;i<((2*n)+1);i++){
            int val = s.nextInt();
            v.add(val);

        }

        for(int i=0;i<v.size();i++){
            if(i==0){
                continue;
            }

            if((i+1)%2 == 0){
                    if(v.get(i-1)<v.get(i) && v.get(i)>v.get(i+1)){
                        v.set(i, (int)v.get(i)-1);
                        k--;
                    }

            }

            if(k == 0){
                break;
            }

        }
        for(int i=0;i<v.size();i++){
            System.out.print(v.get(i)+" ");
        }
    }
}


import java.util.*;
public class Prob34{

    public static void main(String args[]){

        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        Vector<Integer> v = new Vector<>();

        for(int i=0;i<((2*n)+1);i++){
            int val = s.nextInt();
            v.add(val);

        }

        for(int i=0;i<v.size();i++){
            if(i==0){
                continue;
            }

            if((i+1)%2 == 0){
                    if(v.get(i-1)<(v.get(i)-1) && (v.get(i)-1)>v.get(i+1)){
                        v.set(i, (int)v.get(i)-1);
                        k--;
                    }

            }

            if(k == 0){
                break;
            }

        }
        for(int i=0;i<v.size();i++){
            System.out.print(v.get(i)+" ");
        }
    }
}


import java.util.*;
public class Prob34{

    public static void main(String args[]){

        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        Vector<Integer> v = new Vector<>();

        for(int i=0;i<((2*n)+1);i++){
            int val = s.nextInt();
            v.add(val);

        }

        for(int i=0;i<v.size();i++){
            if(i==0){
                continue;
            }
            if(k != 0){
                if((i+1)%2 == 0){
                    v.set(i, (int)v.get(i)-1);
                    k--;
                }

            }
            if(k == 0){
                break;
            }

        }
        for(int i=0;i<v.size();i++){
            System.out.print(v.get(i)+" ");
        }
    }
}


import com.sun.security.jgss.GSSUtil;

import java.io.*;
import java.lang.reflect.Array;
import java.nio.Buffer;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Pair {

    public static void main(String[] args) throws Exception {
        try {
            Scanner sc= new Scanner(System.in);
            int n = sc.nextInt();
            int k = sc.nextInt();
            int arr[]=new int[2*n+1];
            for(int i=0;i<arr.length;i++){
                arr[i] = sc.nextInt();
            }
            for(int i=1;i<2*n;i+=2){
                if(k>0 && arr[i-1]<arr[i]-1 && arr[i]-1 > arr[i+1]){
                    arr[i]--;
                    k--;
                }
            }
            for(int i=0;i<arr.length;i++){
                System.out.print(arr[i]+" ");
            }

        }
        catch (Exception e) {
        }
    }
}


import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt(), k = sc.nextInt(), a[] = new int[n * 2 + 1];
		for(int i = 0; i < n * 2 + 1; ++i)
			a[i] = sc.nextInt();
		for(int i = 1; i < n * 2 + 1 && k > 0; i += 2)
			if(a[i] > a[i - 1] + 1 && a[i] > a[i + 1] + 1)
			{
				--k;
				--a[i];
			}
		for(int x: a)
			out.print(x + " ");
		out.close();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public Scanner(String s) throws FileNotFoundException {	br = new BufferedReader(new FileReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }

		public boolean ready() throws IOException {return br.ready();}
	}
}