The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≤ aij ≤ 100) separated by single spaces — the elements of the given matrix. The input limitations for getting 30 points are:    1 ≤ n ≤ 5  The input limitations for getting 100 points are:   1 ≤ n ≤ 101

Print a single integer — the sum of good matrix elements.

NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.

#include <stdio.h>
#include <math.h>
int main() {

  int l;
  scanf("%d",&l);
  int cln[l][l];
  for(int xl = 0; xl < l; xl++){
    for(int cl = 0; cl < l; cl++){
      scanf("%d",&cln[xl][cl]);
    }
  }

  int sum = 0;
  int mid = (l - 1) / 2;

  for(int xl=0,cl=l-1; xl<l; xl++,cl--){
    if(cln[xl][mid]!=-10){
      sum += cln[xl][mid];
      cln[xl][mid] = -10;
    }
    if(cln[mid][xl]!=-10){
      sum += cln[mid][xl];
      cln[mid][xl];
    }
    // middle value input done
    if(cln[xl][xl]!=-10){
      sum += cln[xl][xl];
      cln[xl][xl] = -10;
    }

    if(cln[xl][cl]!=-10){
      sum += cln[xl][cl];
      cln[xl][cl] = -10;
    }
  }

  /*
  for(int xl = 0,cl = l - 1; xl < l; xl++,cl--){
    if(cln[xl][cl]!=-10){
      sum += cln[xl][cl];
      cln[xl][cl] = -10;
    }
  }

  */
  // printing
  printf("%d\n",sum);
  return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<list>
#include<cmath>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int** ary = new int* [N];
    for (int i = 0; i < N; ++i)
        ary[i] = new int[N];

    // fill
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
            cin>>ary[i][j];
    int mid = N / 2 ;
    int sum = 0;
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
        {
            if (i == j||i==mid||j==mid)
                sum += ary[i][j];
            else if ((i + j) == (N - 1))
                sum += ary[i][j];
        }
    cout << sum;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,numero,suma=0 ;
  cin>>n ;
  int matrix[n][n][2];
  for (int j=0 ; j<n ; j++)for(int i=0 ; i<n ; i++)for(int k=0 ; k<2 ; k++)matrix[j][i][k]=0;
  for (int j=0 ; j<n ; j++)for ( int i=0 ; i<n ; i++){cin>>numero;matrix[j][i][0]=numero;}
  for (int i=0 ; i<n ; i++)matrix[i][i][1]=1;
  for (int i=n-1 ; i>=0 ; i--)matrix[n-1-i][i][1]=1;

  int medio= (n-1)/2;
  for (int i=0;i<n; i++ )matrix[medio][i][1]=1;
  for (int j=0;j<n; j++ )matrix[j][medio][1]=1;

  for (int j=0 ; j<n ; j++)for ( int i=0 ; i<n ; i++){
    if (matrix[j][i][1]==1) suma+=matrix[j][i][0];
  }
  cout << suma;
}

// Template begins

#pragma comment (linker, "/STACK:214721677")
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <ctime>

using namespace std;

#define REP(i,n) for (int i=0, _n=(n)-1; i <= _n; ++i)
#define REPD(i,n) for (int i=(n)-1; i >= 0; --i)
#define FOR(i,a,b) for (int i=(a), _b=(b); i <= _b; ++i)
#define FORD(i,a,b) for (int i=(a), _b=(b); i >= _b; --i)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define sz(a) ((int) ((a).size()))
template < class T > T sqr (T a) { return (a) * (a); }
template < class T > T abs (T a) { return (a < 0) ? -(a) : (a); }
const double Pi = acos(-1.0);
const double eps = 1e-10;
const int INF = 1000*1000*1000;
const double phi = 0.5 + sqrt(1.25);
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <double, double> pdd;

// Template ends

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int sum = 0, n, temp;
    scanf("%d", &n);

    REP(i, n)
        REP(j, n) {
            scanf("%d", &temp);
            if (i == j || i == n - 1 - j || i == n/2 || j == n/2)
                sum += temp;
        }

    printf("%d\n", sum);
    return 0;
}

#include <bits/stdc++.h>
#include <math.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define MOD 1000000007
#define PI 3.14159265358979323
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) ((a)*(a))

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, c, s = 0;
    cin >> n;
    FOR(i,0,n){
        FOR(j,0,n){
            cin >> c;
            if(i == j){
                s += c;
            }
            else if (i+j == n-1)
            {
                s += c;
            }
            else if (i == (n)/2){
                s += c;
            }
            else if (j == (n)/2){
                s += c;
            }
        }
    }
    cout << s << endl;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
        {
            int a;
            cin >> a;
            if (i == j || i == n / 2 + 1 || j == n / 2 + 1 || n - j + 1 == i)
                sum += a;
        }
    cout << sum << endl;
    return 0;
}

#include <iostream>
#include <algorithm>

using namespace std;
int m[101][101];
int main() {
    int n, sum = 0, z;
    cin >> n;
    if (n == 1) {
        cin >> sum;
        cout << sum << endl;
    }
    else {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++)
                cin >> m[i][j];
        }
        for (int i = 0; i < n; i++)
            sum += m[i][i];
        z = n - 1;
        for (int i = 0; i < n; i++) {
            sum += m[i][z];
            z--;
        }
        z = n / 2;
        for (int i = 0; i < n; i++) {
            sum += m[i][z];
            sum += m[z][i];
        }
        sum -= 3 * m[z][z];
        cout << sum << endl;
    }
    return 0;
}

#include <iostream>
using namespace std;
int main() {
	int n,x,s=0;
	cin>>n;
	for (int i=0;i<n;i++) {
		for (int j=0;j<n;j++) {
			cin>>x;
			if (i==j) {
				s+=x;
			}
			if (i==n/2) {s+=x;}
			if (j==n/2) {s+=x;}
			if (i==n-j-1) {s+=x;}
			if (n-j-1==i && i==j)  {
				s-=3*x;
			}
		}
	}
	cout<<s;
	return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int n;
    while(cin>>n){
        int a[n+1][n+1],s=0;//  1<=n<=101

        for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
        cin>>a[i][j];

        for(int i=0;i<n;i++){
            s+=a[i][i];
            s+=a[i][n-i-1];
            s+=a[i][n/2];
            s+=a[n/2][i];
        }
        /*
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++)
            cout<<a[i][j]<<" ";
            cout<<endl;
        }
        */

        s=s-3*a[n/2][n/2];
        cout<<s<<endl;
    }

    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <functional>
using namespace std;

typedef long long _ll;
typedef vector<int> _vi;
typedef vector<_ll> _vll;
typedef vector<string> _vs;
typedef istringstream _iss;
#define _a(v) (v).begin(),(v).end()
#define _e(x,y) (fabs((x)-(y))<1e-10)
#define _p push_back
#define _mp make_pair
#define _m(v) memset(v,0,sizeof(v));
#define _f(i,b,e) for(int i=b;i<e;i++)
#define _fs(i,n) for(int i=0;i<(n).size();i++)
#define _fsit(type, sit, ss) for(set<type>::iterator sit=ss.begin(); sit!=ss.end(); sit++)
#define _fmit(t1, t2, mit, mm) for(map<t1, t2>::iterator mit=mm.begin(); mit!=mm.end(); mit++)
#define _fd(t,e) ((t).find(e)!=(t).end())
#define _sw(x, y, t) {t __t_; __t_=x;x=y;y=__t_;}

int marr[200][200];
int main()
{
    int n;
    _m(marr);

    int ret = 0;
    cin>>n;
    _f(i, 0, n)
        _f(j, 0, n)
            cin>>marr[i][j];

    if(n==1)
    {
        cout<<marr[0][0]<<endl;
        return 0;
    }

    int mid = n/2;
    _f(i, 0, n)
    {
        ret += marr[i][i];
        ret += marr[n-i-1][i];
        ret += marr[mid][i];
        ret += marr[i][mid];
    }

    ret -= 3*marr[mid][mid];
    cout<<ret<<endl;

    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <sstream>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>
#include <ctime>
#include <assert.h>
#include <string.h>
#include <limits>
using namespace std;

#define INF 100000000
#define PI 3.1415926535897932384626433832795
#define PI_HALF 1.570796327
#define EPS 1e-9

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair< int, int > PII;
typedef pair< LL, LL > PLL;
typedef vector< int > VI;
typedef vector< LL > VLL;
typedef vector< string > VS;
typedef vector< PII > VPII;
typedef vector< PLL > VPLL;

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define SZ(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort( ALL( c ) )
#define SORT_(c,f) sort( ALL( c ), f )
#define FILL(x,v) memset( x, v, sizeof( x ) );

#define REP(i,n) for ( int i = 0, max_ = (n); i < max_; ++i )
#define REPD(i,n) for ( int i = (n) - 1; i >= 0; --i )
#define FOR(i,a,b) for ( int i = (a), max_ = (b); i < max_; ++i )
#define FORD(i,a,b) for ( int i = (a) - 1, min_ = (b); i >= min_; --i )

int ToInt ( string & s, int len ) { int r = 0; REP(i,len) { r *= 10; r += s[i] - '0'; } return r; }
int GCD ( int a, int b ) { return b != 0 ? GCD(b, a % b) : a; }
int LCM ( int a, int b ) { return a*(b / GCD(a,b)); }
LL Pow ( LL n, LL e ) { if ( e == 0 ) return 1; if ( e == 1 ) return n; else if ( e & 1 ) { LL t = Pow(n,e/2); return n*t*t; } else { LL t = Pow(n,e/2); return t*t; } }

int m[ 101 ][ 101 ];

int main ()
{
    int N;
    scanf( "%d", &N );
    REP(i,N) REP(j,N) scanf( "%d", &m[ i ][ j ] );

    int res = 0;
    REP(i,N)
    {
        res += m[ i ][ i ];
        m[ i ][ i ] = 0;
        res += m[ i ][ N - 1 - i ];
        m[ i ][ N - i - 1 ] = 0;
    }

    int c = N / 2;
    REP(i,N)
    {
        res += m[ i ][ c ];
        m[ i ][ c ] = 0;
        res += m[ c ][ i ];
        m[ c ][ i ] = 0;
    }
    printf( "%d\n", res );

    return 0;
}

#include <iostream>
#include <cstdlib>
#include <cstdio>

using namespace std;

int main() {
// kak zhe ya zaebalsya
	int a, d, s=0,n,i,j;
	cin >> n;
	for (i = 0; i < n; ++i) {
		for (j = 0; j < n; ++j) {
			cin >> d;
			if (i == n / 2 || j == n / 2 || i == j || n - i == j + 1)
				s += d;
		}
	}
	cout << s;
	return 0;
}

#include <algorithm>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <functional>
#include <string>
#include <cctype>
#include <limits>

using namespace std;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef long double ld;

int main()
{
	i64 n;
	cin >> n;
	vector<vector<i64> > mapw(n, vector<i64>(n));

	for (i64 i = 0; i < n; i++)
	{
		for (i64 a = 0; a < n; a++)
		{
			cin >> mapw[i][a];
		}
	}

	ui64 res = 0;
	i64 t = n/2;
	for (i64 i = 0; i < n; i++)
	{
		res += mapw[i][i];
		res += mapw[n - i - 1][i];
		res += mapw[t][i];
		res += mapw[i][t];
	}
	res -= 3 * mapw[t][t];
	cout << res << endl;
	return 0;
}

#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<cstdio>
#include<map>
#include<queue>
#include<cmath>
#include<string>

using namespace std;
typedef long long int64;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int64 n;
	cin >> n;
	vector<vector<int64> > mat(n, vector<int64>(n));
	int64 res = 0;
	for (int64 i = 0; i < n; i++)
		for (int64 j = 0; j < n; j++)
		{
			cin >> mat[i][j];
			if (i == j || i == (n - 1) / 2 || j == (n - 1) / 2 || i == n - j - 1)
				res += mat[i][j];
		}

	cout << res;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,e;
    cin>>n;
    int a1[n][n];
    long long int s=0;
     e=((n-1)/2)+1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>a1[i][j];
            if(n==1)
            {
                cout<<a1[i][j]<<endl;
                return 0;
            }
            if(i==j){
                 if(i!=e && j!=e){
                s+=a1[i][j];
        }
            }
    }
    }

    for(int i=1;i<=n;i++)
    {
        if(i!=e){
        s+=a1[e][i];
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(i!=e){
        s+=a1[i][e];
        }
        s+=a1[i][n-i+1];
    }
cout<<s<<endl;
return 0;

}

#include <stdlib.h>
#include <iostream>

using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    int **arr = new int *[n] ;
    for (int i = 0; i < n; i++)
    {
        arr[i] = new int[n];

        for (int j = 0; j < n; j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }

    int nSumm = 0;
    int nLeftIndex = 0, nMidIndex = (n - 1) / 2, nRightIndex = n - 1;
    for (int i = 0; i < n; i++)
    {
        if (i == (n - 1) / 2)
        {
            for (int j = 0; j < n; j++)
                nSumm += arr[i][j];
        }
        else
        {
                nSumm += arr[i][nLeftIndex] + arr[i][nRightIndex] + arr[i][nMidIndex];
        }
        nLeftIndex++;
        nRightIndex--;
    }

    cout<<nSumm;
    for (int i = 0; i < n; i++)
    {
        delete [] arr[i];
    }
    delete [] arr;

    return 0;
}

#include <iostream>

using namespace std;

const int MAXN = 105;
int a[MAXN][MAXN];
bool hit[MAXN][MAXN];
int ans = 0;

void place(int x, int y)
{
    if (!hit[x][y])
    {
        ans += a[x][y];
        hit[x][y] = true;
    }
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    int k = (n - 1) / 2;
    for (int i = 0; i < n; i++)
    {
        place(k, i);
        place(i, k);
        place(i, n - 1 - i);
        place(i, i);
    }
    cout << ans << "\n";
    return 0;
}

#include <iostream>
#include <sstream>
#include <bitset>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <numeric>
#define FOR(i,A) for(typeof (A).begin() i = (A).begin() ; i != (A).end() ; i++)
#define mp make_pair
#define clr(v,x) memset( v, x , sizeof v )
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define TAM 110

using namespace std;

typedef pair<int,int> ii ;
typedef long long ll ;
typedef pair<int,ii> pii ;

int main(){

    int n ;
    scanf("%d" , &n ) ;
    int g[ n ][ n ] ;
    for(int i = 0 ; i < n ; i++) for(int j = 0 ; j < n ; j++) scanf("%d" , &g[ i ][ j ] ) ;

    int mid = n / 2 ;
    bool v[ n ][ n ] ;
    clr( v , 0 ) ;
    for(int i = 0 ; i < n ; i++){
        v[ mid ][ i ] = v[ i ][ mid ] = true ;
        v[ i ][ i ] = v[ n - i - 1 ][ i ] = true ;
    }

//  for(int i = 0 ; i < n ; i++) for(int j = 0 ; j < n ; j++) if( v[ i ][ j ] ) printf("( %d , %d )\n" , i , j ) ;

    int resp = 0 ;
    for(int i = 0 ; i < n ; i++) for(int j = 0 ; j < n ; j++) if( v[ i ][ j ] ) resp += g[ i ][ j ] ;

    printf("%d\n" , resp ) ;

    return 0 ;
}

/*Bishmillahir Rahmanir Rahim*/
#include <bits/stdc++.h>
#define AmX ios_base::sync_with_stdio();cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define sp ' '
#define vi vector<int>
#define pb push_back
#define f(i,n) for(i=1;i<=n;i++)
using namespace std;

int main()
{
   int n,a,i,j,s=0,m;
    vi v;
    cin>>n;
    m=n/2+1;
    for(i=1 ; i<=n ; i++)
    {
        for(j=1 ; j<=n ; j++)
        {
            cin>>a;
            if(i==j||(i+j)-1==n||i==m||j==m)
                 s+=a;
        }

    }

    cout<<s<<endl;

}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>

#define int long long
#define ld long double

using namespace std;

void solve() {
	int n, ans = 0;
	cin >> n;
	int map[105][105];
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			cin >> map[i][j];
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j || i + j == n - 1 || i == n / 2 || j == n / 2) {
				ans += map[i][j];
			}
		}
	}
	cout << ans;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	solve();
	return 0;
}

#include<stdio.h>
int n,t,sum;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            scanf("%d",&t);
            if(i==j||n-1-i==j||i==(n-1)/2||j==(n-1)/2)
                sum+=t;
        }
    }
    printf("%d\n",sum);
    return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

int n;
int ans = 0;
int g[101][101];

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                    scanf("%d", &g[i][j]);
            }
    }

    for(int i = 0; i < n; i++) {
            ans += g[n / 2][i];
            ans += g[i][n / 2];
            ans += g[i][i];
            ans += g[i][n - 1 - i];
    }

    printf("%d", ans - 3 * g[n / 2][n / 2]);

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin>>n;
    int a[n][n],s=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
            if(i==n/2||j==n/2||i==j||i==n-1-j)
            {
                s+=a[i][j];
            }

        }
    }cout<<s;
	return 0;
}

#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstdio>
#include <vector>
#include <list>
#include <map>
#include <set>
using namespace std;

int main()
{
	int n, t=0, a[102][102];
	cin>>n;
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
		{
			cin>>a[i][j];
		}
	}
	for (int k=0; k<n; k++)
	{
		t=t+a[(n-1)/2][k]+a[k][(n-1)/2]+a[k][k]+a[n-k-1][0+k];
	}
	t=t-(3*a[(n-1)/2][(n-1)/2]);
	cout<<t<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[101][101];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }

    int total=0;
    for(int i=0;i<n;i++)
    {
        total=total+a[i][i];

    }
    //cout<<total<<endl;
    int middle=a[n/2][n/2];
    for(int i=0;i<n;i++)
    {

        total=total+a[i][n-1-i];

    }
    total=total-middle;
   // cout<<total<<endl;
    int middlenum=n/2;

    for(int i=0;i<n;i++)
    {
        total=total+a[middlenum][i];
    }
    total=total-middle;
    //cout<<total<<endl;
    for(int i=0;i<n;i++)
    {
        total=total+a[i][middlenum];
    }
    total=total-middle;

    cout<<total;

}

// Teams Forming - CodeForces
// https://codeforces.com/problemset/problem/769/A

#include<bits/stdc++.h>
using namespace std;

#define MAX 101
#define ll long long

int main(){

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);
	cout.tie(NULL);

	ll n;
	cin >> n;

	ll a[n][n];
	ll diag1 = 0, diag2 = 0, mid_row = 0, mid_col = 0;

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
			cin >> a[i][j];
	}

	for(int i=0;i<n;i++){
		diag1 += a[i][i];
		diag2 += a[i][n-i-1];
		mid_row += a[n/2][i];
		mid_col += a[i][n/2];
	}
	cout << diag1 + diag2 + mid_col + mid_row - 3 * a[n/2][n/2] << endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
  long n ;
  cin >> n;
  long ans = 0;
  if(n == 1){
      cin >> ans;
      cout << ans << endl ;
      return 0;
  }
  long t = 0;
  set<long> s;
  long a = 0 , b = 0, c = 0, d = 0;
  // second diagonal
  while(a<(n*n)){
      s.insert(a);
      a += (n-1);
  }

  b = n / 2;
  // middle row
  while(b<(n*n)){
      s.insert(b);
      b += n;
  }
  a = n / 2;
  a *= n;
  // middle column
  for (long i = 0; i < n;i++){
      s.insert(a+i);
  }
  // main diagonal
  for (long i = 1; i < n;i++){
      d += n + 1;
      s.insert(d);
  }
  long p = 0 , r = 0 ;

  for (long i = 0 ; i < n*n ; i++){
      cin >> t;
      if(i == p){
          ans += t;
          s.erase(i);
          auto itr = s.begin();
          p = *itr;
      }
  }
  cout << ans << endl ;

  return 0;

}

#include<iostream>
using namespace std;
int main()
{
    int n,a,sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a;
            if(i==j || i==n/2 || j==n/2 || i==n-1-j)
                sum+=a;
        }
    }
    cout<<sum<<endl;
    return 0;
}
//hellobig_tq//hellobig_tq

#include <iostream>
using namespace std;
int n,m,s,x,i,j;
int main()
{
    cin>>n;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        {
            cin>>x;
            if ((i==j)||(n-j==i+1)||(i==n/2)||(j==n/2))
                s+=x;
        }
    cout<<s<<endl;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{int y,count=0;
cin>>y;
int x[y][y];
    for(int i=0;i<y;i++){
        for(int j=0;j<y;j++){
        cin>>x[i][j];

        if (i==j || i==((y-1)/2) || j==((y-1)/2) || i==y-1-j)
            count+=x[i][j];
        }

}
cout<<count;

    return 0;

}

#include<bits\stdc++.h>
using namespace std;
int main()
{
    long long n,i,a,s=0,q=0,j;
    cin>>n;
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                cin>>a;
                 if((i==j)||(i== n-1-j)||i==(n - 1)/2||j==(n - 1)/2)
                 {
                     s+=a;
                 }
            }
        }
        cout<<s<<endl;

}

#include<bits/stdc++.h>
#define eps 1e-8
#define ll long long
#define ed cout<<endl
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define ll long long
#define se second
#define inf 2e9
#define sz 456789
#define all(x) x.begin(), x.end()
#define pi 3.14159265359
using namespace std;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int q, n, k, ar[1234][1234], br[sz], x, y, z, maxx, a, b, c, d, sum;
string s, t;
bool ok;

void dii(){

    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> ar[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        sum += ar[i][i];
        sum += ar[i][n - i - 1];
        sum += ar[i][n / 2];
        sum += ar[n / 2][i];
    }
    sum -= (3 * ar[n / 2][n / 2]);
    cout << sum;
}

int main(){

    faster();

    q = 1;
    // cin >> q;
    while(q--){
        dii();
    }

    return 0;
}

//http://codeforces.com/problemset/problem/177/A1

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <list>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef vector <int> vi;
typedef long long ll;

#define endl "\n"
#define mp make_pair

int n;
int result = 0;

int main()
{
	int ii, jj;
	int a;

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;

	for (ii = 1; ii <= n; ii++)
	{
		for (jj = 1; jj <= n; jj++)
		{
			cin >> a;

			if (ii == ((n / 2) + 1))
				result += a;
			else if (jj == ((n / 2) + 1))
				result += a;
			else if (ii == jj)
				result += a;
			else if (ii == (n - jj + 1))
				result += a;
		}
	}
	cout << result << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum1=0,sum2=0,sum3=0,sum4=0;
    cin>>n;
    int a[n][n];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
          cin>>a[i][j];
    }
    for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
      {
          if(i==j)sum1+=a[i][j];                  //first diagonal
          if(i==n-j-1)sum2+=a[i][j];                //second diagonal
          if(i==(n-1)/2)sum3+=a[i][j];              //middle row
         if(j==(n-1)/2)sum4+=a[i][j];              //middle column
      }
    }
    //cout<<sum1<<" "<<sum2<<" "<<sum3<<" "<<sum4<<endl;
    cout<<(sum1+sum2+sum3+sum4)-(3*(a[(n-1)/2][(n-1)/2]))<<endl;    //3*a[mid][mid]
}
      //Alhamdulilla..

#include <bits/stdc++.h>
using namespace std;
int main()
{
   long long n;
    cin>>n;
    long long arr[n][n];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>arr[i][j];
        }
    }
    long long sum=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j)
            {
                sum+=arr[i][j];
                continue;
            }
            if(i==n-1-j)
            {
                sum+=arr[i][j];
                continue;
            }
            if(i==(n-1)/2)
            {
                sum+=arr[i][j];
                continue;
            }
            if(j==(n-1)/2)
            {
                  sum+=arr[i][j];
                continue;
            }
        }
    }
    cout<<sum<<endl;
}

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
int n;
int mat[101][101];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n;
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            cin >> mat[i][j];
        }
    }
    ll res =0 ;
    for(int i=0;i<n;++i){
        res+=mat[i][i];
        res+=mat[i][n-i-1];
        res+=mat[i][(n-1)/2]+ mat[(n-1)/2][i];
    }
    if(n == 1) res=mat[0][0];
    else res-= 3*mat[(n-1)/2][(n-1)/2];
    cout << res;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main () {
      int n, x;
      cin >> n;
      int a[n][n];
      for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                  cin >> x;
                  a[i][j] = x;
            }
      }
      int sum = 0;
      for (int i=0, j=0; i<n, j<n; i++, j++) {
            sum += a[i][j];
      }
      for (int i=0, j=n-1; i<n, j>=0; i++, j--) {
            sum += a[i][j];
      }
      for (int i=0; i<n; i++) {
            sum += a[i][n/2];
            sum += a[n/2][i];
      }
      cout << sum - (a[n/2][n/2] * 3) << endl;
      return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int i,j,n,q,a[110][120],s,m;

int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            cin>>a[i][j];
        }
    }
    i=1;
    j=1;
    while(i<=n)
    {
        s+=a[i][j];
        i++;
        j++;
    }
    i=n;j=1;
    while(j<=n)
    {
        s+=a[i][j];
        j++;
        i--;
    }
    j=(n+1)/2;
    for(i=1;i<=n;i++)
    {
        s+=a[j][i];
    }
    for(i=1;i<=n;i++)
    {
        s+=a[i][j];
    }
    s-=3*a[j][j];
    cout<<s<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
  /*  freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    long n,res = 0,l = 0,dia = 0,k = 1;
    cin >> n;
    long sq[n+1][n+1];
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < n;j++)
        {
            //sq[i][j] = k;
          //  k++;
         // cout << sq[i][j] << " ";
          cin >> sq[i][j];
        }
cout << endl;
    }
    dia = n-1;
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < n;j++)
        {
            if(n-1 - j == dia && i != n / 2)
                {res += sq[i][j];
               // cout << sq[i][j] << " ";
               }
                else if(dia - j == 0 && i != n / 2)
                {
                    res += sq[i][j];
                //cout << sq[i][j] << " ";
                }

      if(i == n / 2)
    {
         l++;
        res += sq[i][j];
        //cout << sq[i][j] << " ";
    }
            if(j == n / 2 && l == 0)
                {res += sq[i][j];
               // cout << sq[i][j] << " ";
                }
        }
        l = 0;
        if(i < n/2)
            dia-- ;
        else
            dia++;
    }
cout << res;
    }

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,sum=0;
	cin>>n;

	int a;

	for(int i=0;i<n;i++){
	   for(int j=0;j<n;j++)
	   {
	   	cin>>a;
	       if(i==j || i==(n-j-1)||i==n/2||j==n/2)sum+=a;
	   }
}

	cout<<sum;

}

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int> > v(n + 1,vector<int>(n + 1,0));

    long long psum = 0, nsum = 0;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            int x;
            cin >> x;
            v[i][j] = x;
            psum +=x;
        }
    }

    //first and last even row
    for(int i = 2; i <= n - 1; i++){
        if(i % 2 == 0 && i != (n + 1) / 2){
            nsum += v[1][i];
            nsum += v[n][i];
        }
    }

    ////first and last even col
    for(int i = 2; i <= n - 1; i++){
        if(i % 2 == 0 && i != (n + 1) / 2){
            nsum += v[i][1];
            nsum += v[i][n];
        }
    }

    cout << (psum - nsum) << endl;

    return 0;
}

#include <bits/stdc++.h>

const double eps = 1e-8;
const int oo = 0x3f3f3f3f;

typedef long long ll;
using namespace std;

#define fr(a,b,c) for(int a = b; a < c; a++)
#define rep(a,b) fr(a,0,b)
#define ln printf("\n")
#define db if(1)
#define dbs(x) db rep(i,x) printf(" "); db
#define pb push_back
#define mem(r,v) memset(r, v, sizeof r)

int n;
int mat[101][101];

bool read(){
    if(!(cin >> n)) return false;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        cin >> mat[i][j];
      }
    }
    return true;
}

void process(){
    int counter = 0;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
       if(i == j || i + j == n-1 || i == n/2 || j == n/2){
          counter += mat[i][j];
        }
      }
    }
    cout << counter << '\n';
}

int main(){
    int t = -1;
    //scanf("%d", &t);

    while(t-- && read()){
        process();
    }

    return 0;
}

#include<iostream>
#include<math.h>
#include<algorithm>
#include<fstream>
#include<string>
#include<map>
#include<math.h>
#include<vector>
#include <stdio.h>
#include <string.h>
#include<list>
#include <set>
using namespace std;
ofstream fo("output.txt");
ifstream fi("input.txt");
const int Max = 1e2 + 10;
char ch[Max];
#define N 10001
int bucket[N];
string str1[17] = { "purple", "green", "blue", "orange", "red", "yellow" }, str2[17] = { "Power", "Time", "Space", "Soul", "Reality", "Mind" }, tmp;
bool vis[17];
int a[3];
const long long MAXN = 1e6 + 20;
const int MAXSIZE = 100 + 10;
bool mark[MAXN];
#define ll long long
int n, sum;
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0, a; j < n; j++)
		{
			cin >> a;
			if (i == (n - 1) / 2 || j == (n - 1) / 2 || i == j || i + j == n - 1)  sum += a;
		}
	cout << sum;
}

#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <deque>
#include <functional>
#include <utility>
#include <numeric>
#include <list>
#include <queue>
#include <climits>
#include <cstring>
#include <stack>
#include <cstdlib>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <complex>
using namespace std;

const int MAX_N = 100005;
const double EPS = 1e-9;
const int MOD = 1000007;
const int INF = 0x7fffffff;

typedef long long ll;
typedef pair <int,int> PII;

#define all(a)  a.begin(),a.end()
#define ss  second
#define ff   first
#define sqr(x)  ((x)*(x))
#define cub(x)  ((x)*(x)*(x))
#define pb  push_back
#define mp  make_pair
#define mem(f, a) memset(f, a, sizeof(f))
#define cl  clear()
#define ins insert
//#define int long long
#define dbg(x) cerr<<((#x))<<" = "<<((x))<<" "<<endl
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define fora(i,a,b) for(__typeof(a) i=(a) ; i<(b) ; i++)
#define foreach(i,n) for(__typeof((n).begin())i =(n).begin();i!=(n).end();i++)

template <class Int> inline int size (const Int &a){return (int)a.size();}

set <PII> st;
int n, arr[111][111];

void move(int x,int y,int dx,int dy)
{
    if(x < 0 || x > n || y < 0 || y > n) return ;

    st.ins(mp(x,y));
    move(x+dx,y+dy,dx,dy);
}

main() {
    ios::sync_with_stdio(false);

    cin >> n;

    rep(i,n) rep(j,n) cin >> arr[i][j];

    move(0,0,1,1);
    move(0,n/2,1,0);
    move(n/2,0,0,1);
    move(n/2,0,1,1);
    move(0,n/2,1,1);
    move(0,n-1,1,-1);

    ll ans = 0;
    foreach(it,st)
    {
        ans += (ll)(arr[it->ff][it->ss]);
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
int n,s=0,x;
int main()
{
    cin>>n;
    for(int i =0; i<n; i++)
    for(int j=0; j<n; j++)
    {
        cin>>x;
        if((i==j)||(j+1==n-i)||j==(n)/2 || i==(n)/2)
        s+=x;
    }
    cout<<s;

	return 0;
}

#include <iostream>

using namespace std;

bool check(int, int, int);

int main()
{
	int n, a, sum = 0;

	cin >> n;

	for (int x = 0; x < n; x++)
	{
		for (int y = 0; y < n; y++)
		{
			cin >> a;

			if (check(x, y, n)) sum += a;
		}
	}

	cout << sum;
	return 0;
}

bool check(int x, int y, int n)
{
	if (x == y || n - x - 1 == y || x == n / 2 || y == n / 2)
	{
		return true;
	}
	else return false;
}

#include <iostream>
#include <cstdlib>
using namespace std;

int main(){
	int n;
	long long int summ = 0, k;
	cin >> n;
	for (int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> k;
			if(i == (n - 1)/2 || j == (n - 1)/2 || i == j || i + j + 1 == n){
				summ += k;
			}
		}
	}
	cout << summ;
}

#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main()
{
	int n;
	cin>>n;
int **arr=new int*[n];
for(int i=0;i<n;i++)
	arr[i]=new int[n];
int sum=0;
for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	{
		cin>>arr[i][j];
		if(i==j||i+j==n-1||i==n/2-(1-n%2)||j==n/2-(1-n%2))
			sum+=arr[i][j];
	}
	cout<<sum;
	//system("pause");
	return 0;
}

#include <iostream>
using namespace std;
int n,m,s,x,i,j;
int main()
{
    cin>>n;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        {
            cin>>x;
            if ((i==j)||(n-j==i+1)||(i==n/2)||(j==n/2))
                s+=x;
        }
    cout<<s<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[100][100];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  int ans = a[n / 2][n / 2];
  for (int i = 0; i < n; i++) {
    if (i == n / 2)
      continue;
    ans += a[i][i];
    ans += a[i][n - i - 1];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == n / 2 && j == n / 2) {
        continue;
      } else if (i == n / 2 || j == n / 2) {
        ans += a[i][j];
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>

#define int long long
#define ld long double

using namespace std;

void solve() {
	int n, ans = 0;
	cin >> n;
	int map[105][105];
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			cin >> map[i][j];
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j || i + j == n - 1 || i == n / 2 || j == n / 2) {
				ans += map[i][j];
			}
		}
	}
	cout << ans;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	solve();
	return 0;
}

/*The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good:

Elements of the main diagonal.
Elements of the secondary diagonal.
Elements of the "middle" row — the row which has exactly  rows above it and the same number of rows below it.
Elements of the "middle" column — the column that has exactly  columns to the left of it and the same number of columns to the right of it.
The figure shows a 5 × 5 matrix. The good elements are marked with green.
Help the Smart Beaver count the sum of good elements of the given matrix.

Input
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≤ aij ≤ 100) separated by single spaces — the elements of the given matrix.

The input limitations for getting 30 points are:

1 ≤ n ≤ 5
The input limitations for getting 100 points are:

1 ≤ n ≤ 101
Output
Print a single integer — the sum of good matrix elements.

Examples
inputCopy
3
1 2 3
4 5 6
7 8 9
outputCopy
45
inputCopy
5
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
outputCopy
17
*/
#include<iostream>
using namespace  std;

int main()
{
    int i,j,n,sum1=0,sum2=0,sum3=0,sum4=0,sum=0;

    cin>>n;
    int a[5][5];
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }

    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i+j==n-1)
                sum1=sum1+a[i][j];
            if(i==j)
                sum2=sum2+a[i][j];
        }
    }
    for(i=0;i<n;i++)
    {
        sum3=sum3+a[(n-1)/2][i];
        sum4=sum4+a[i][(n-1)/2];
    }
    sum=sum1+sum2+sum3+sum4-3*a[(n-1)/2][(n-1)/2];
    cout<<sum;
    return 0;
}

#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <sstream>
#include <algorithm>
using namespace std;
#define rep(_m,s,e) for(ll _m=s;_m<e;_m++)
#define ll long long
#define li __int64
int  toInt(string s)   {int r=0; istringstream sin(s); sin>>r; return r;}
ll   toInt64(string s) {ll r=0; istringstream sin(s); sin>>r; return r;}
double  toDouble(string s){double r=0; istringstream sin(s); sin>>r; return r;}
string toString(ll n) {string s,s1; while (n / 10 > 0){ s += (char)((n%10) + 48); n/=10;} s += (char)((n%10) + 48); n/=10; s1 = s; rep(i,0,s.length()) s1[(s.length()-1)-i] = s[i]; return s1;}
bool isUpperCase(char c){return c >= 'A' && c <= 'Z';}
bool isLowerCase(char c){return c >= 'a' && c <= 'z';}
bool isLetter(char c)   {return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z';}
bool isDigit(char c)    {return c >= '0' && c <= '9';}
char toLowerCase(char c){return (isUpperCase(c))?(c + 32) : c;}
char toUpperCase(char c){return (isLowerCase(c))?(c - 32) : c;}
int main()
{
	int n,a;
	ll sum = 0;
	cin >> n;
	rep(i,1,n+1)
	{
		rep(j,1,n+1)
		{
			cin >> a;
			if (i == j || i+j == n+1 || i == (n/2)+1 || j == (n/2)+1)
				sum += a;
		}
	}
	cout << sum << endl;
}

#include<iostream>
#include<vector>
//#include<bits/stdc++.h>
//#include</Users/arav/Downloads/stdc++.h>
using namespace std;
int main()
{int i,j,n,x,sum=0;
 cin>>n;
 vector<vector<int> > v(n);
 for(i=0;i<n;i++)

    { v[i]=vector<int>(n);
      for(j=0;j<n;j++)
       {cin>>x;
        v[i][j]=x;}
    }
 for(i=0;i<n;i++)
  {sum=sum+v[i][i];}
 for(i=0;i<n;i++)
  {sum=sum+v[n-1-i][i];}
  for(i=0;i<n;i++)
   {sum=sum+v[(n-1)/2][i];}
   for(i=0;i<n;i++)
    {sum=sum+v[i][(n-1)/2];}
  sum=sum-3*(v[(n-1)/2][(n-1)/2]);
  cout<<sum;

  return 0;
 }

# include <iostream>
# include <math.h>
# include <fstream>
# include <vector>
# include <algorithm>
# include <string>
using namespace std;
//printf ("%.8lf\n", a);
// erase

# define all(a) a.begin(), a.end()
# define Sort(a) sort(all(a));
# define pause system("pause");
# define ll long long
# define VI vector <int>
# define pb push_back
# define graph vector < vector <bool> >

int main()
{
    int n, ans=0, a, x, y;
    cin>>n;

    for(int i=0; i<(n*n); i++)
    {
        cin>>a;
        x=i%n;
        y=i/n;

        if(x==(n-1)/2||y==(n-1)/2||x==y||x+y==n-1) ans+=a;
    }

    cout<<ans<<endl;
}

#include<stdio.h>
#include<conio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int arr[n][n];
	int sum=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			scanf("%d", &arr[i][j]);
			if(i==j)
			{
				sum=sum+arr[i][j];
				arr[i][j]=0;
			}
			else if(i==(n-1)/2)
			{
				sum=sum+arr[i][j];
				arr[i][j]=0;
			}
			else if(j==(n-1)/2)
			{
				sum=sum+arr[i][j];
				arr[i][j]=0;
			}
		}
	}
	for(int i=(n-1);i>=0;i--)
	{
		sum=sum+arr[n-i-1][i];
	}
	printf("%d", sum);
	return 0;
}

#include<stdio.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<string.h>

int main ()
{
    int n, s=0;
    int a[101][101];
scanf("%d", &n);

for (int i=0;i<n;i++)
{
    for (int j=0;j<n;j++)
    {
        scanf("%d",&a[i][j]);
    }
}

for (int i=0;i<n;i++)
{
    s=s+a[i][i]+a[(n-1)/2][i]+a[n-1-i][i]+a[i][(n-1)/2];
}
s=s-3*a[(n-1)/2][(n-1)/2];
printf("%d",s);
return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(){

    int T;
    cin >> T;

    int Arr[T][T];
    int Start=0, Mid=T/2, End=T-1, Result=0;

    for(int i=0; i<T; i++){
        for(int j=0; j<T; j++){
            cin >> Arr[i][j];
        }
        if(Start < Mid){
            Result += Arr[i][Start];
            Result += Arr[i][Mid];
            Result += Arr[i][End];
            Start++;
            End--;
        }
        else if(Start == Mid){
            int k=0;
            while(k!=T){
                Result += Arr[i][k];
                k++;
            }
            Start++;
            End--;
        }
        else {
            Result += Arr[i][Start];
            Result += Arr[i][Mid];
            Result += Arr[i][End];
            Start++;
            End--;
        }
    }

    cout << Result << endl;

    return 0;

}

#include<bits/stdc++.h>

typedef long long int ll;
#define pp pair<ll,ll>
#define dbg printf("f");
#define inf 1000000000000

#define max2(a,b) ((a<b)?b:a)
#define max3(a,b,c) max2(max2(a,b),c)
#define min2(a,b) ((a>b)?b:a)
#define min3(a,b,c) min2(min2(a,b),c)

using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    ll i,j,k;
    ll n,sum=0;

    cin>>n;
    ll a[n][n];

    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }

    //main diagonal
    for(i=0,j=0;i<n,j<n;i++,j++)
    {
        sum+=a[i][j];
        a[i][j]=0;
    }

    //secondary diagonal
    for(i=0,j=n-1;i<n,j>=0;i++,j--)
    {
        sum+=a[i][j];
        a[i][j]=0;
    }

    //mid row
    for(i=0;i<n;i++)
    {
        sum+=a[n/2][i];
        a[n/2][i]=0;
    }

    //mid column
    for(i=0;i<n;i++)
    {
        sum+=a[i][n/2];
        a[i][n/2]=0;
    }

    cout<<sum;

    return 0;
}

#pragma warning(disable:4996)

#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <set>
#include <vector>
#include <cassert>

using namespace std;

typedef long long int i64;
typedef vector<int> vint;
typedef vector<i64> vi64;
typedef pair<int, int> pint;

const i64 inf = 1000000000000000000LL;

#define forn(i, n) for(int i = 0; i < (n); ++i)

struct Node
{
    vint nbr;
    int used;
    int p;
    int l;
    int r;
    Node()
    {
        r = -1;
        l = 0;
        p = -1;
        used = 0;
    }
};

void dfs(vector<Node> & arr, int v, int p = -1)
{
    arr[v].used = 1;
    forn(i, arr[v].nbr.size())
    {
        int to = arr[v].nbr[i];
        if (arr[to].used && arr[to].l == 0 && to != p)
        {
            int curr = v;
            arr[to].l = 1;
            while (curr != to)
            {
                arr[curr].l = 1;
                curr = arr[curr].p;
            }
        }
        else if (arr[to].used == 0)
        {
            arr[to].p = v;
            dfs(arr, to, v);
        }
    }
}

void dfs2(vector<Node> & arr, int v, int r)
{
    arr[v].used = 1;
    if (arr[v].l == 1)
    {
        arr[v].r = 0;
        r = 0;
    }
    else
    {
        arr[v].r = r;
    }
    forn(i, arr[v].nbr.size())
    {
        int to = arr[v].nbr[i];
        if (arr[to].used == 0)
        {
            dfs2(arr, to, r + 1);
        }
    }

}

int main()
{
    srand(13);
    ios_base::sync_with_stdio(false);

#ifdef FILE_INPUT
    freopen("file.in", "r", stdin);
    freopen("file.out", "w", stdout);
#endif
    int n;
    cin >> n;
    i64 s = 0;
    forn(i, n)
    {
        forn(j, n)
        {
            int a;
            cin >> a;
            if (i == n / 2 || j == n / 2 || i - j == 0 || i + j == n - 1)
            {
                s += a;
            }
        }
    }
    cout << s;

    return 0;
}

/* 177A */
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000")

#define mpii			map<int,int>
#define vi				vector<int>
#define pii				pair<int,int>
#define vpii			vector<pair<int,int> >
#define rep(i, a, n) 	for (int i=a;i<n;++i)
#define per(i, a, n) 	for (int i=n-1;i>=a;--i)
#define pb 				push_back
#define mp 				make_pair
#define fir				first
#define sec				second
#define all(x) 			(x).begin(),(x).end()
#define SZ(x) 			((int)(x).size())
#define lson			l, mid, rt<<1
#define rson			mid+1, r, rt<<1|1

const int maxn = 105;
bool visit[maxn][maxn];

int main() {
	ios::sync_with_stdio(false);
	#ifndef ONLINE_JUDGE
		freopen("data.in", "r", stdin);
		freopen("data.out", "w", stdout);
	#endif

	int ans = 0, x, n;

	scanf("%d", &n);
	memset(visit, false, sizeof(visit));

	// main diagonal & mid row & mod col
	int n_ = n/2;
	rep(i, 0, n) {
		visit[i][i] = true;
		visit[i][n-1-i] = true;
		visit[n_][i] = true;
		visit[i][n_] = true;
	}

	// second diagonal
	int l, r;

	l = r = n_;
	rep(i, 0, n_+1) {
		visit[i][l] = true;
		visit[i][r] = true;
		--l;
		++r;
	}
	l = 0;
	r = n - 1;
	rep(i, n_+1, n) {
		++l;
		--r;
		visit[i][l] = true;
		visit[i][r] = true;
	}

	#ifndef ONLINE_JUDGE
		rep(i, 0, n) {
			rep(j, 0, n) {
				printf("%d ", visit[i][j]);
			}
			putchar('\n');
		}
	#endif

	rep(i, 0, n) {
		rep(j, 0, n) {
			scanf("%d", &x);
			if (visit[i][j])
				ans += x;
		}
	}

	printf("%d\n", ans);

	#ifndef ONLINE_JUDGE
		printf("time = %d.\n", (int)clock());
	#endif

	return 0;
}

#include <iostream>
using namespace std;
int main()
{
	int n,s=0,c=0;
	cin>>n;
	int ** arr = new int*[n];
	for(int i=0;i<n;i++)
	{
		arr[i]=new int[n];
	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>arr[i][j];
		}
	}

	for(int i=0;i<n;i++)
	{
		s+=arr[i][i];
	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i+j==n-1)
			s+=arr[i][j];
		}
	}

		for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i==n/2)
			s+=arr[i][j];
		}
	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(j==n/2)
			s+=arr[i][j];
		}
	}

	c=(arr[n/2][n/2])*3;
	s-=c;
	/*	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			s-=c;
		}
	}*/
	//cout<<arr[n/2][n/2];
	cout<<s<<"\n";
	return 0;
}

#include "stdio.h"
#include <stack>
#include <vector>
#include <iostream>
#include "math.h"
int chek[102][102];

using namespace std;

int main()
{
    int n,l,i,min,ch=0,nom,j;

    scanf("%d",&n);
     for(i=0;i<n;i++)
         for(j=0;j<n;j++){
             scanf("%d",&nom);
             if( j==i || j==(n-1)/2 || i==(n-1)/2 || i==n-j-1){
                ch+=nom;

                }
         }
     printf("%d",ch);

    return 0;
}

#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <map>
using namespace std;
typedef long long ll;

int mas[110][110];
bool used[110][110];

int get(int x, int y)
{
    if (used[x][y]) return 0;
    used[x][y] = true;
    return mas[x][y];
}

int main()
{
    #if !defined(ONLINE_JUDGE)
        freopen("input.txt", "r", stdin);
        freopen("output.txt ", "w", stdout);
    #endif

    memset(used, false, sizeof(used));
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            scanf("%d", &mas[i][j]);
        }
    }

    int sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += get(i, i);
    }
    for (int i = 0; i < n; ++i) {
        sum += get(i, n - i - 1);
    }
    for (int i = 0; i < n; ++i) {
        sum += get(n/2, i);
    }
    for (int i = 0; i < n; ++i) {
        sum += get(i, n/2);
    }
    printf("%d\n", sum);

    return 0;
}

    #include<iostream>
    using namespace std;
    int main()
    {
    	int i,j,n,s = 0,t;
    	cin >> n;
    	int a[n][n];
    	int m = (n-1)/2;
    	for(i=0;i<n;i++)
    		for(j=0;j<n;j++)
    			cin >> a[i][j];

    	for(i=0;i<n;i++)
    		for(j=0;j<n;j++)
    			if(i == j||i+j == n-1||i==m||j == m)
    				s=s+a[i][j];
    	cout << s <<endl;
    }

#include <iostream>

using namespace std;
int main()
{
    int n, a[1200][1200]; cin >> n;
    bool fre[1200][1200];
    for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++)
      {
          fre[i][j]=false;
          cin >> a[i][j];
      }
    int res=0;
    for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++)
      {
          fre[i][i]=true;
          fre[i][n-i+1]=true;
          if(i==(n+1)/2) fre[i][j]=true;
          if(j==(n+1)/2) fre[i][j]=true;
      }
    for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++) if(fre[i][j]) res+=a[i][j];
    cout << res << endl;

}

#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<list>
#include<cmath>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int** ary = new int* [N];
    for (int i = 0; i < N; ++i)
        ary[i] = new int[N];

    // fill
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
            cin>>ary[i][j];
    int mid = N / 2 ;
    int sum = 0;
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
        {
            if (i == j||i==mid||j==mid)
                sum += ary[i][j];
            else if ((i + j) == (N - 1))
                sum += ary[i][j];
        }
    cout << sum;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n][n];
  int ans = 0;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      cin >> arr[i][j];
      if (i == n / 2 || j == n / 2 || i == j || j == n - i - 1){
        ans += arr[i][j];
      }
    }
  }
  cout << ans;
}

#include<iostream>
using namespace std;
int main()
{
    int n,s=0;
    cin>>n;
    int i,j,a[n][n];
    for(i=0;i<n;i++)
    for(j=0;j<n;j++)
    {
      cin>>a[i][j];
      if(i==(n-1)/2||j==(n-1)/2||i==j||n-j-1==i){s+=a[i][j];
      a[i][j]=0;}
      }
      cout<<s;
      return 0;
      }

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,numero ;
  cin>>n ;
  int matrix[n][n][2];
  for (int j=0 ; j<n ; j++)for ( int i=0 ; i<n ; i++)for ( int k=0 ; k<2 ; k++) matrix[j][i][k]=0;

  for (int j=0 ; j<n ; j++)for ( int i=0 ; i<n ; i++){cin>>numero;matrix[j][i][0]=numero;}

  for (int i=0 ; i<n ; i++)matrix[i][i][1]=1;

  for (int i=n-1 ; i>=0 ; i--)matrix[n-1-i][i][1]=1;

  int medio= (n-1)/2;

  for (int i=0;i<n; i++ )matrix[medio][i][1]=1;

  for (int j=0;j<n; j++ )matrix[j][medio][1]=1;

  int suma=0;

  for (int j=0 ; j<n ; j++)for ( int i=0 ; i<n ; i++){
    if (matrix[j][i][1]==1) suma+=matrix[j][i][0];
  }
  cout << suma;

}

#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n;
    int sum=0;
    cin>>n;
    vector<vector<int> >v(n,vector<int>(n));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>v[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j||i==n-j-1||i==n/2||j==n/2)
            sum+=v[i][j];
        }
    }
    cout<<sum;
    return 0;
}

#include<bits/stdc++.h>
#include <stdio.h>
#include <algorithm>

#define LL long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define vecprint(vec) for (int i=0;i<vec.size();i++)printf("%d ",vec[i]);
#define queprint(q) while(q.size()){printf("%d ",q.front());q.pop();}
#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define pr(x) printf("%d",x)
#define prl(x) printf("%lld",x)
#define sz(x) ((int)x.size())
#define MEM(v,x) memset(v,x,sizeof v)
#define rep(v,i) for(int i=0;i<v.size();i++)

const double eps=1e-7,PI=3.1415926;
const int N=1e6;

using namespace std;

LL n,m,k,a[200][200],sum,mx=-1,mn=1e9;
char c[N];
string s;
vector < int > vec;

int main(){
    cin>>n;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            if (i==((n+1)/2)||j==((n+1)/2)||j==i||(n-j+1)==i)sum+=a[i][j];
        }
    }
    cout<<sum;
    return 0;
}

#include <iostream>

using namespace std;
bool Good[104][104];
int main()
{
    for (int i=0;i<104;i++)
    for (int j=0;j<104;j++){
        if (  i==j || i==52 || j==52 || i+j ==104 )
        Good[i][j]=1;
    }
     int n;
     cin>>n;
     int s=n/2,sum=0;
     for (int i=52-s;i<=52+s;i++)
        for (int j=52-s;j<=52+s;j++)
     {
         int a;
         cin>>a;
         if (Good[i][j]) sum+=a;
     }
     cout<<sum;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define FAST ios_base :: sync_with_stdio(false);
#define inp  freopen("input.txt","r",stdin);
#define out  freopen("output.txt","w",stdout);
#define debug(x) cout << '>' << #x << " : " << x << endl;
#define MAX 100000
#define PI acos(-1)
#define pb push_back
#define F first
#define S second

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    FAST
    //inp
    //out

     int a,cnt=0;
    scanf("%d",&a);
    int ara[101][101];
    for(int i=1;i<=a;i++){
        for(int j=1;j<=a;j++){
            scanf("%d",&ara[i][j]);
            if(i==j){cnt += ara[i][j];}
            //if(i==(a+1)/2){cnt += ara[i][j];}
            //if(j==(a+1)/2){cnt += ara[i][j];}
            if((i+j)==a+1){cnt += ara[i][j];}
    }

    }

    int x=(a+1)/2;
    for(int i=1;i<=a;i++){
        cnt += ara[x][i];
        cnt += ara[i][x];
    }

    printf("%d\n",cnt-3*ara[(a+1)/2][(a+1)/2]);

    return 0;
}

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

//const long long int MOD = 1000000007;
const long long  int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> K;
			if (i * 2 + 1 == N || j * 2 + 1 ==N|| i == j || i + j == N - 1)M += K;
		}
	}
	cout << M << endl;
	return 0;
}

/*
 * main.cpp
 *
 *  Created on: 18.02.2012
 *      Author: tux
 */

#include <iostream>
#include <algorithm>
#include <list>
#include <set>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <thread>

using namespace std;

int main(int argc, char *argv[])
{
    int N;
    cin >> N;
    long long ret = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            int tmp;
            cin >> tmp;
            if(i == j || i == N / 2 || j == N / 2)
                ret += tmp;
            else if(i < N / 2) {
                if(i == j - (2 * (N / 2 - i)))
                    ret += tmp;
            } else if(i > N / 2) {
                if(i == j + (2 * (i - N / 2)))
                    ret += tmp;
            }
        }
    }
    cout << ret;
    return 0;
}

// gnu gcc compiller 4.7.2 -std = c++0xx
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#define File_in freopen("input.txt", "r", stdin)
#define File_out freopen("output.txt", "w", stdout)
#define yep cout << "YES" << endl
#define nope cout << "NO" << endl
#define FOR(i,b,n) for(int i=b; i<=n; i++)
#define RFOR(i,n,b) for(int i=n; i>=b; i--)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;

int s,n,mid,a[110][110];

int main ()
{
  cin >> n;
  mid=(n-1)/2;
  FOR(i,0,n-1)
  {
      FOR(j,0,n-1)
      {
          cin >> a[i][j];
      }
  }
  FOR(i,0,n-1)
  {
      s+=(a[i][i]+a[i][n-i-1]+a[mid][i]+a[i][mid]);
  }
  cout << s-3*a[mid][mid] << endl;

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,cnt=0;
    cin>>a;
    for(int i=0;i<a;i++)
    {
        for(int j=0;j<a;j++)
        {
            cin>>b;
            if(i==a/2 or j==a/2 or i==j or a-i==j+1)
            {
                cnt+=b;
            }
    }
    }
    cout<<cnt;

}

#include <bits/stdc++.h>
#include <string>
using namespace std;
int i,j,t,n;
bool b;
int num[1000];
int temp;
int m,x,y,z;
int main(){

    cin>>n;
     if(n==1) {cin>>y; cout<<y; return 0;}
    for(i=1;i<=n*n;i++) cin>>num[i];

    if(n==3) {for(i=1;i<=n*n;i++){
                 temp=temp+num[i];}  cout<<temp; return 0;}

        for(i=1;i<=n*n;i++){
        if(i==2 || i==4 ||
            i==6 || i==10 ||
            i==22 || i==24 ||
            i==16 || i==20 ) continue;
        else temp=temp+num[i];

    }
        cout<<temp;

}

#include<bits/stdc++.h>
#define eps 1e-8
#define ll long long
#define ed cout<<endl
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define ll long long
#define se second
#define inf 2e9
#define sz 456789
#define all(x) x.begin(), x.end()
#define pi 3.14159265359
using namespace std;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int q, n, k, ar[1234][1234], br[sz], x, y, z, maxx, a, b, c, d, sum;
string s, t;
bool ok;

void dii(){

    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> ar[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        sum += ar[i][i];
        sum += ar[n - i - 1][n - i - 1];
        sum += ar[i][n / 2];
        sum += ar[n / 2][i];
    }
    sum -= (3 * ar[n / 2][n / 2]);
    cout << sum;
}

int main(){

    faster();

    q = 1;
    // cin >> q;
    while(q--){
        dii();
    }

    return 0;
}

#include<iostream>
#include <bits/stdc++.h>
#include<algorithm>
#include <cstring>
#include <string>
#define endl "\n"
#define SRK ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define EPS 1e-6
#define MAX 100000
typedef long long ll;
const ll MOD = 1e9;
using namespace std;

int main()
{
    SRK;
    int n;
    cin >> n;
    int arr[n][n], sum = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> arr[i][j];
        }
    }
    if (n == 1)
    {
        cout << arr[0][0];
    }
    else
    {
        int k = n - 1;
        for (int i = 0; i < n; i++)
        {
            sum += arr[i][i];
            sum += arr[k][i];
            k--;
        }
        int midrow = (n / 2) + 1;
        for (int i = 0; i < n; i++)
        {
            sum += arr[midrow][i];
            sum += arr[i][midrow];
        }
        sum -= 3 * arr[midrow][midrow];
        cout << sum;
    }
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
using namespace std;

int main()
{
	int n;
	cin>>n;
	int no[n][n];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>no[i][j];
	int res=0;
	for(int i=0;i<n;i++)
	{
		res+=no[i][i];
		res+=no[i][n-1-i];
		res+=no[n/2][i];
		res+=no[i][n/2];
	}
	cout<<res;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,sum;
    scanf("%lld", &n);
    getchar();
    string s;
    for(i=0,sum=0;i<n;i++){
        getline(cin,s);
        if(n==3){
            for(j=0;j<n+(n-1);j+=2){
                sum += s[j]-'0';
            }
        }
        else if(i==0 || i==n-1){
            for(j=0;j<n+(n-1);j+=4){
                sum += s[j]-'0';
            }
        }
        else if(i==(n-1)/2){
            for(j=0;j<n+(n-1);j+=2){
                sum += s[j]-'0';
            }
        }
        else{
            for(j=2;j<n+(n-1)-2;j+=2){
                sum += s[j]-'0';
            }
        }
    }
    printf("%lld\n", sum);
    return 0;
}

#include <iostream>
#include <cstdlib>
#include <Windows.h>
#include <fstream>
//#include <conio.h>

using namespace std;
ifstream fin("standard input.txt");
ofstream fout("standard output.txt");

int main()
{
	int n,summ=0;
	int flag=1;
	fin>>n; //��������� ���������� ������
	if(n>101 || n<0|| n%2==0)
		flag=0;
    char symb; // ������ ���������� ��� ���������� �����������
	if(flag)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				fin>>symb;
				if(symb-'0'>100 || symb-'0'<0)
					break;
				if(i==j)
					summ+=symb-'0';
				else if(n-i-1==j)
					summ+=symb-'0';
				else if(i==(n-1)/2)
					summ+=symb-'0';
				else if(j==(n-1)/2)
					summ+=symb-'0';
			}
			//cout <<endl;
		}
	}
	fin.close();
    //if(!fout)
    //{
    //    cout<<"[������]: ���������� ������� ����";
    //    getchar();
    //    exit(1);
    //}
	fout<<summ;
    //fout.close();
	//cout<<endl<<summ;
	//getch();
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n, a, matrica[101][101], pas=0;
	cin>>n;
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
		{cin>>a; matrica[i][j]=a;}
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
		{
			bool flag;
			if (i==((n+1)/2-1)&&j==((n+1)/2-1)) flag = false;
			if (i==j) pas+=matrica[i][j];
			else if (i==(n-j-1)&&flag)   pas+=matrica[i][j];
			else if (i==(((n+1)/2)-1)&&flag) pas+=matrica[i][j];
			else if (j==(((n+1)/2)-1)&&flag) pas+=matrica[i][j];
		}
		cout<<pas<<endl;

	return 0;
}

#include <iostream>
using namespace std;

void main()
{
	int a[101][101], mid, s=0, n;
	 cin>>n;
	 if(n>101) return;
	 if(n==1){
		 cin>>s;
		 cout<<s;
	 }
	 else{
	 for(int i=0; i<n; i++)
		 for(int j=0; j<n; j++)
			 cin>>a[i][j];
	 mid=(n+1)/2;
	 for(int i=0;i<n;i++)
		 s+=a[i][i]+a[i][n-i-1]+a[mid][i]+a[i][mid];
	 s-=3*a[mid][mid];
	 cout<<s;
	 }
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <string>

using namespace std;

int main()
{
	char str[100000];
	int n, i = 0, index = 0;
	string s1;
	cin >> n;
	int** matrix = new int* [n];
	for (int i = 0; i < n; i++) {
		matrix[i] = new int[n];
	}
	cin.get();
	int g = 0;
	while (n > g) {
		s1 = "";
		i = 0;
		index = 0;
		cin.getline(str, 110);
		while (str[i] != '\0') {
			if (isdigit(str[i])) {
				while (str[i] != ' ' && str[i] != '\0') {
					s1 += str[i];
					i++;
				}
				int number = atoi(s1.c_str());
				matrix[g][index++] = number;
				s1 = "";
				if (str[i] == '\0')
					break;
			}
			i++;
		}
		g++;
	}
	/*cout << endl << endl;
	for (int i = 0; i < g; i++) {
		for (int j = 0; j < n; j++) {
			cout << matrix[i][j] << ' ';
		}
		cout << endl;
	}*/
	unsigned long long int sum = 0;
	for (int i = 0; i < g; i++) {
		for (int j = 0; j < n; j++) {
			if (j == i)
				sum += matrix[i][j];
			else if (j == n - i - 1 && j != (n - 1) / 2)
				sum += matrix[i][j];
			else if (i == (n - 1) / 2 && j != (n - 1) / 2)
				sum += matrix[i][j];
			else if (j == (n - 1) / 2 && i != (n - 1) / 2)
				sum += matrix[i][j];
		}
	}
	cout << sum << endl;
	for (int i = 0; i < n; i++) {
		delete[] matrix[i];
	}
	delete[] matrix;
}

#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define en end()
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
#define Max 10000000000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+9;
ll j,cs=0,n,a,b,i,dxx[]={1,0,0,-1},c,d,dyy[]={0,-1,1,0},k,m,x,y;
string s;

int main()
{
ll a,n;
cin>>n;
ll sum=0;

vector<int >v;

for(int i=1;i<=n;i++)
{
    for(int j=1;j<=n;j++)
    {
        cin>>a;
    cout<<a<<endl;
     if(i==1)
        {
            if(j==1 || j==(n+1)/2 || j==n)
               sum+=a;
        }
      if(i==(n+1)/2 && j==1 )           sum+=a;
        if(i==(n+1)/2 && j==n)    sum+=a;

           if(i==n)
        {
            if(j==1 || j==(n+1)/2 || j==n)
            sum+=a;
        }

        if(i>=2 && i<n)
        {
            if(j>=2 && j<n)
                sum+=a;
        }

    }
}
cout<<sum<<endl;

return 0;
}

#include <iostream>
//#include <vector>
using namespace std;

int matrix[105][105];
int main()
{
  int n, center, ans = 0;
  cin >> n;

  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      cin >> matrix[i][j];
    }
  }
  center = (n/2); cout << center << endl;

  for(int i=0; i<n; i++){
    ans += matrix[i][i];
    if(i == center){
      continue;
    }else{
      ans += matrix[i][n-i-1];
      ans += matrix[center][i];
      ans += matrix[i][center];
    }
  }
  cout << ans << endl;
  return 0;
}

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
	ifstream input("standart.input");
	ofstream output("standart.output");

	int size;
	input >> size;
	int **a;
	long sum=0;
	a=new int*[size];
	for(int i=0; i<size; i++)
		a[i]=new int[size];
	for(int i=0; i<size; i++)
	{
		for(int j=0; j<size; j++)
		{
			input >> a[i][j];

		}
	}
	int m=size/2;
	for(int i=0; i<size; i++)
	{
		sum+=a[i][i];
		if(i!=m)
		{
			sum+=a[m][i];
			sum+=a[i][m];
		}
		for(int j=0; j<size; j++)
		{
			if(i+j==size-1 && i!=j)

				sum+=a[i][j];
		}
	}

	output << sum;
	for(int i=0; i<size; i++)
		delete[]a[i];
	input.close();
	output.close();
	delete[]a;
	return 0;

}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>

#define N 110

using namespace std;

int a[N][N];

int main()
{
    int n;
    while(cin >> n) {
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < n; ++j) {
                cin >> a[i][j];
            }
        }
        int sum = 0;
        for(int i = 0; i < n; ++i) {
            sum += a[i][i] + a[i][n - 1 - i] + a[i][n / 2] + a[n / 2][i];
        }
        cout << sum - 2 * a[n / 2][n / 2] << endl;
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
int main() {
	int n,sum=0;
  cin>>n;
  int t[100][100];
  set<pair<int,int>>s;
  for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {
      cin>>t[i][j];
    }
  }
  for(int i=0;i<n;i++) {
    s.insert({i,i});
    s.insert({i,n-i-1});

    s.insert({(n-1)/2,i});
    s.insert({i,(n-1)/2});

  }
  for(auto &x:s) {
    cout<<x.first<<" "<<x.second<<endl;
    sum+=t[x.first][x.second];
  }
  cout<<sum;
	return 0;
}

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int i,j,n,x,c=0,t;
	cin >> n >> x;
	if(x>n)
		t = n;
	else
		t = x;
	for(i=1;i<=n;i++)
		for(j=1;j<=t;j++)
			if(i*j==x)
			{
				c++;
			}
	cout << c <<endl;
}

#include <bits/stdc++.h>
using namespace std;
//ifstream cin("lineup.in");
//ofstream cout("lineup.out");
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int main(){
    int n;
    cin>>n;
    int a[n][n];
    for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
	    cin>>a[i][j];
	}
    }
    if(n==1){
	cout<<a[0][0]<<endl;
	return 0;
    }
    long long ans=0;
    for(int i=0;i<n;i++){
	ans+=a[n/2+1][i];
    }
    for(int i=0;i<n;i++){
	ans+=a[i][n/2+1];
    }
    for(int i=0;i<n;i++){
	ans+=a[i][i];
    }
    for(int i=0;i<n;i++){
	ans+=a[i][n-1-i];
    }
    ans-=3*a[n/2+1][n/2+1];
    cout<<ans<<endl;

}

#include <iostream>
using namespace std;

int main()
{
    int i,j,p,num1,sum=0;
    cin>> num1;
    if(num1==1){
        cin>> p; cout<< p<< endl;
    }
    else{
        int array1[num1][num1];
        for(i=0; i<num1; i++){
            for(j=0; j<num1; j++){
                cin>>array1[i][j];
            }
        }

        if(num1==1)
            cout<< array1[num1][num1];
        else{
            for(i=0; i<num1; i++){
            sum = sum+array1[i][i];
        }
        for(i=num1-1,j=0; i>-1&&j<num1; i--,j++){
            sum = sum+array1[j][i];
        }
        p=(num1+1)/2;
        for(i=0; i<num1; i++){
            sum = sum+array1[i][p];
        }
        for(i=0; i<num1; i++){
            sum = sum+array1[p][i];
        }
        p=array1[p][p]*3;
        sum=sum-p;
        cout<< sum<< endl;
        }
    }
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int n;
int sum=0;
int temp[101][101];
cin >> n;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
cin >> temp[i][j];
}
}
for(int i = 0; i < n; i++) sum += temp[i][i];
for(int i = 0; i < n; i++) sum += temp[i][n-i-1];

for(int i = 0; i < n; i++) {
sum += temp[i][(n-1)/2];
}
for(int i = 0; i < n; i++) {
sum += temp[(n-1)/2][i];
}

sum = sum - 3;
cout << sum;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
//#define ll long long

int main(){
      #ifndef Utshow_Rehman
   freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
  ios::sync_with_stdio(false);
  cin.tie(0);
       int n;
       cin>>n;
       int arr[n][n];
       for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
               cin>>arr[i][j];
}
       }
       int sum=0;
       for(int i=0;i<n;i++){
        for(int j=i;j<=i;j++){
               sum+=arr[i][j];
}
       }
       int res=n/2,c=1;
        for(int i=0;i<n;i++){
        for(int j=n-1-i;j>=n-1-i;j--){
              if(res==i )
                 continue;
               else sum+=arr[i][j];
}
       }
       for(int i=res;i<=res;i++){
        for(int j=0;j<n;j++){
              if(res==i && res==j )
                 continue;
               else sum+=arr[i][j];
}
}
for(int i=0;i<n;i++){
        for(int j=res;j<=res;j++){
              if(res==i && res==j )
                 continue;
               else sum+=arr[i][j];
}
}
       cout<<sum<<endl;
    return 0;
}

#include <iostream>

using namespace std;
int sum = 0;
int a[1000][1000];
int main(){
	int n ;
	cin >> n;

	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ;j <= n ;j++){
			cin >> a[i][j];
		}
	}
	for(int i = 1 ; i <= n ; i++){
		sum += a[i][i];
	}
	for(int i = n ; i  >= 1; i--){
		sum +=a[i-n+1][i];

	}
	int f = n/2 +1;
	for( int j = 1; j <= n; j++){

		sum+= a[f][j];
		sum+= a[j][f];
	}
	sum -= 3 * a[f][f];
	cout << sum;
}

#include <iostream>
#include <cstdlib>
#include <Windows.h>
#include <fstream>
//#include <conio.h>

using namespace std;
ifstream fin("standard input.txt");
ofstream fout("standard output.txt");

int main()
{
	int n,summ=0;
	int flag=1;
	fin>>n; //��������� ���������� ������
	if(n>101 || n<0)
		flag=0;
    char symb; // ������ ���������� ��� ���������� �����������
	if(flag)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				fin>>symb;
				if(symb-'0'>100 || symb-'0'<0)
					break;
				if(i==j)
					summ+=symb-'0';
				else if(n-i-1==j)
					summ+=symb-'0';
				else if(i==(n-1)/2)
					summ+=symb-'0';
				else if(j==(n-1)/2)
					summ+=symb-'0';
			}
			//cout <<endl;
		}
	}
	fin.close();
    //if(!fout)
    //{
    //    cout<<"[������]: ���������� ������� ����";
    //    getchar();
    //    exit(1);
    //}
	fout<<summ;
    fout.close();
	//cout<<endl<<summ;
	//getch();
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n][n];

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
    if(n==1)
        cout<<a[0][0];
    else
    {
    int centre=a[n/2][n/2];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==n/2||j==n/2)
                sum+=a[i][j];
            if(i==j)
                sum+=a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=n-1;j>=0;j--)
        {
            if(i==j)
                sum+=a[i][j];
        }
    }
    sum=sum-(2*centre);
    cout<<sum;
    }
    return 0;
}

#include <stdio.h>
#include <conio.h>

const int N = 5;

int main()
{
    int array[ N ][ N ];
    int sizeArr = 0;
    int input;
    int i,j;
    int sumHeadDiag = 0, sumAddDiag = 0, sumCent1 = 0, sumCent2 = 0, result = 0;

    scanf("%d", &sizeArr);

    if(sizeArr == 1)
    {
        scanf("%d", &input);
        printf("%d", input);
    }
    else
    {
        for( i = 0; i < sizeArr; i++ )
            for( j = 0; j < sizeArr; j++ )
            {
                scanf( "%d", &input);
                array[i][j] = input;
            }

            for( i = 0; i < sizeArr; i++)
                sumHeadDiag += array[i][i];

            for( i = sizeArr-1; i >= 0; i-- )
                sumAddDiag += array[i][i];

            for ( i = 0; i < sizeArr; i++ )
                sumCent1 += array[i][ (sizeArr-1)/2];

            for ( i = 0; i < sizeArr; i++ )
                sumCent2 += array[ (sizeArr-1)/2 ][i];

            result = sumCent1 + sumCent2 + sumAddDiag + sumHeadDiag - 3*array[(sizeArr - 1)/2][(sizeArr - 1)/2] ;
            printf("%d", result);
    }
    return 0;

}

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    int b[105][105],a[105][105];
    int i,j,m,n,sum,k,sum1;
    while(scanf("%d",&n)!=EOF)
    {
        memset(b,0,sizeof(b));
        k=(n+1)/2;
        for(i=1;i<=n;i++)
        a[k][i]=a[i][k]=1;
        for(i=1;i<=n;i++)
        a[i][i]=a[i][n+1-i]=1;
        sum=sum1=0;
        for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
        {
        scanf("%d",&b[i][j]);
        sum+=b[i][j];
        if(a[i][j]==1)
        sum1+=b[i][j];
        }
        if(n<5)
        printf("%d\n",sum);
        else
        printf("%d\n",sum1);
    }
}

#include <iostream>

using namespace std;

int main()
{
    int a[102][102], i, j, n, sum = 0;
    while (cin >> n)
    {
        sum = 0;
        for (i = 0; i < n; i++)
        {
            for (j = 0; j < n; j++)
            {
                cin >> a[i][j];
                if (i == n / 2 || j == n / 2)
                {
                    sum  += a[i][j];
                }
            }
        }
        for (int i = 0; i < n; i++)
        {
            sum += a[i][i];
            sum += a[n - 1 - i][n - 1 - i];
        }
        cout << sum - a[n / 2][n / 2] * 2 << endl;
    }
    return 0;
}

/*
 * File:   CrockCC.cpp
 * Author: MarieL
 *
 * Created on 3 Апрель 2012 г., 21:53
 */

#include <cstdlib>
#include <stdio.h>
#include <iostream>
#include <map>
#include <math.h>
#define maxn 101

using namespace std;

int main(int argc, char** argv) {

    int n;
    cin>>n;

    int M[101][101];

    for (int i = 0; i<n; ++i)
        for (int j = 0; j<n; ++j)
            cin>>M[i][j];

    int res = 0,c = 0;

    if (c>1)
         c = n/2 + 1;
    else c = 0;

    for (int i = 0; i<n; ++i)
    {
        res+=M[i][c];
        res+=M[i][i];
        res+=M[i][n-1-i];
        res+=M[c][i];
    }

    cout<<res - 3*M[c][c]<<endl;

    return 0;
}

#include<bits/stdc++.h>
#define ll long long int
#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

int main(void)
{
    FastIO;

    ll n;
    cin>>n;
    ll a[n][n];
    for(ll i=1;i<=n;i++)
    {
    	for(ll j=1;j<=n;j++)
    	{
    		cin>>a[i][j];
		}
	}
	ll m=(n/2)+1,s=0;
	for(ll i=1;i<=n;i++)
	{
		s+=a[m][i];
		s+=a[i][m];
	}
	for(ll i=1;i<=n;i++)
	{
		s+=a[i][i];
	}
	for(ll i=1,j=n;i<=n,j>0;i++,j--)
	{
		s+=a[i][j];
	}
	cout<<s-3*a[m][m];

    return 0;
}

//
//--Odina Placement (t.me/OP_hw)--
//-- coded by Alex Teexone::8-12-2018 ---
//
#include <bits/stdc++.h>

#define f first
#define s second
//#define for(x,n) for(int i{x};i<n;i++)
using namespace std;

int main()
{
   int n; cin>>n;
   int m[n][n];
   int ans = 0;
   for(int i = 0; i < n; i++)
   {
   	 	for(int j = 0; j < n; j++) cin>>m[i][j];
   }
   for(int i = 0; i < n; i++)
   {
   		ans+=m[i][i];
   		ans+=m[i][n-i];
   }
   int g = n/2+1;
   for(int i=0; i < n; i++)
   {
   		ans+=m[g][i];
   		ans+=m[i][g];

   } cout<<ans-3*m[g][g];
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <cctype>

using namespace std;

int a[10][10];

 int main ()
 {
     int N;
     cin>>N;

     for( int i=0 ; i<N ; i++ )

         for( int j = 0 ; j<N; j++)

            {
                cin>> a[i][j];
            }

    int suma;
    suma=0;

    for( int i=0 ; i<N ; i++ )
    {
       for( int j = 0 ; j<N; j++)
         {
           if( i==j)
            {
                 suma = a[i][j] + suma;
                }

           if( i==N/2)
          {
                 suma = a[i][j] + suma;
                 }
           if( j==N/2)
           {
                suma = a[i][j] + suma;
                }

            if( j==N-i+1)
           {
                suma = a[i][j] + suma;
                }

        suma = suma - 3* a[N/2][N/2];

            }
        }

     cout<< suma<< endl;

}

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>
#include <deque>

typedef long long int64;

#define all(x) x.begin(), x.end()
#define INF 10000000 //'0':7
#define veci vector <int>
#define forn(name, size) for(int64 name = 0; name < size; ++name)

using namespace std;

struct Node
{
	Node() : color(-1),iNeed(false) {}
	vector<int> edges;
	int color;
	bool iNeed;
};

vector<Node> graph;
int timer = 0;
set<int> slaves;
set<int> ans;

void DFS(int from)
{
	graph[from].color = timer;

	for (int i = 0; i < graph[from].edges.size(); ++i)
	{
		int to = graph[from].edges[i];

		if (graph[to].color == -1)
		{
			DFS(to);
		}
		else
		{
			if (graph[to].color != timer)
			{
				slaves.insert(graph[to].color);
			}
		}
	}

}

int main()
{
//	freopen("input.txt", "r", stdin);
	int n;
	cin >> n;
	vector<vector<int>> matrix(n);
	int sum = 0;

	forn(i, n)
	{
		matrix[i].resize(n);
		forn(j, n)
		{
			cin >> matrix[i][j];
		}
	}

	for (int i = 0; i < n; ++i)
	{
		sum += matrix[n / 2][i];
		sum += matrix[i][n / 2];
		sum += matrix[i][i];
		sum += matrix[n - i - 1][n - i - 1];
	}
	sum -= matrix[n / 2][n / 2] * 3;

	return 0;
}

#include <iostream>
using namespace std;

int n, ans;

void main () {
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);

    cin >> n;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) {
            int x;
            cin >> x;
            if (i == j || i == n-j-1 || i == (n-1)/2 || j == (n-1)/2)
                ans += x;
        }
    cout << ans;
}

#include <bits/stdc++.h>
#define lint long long int
#define girdi freopen("motor.gir", "r", stdin);
#define cikti freopen("motor.cik", "w", stdout);
#define faster ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
#define cend << "\n";
#define cspace << " ";
#define space << " " <<
#define modal  %= 1000000007
#define P system("PAUSE");
using namespace std;
//vector <string> nec; 300milyon
//vector <int> mec;5545036815
//vector <bool> visited(1000000,0);
//map <lint,char> eksi;
//map <int,vector <int>> yollar;
//map <char,vector <pair<char,int> > > yollar;
//priority_queue <int> pq;
//set <int> ster;
//return cout << 0,0;
//multiset <int> mst;
//memset(arr, 0, sizeof arr);
//priority_queue <int, vector<int>, greater<int> > pq;
//variable = (condition) ? expressionTrue : expressionFalse;
//sort(vec.begin(), vec.end());
//for (int i = 0; i < n; i++){
///////////////////////////////////////////////

bool bol = true;
vector <lint> vec;
map <string,string> mp;
///************///***********///
char fe,fa,fu,fi;
lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,x1,x2,y1,y2;
lint mis = 1000000007,mas = -1000000007,ans,bas,mid,son,st,en,temp,sum,prd;
string aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll,mm,nn,oo,pp,qq,rr,ss,tt,uu,vv,ww,xx,yy,zz;
///////////////////////////////////////////////

lint max3 (lint mar1, lint mar2, lint mar3){
    if (mar1 >= mar2 && mar1 >= mar3) return mar1;
    else if (mar2 >= mar1 && mar2 >= mar3) return mar2;
    else if (mar3 >= mar2 && mar3 >= mar1) return mar3;
}
lint min3 (lint mar1, lint mar2, lint mar3){
    if (mar1 <= mar2 && mar1 <= mar3) return mar1;
    else if (mar2 <= mar1 && mar2 <= mar3) return mar2;
    else if (mar3 <= mar2 && mar3 <= mar1) return mar3;
}

int main (void){
    faster
    //girdi
    //cikti
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            cin >> x;
            if (i == n / 2 || j == n / 2) ans += x;
            if ((i == 0 || i == n - 1) && (j == 0 || j == n - 1)) ans += x;
            if ((i == 1 || i == n - 2) && (j == 1 || j == n - 2)) ans += x;
        }
    }
    cout << ans cend
}

#include<stdio.h>
int main()
{
    int num,i,k;
    int sum=0;
    int Array[101][101];
    scanf("%d",&num);
    for(i=0;i<num;i++)
    for(k=0;k<num;k++)
    scanf("%d",&Array[i][k]);
    for(i=0;i<num;i++)
    sum+=Array[i][(num+1)/2];
    for(i=0;i<num;i++)
    sum+=Array[(num+1)/2][i];
    for(i=0;i<num;i++)
    sum+=Array[i][i];
    for(i=0;i<num;i++)
    sum+=Array[i][num-i-1];
    sum-=3*Array[(num+1)/2][(num+1)/2];
    printf("%d",sum);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,e;
    cin>>n;
    int a1[n][n];
    long long int s=0;
     e=(n-1)/2;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>a1[i][j];
            if(n==1)
            {
                cout<<a1[i][j]<<endl;
                return 0;
            }
            if(i==j){
                 if(i!=e && j!=e){
                s+=a1[i][j];
        }
            }
    }
    }

    for(int i=1;i<=n;i++)
    {
        if(i!=e){
        s+=a1[e][i];
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(i!=e){
        s+=a1[i][e];
        }
        s+=a1[i][n-i+1];
    }
cout<<s<<endl;
return 0;

}

#include <iostream>

using namespace std;

int main()
{
int n,sum=0,mid;

cin>>n;

int m[n][n];

for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
    cin>>m[i][j];

for(int i=0,j=n-1;i<n,j>=0;i++,j--)
{
    sum+=m[i][j];
    sum+=m[j][i];
    sum+=m[mid][i];
    sum+=m[i][mid];
}

sum-=(3*m[mid][mid]);

cout<<sum;

    return 0;
}

#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    long long n, sum = 0;
    cin >> n;

    long long ** x = new long long * [n];
    for (long long i = 1; i <= n; i++) x[i] = new long long[n];

    for (long long i = 1; i <= n; i++) {
        for (long long j = 1; j <= n; j++) {
            cin >> x[i][j];
        }
    }

    if (n == 1) {
        cout << 1;
    }

    else if (n == 3) {
        for (long long i = 1; i <= n; i++) {
            for (long long j = 1; j <= n; j++) {
                sum += x[i][j];
            }
        }
        cout << sum;
    }
    else {
        for (long long i = 1; i <= n; i++) {
            for (long long j = 1; j <= n; j++) {
                if (i == j) {
                    sum += x[i][j];
                }
            }
        }
        for (long long i = n; i >= 1; i--) {
            for (long long j = n; j >= 1; j--) {
                if (i == j) {
                    sum += x[i][j];
                }
            }
        }
        for (long long j = 1; j <= n; j++) {
            sum += x[(n / 2) + 1][j];
        }
        for (long long i = 1; i <= n; i++) {
            sum += x[i][(n / 2) + 1];
        }
        cout << sum - 3 * x[(n / 2) + 1][(n / 2) + 1];
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int a [101][101];

int main(){
    int n, sum = 0;
    cin >> n;
    int x = n / 2;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        sum += a[i][i];
        sum += a[i][x];
        sum += a[x][i];
    }
    for (int i = n - 1; i >= 0; --i) {
        sum += a[i][i];
    }
    cout << sum - 3 * a[x][x];

    return 0;
}

#include <iostream>
#include <cstdlib>
#include <Windows.h>
#include <fstream>
//#include <conio.h>

using namespace std;
//ifstream fin("standard input.txt");
//ofstream fout("standard output.txt");

int main()
{
	int n,summ=0;
	cin>>n; //��������� ���������� ������
	if(n>101 || n<0|| n%2==0)
		return 1;
    char symb; // ������ ���������� ��� ���������� �����������
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>symb;
			if(symb-'0'>100 || symb-'0'<0)
				break;
			if(i==j)
				summ+=symb-'0';
			else if(n-i-1==j)
				summ+=symb-'0';
			else if(i==(n-1)/2)
				summ+=symb-'0';
			else if(j==(n-1)/2)
				summ+=symb-'0';
		}
		//cout <<endl;
	}
	//fin.close();
    //if(!fout)
    //{
    //    cout<<"[������]: ���������� ������� ����";
    //    getchar();
    //    exit(1);
    //}
	cout<<summ;
    //fout.close();
	//cout<<endl<<summ;
	//getch();
	return 0;
}

#include<bits/stdc++.h>

using namespace std;
const int MAXN = 100 + 7;
int n, arr[MAXN][MAXN], sum;
bool mark[MAXN][MAXN];
int main(){
	cin >> n;
	for ( int i = 0; i < n; i++){
		for( int j = 0; j < n; j++ ){
			cin >> arr[i][j];
			sum = sum + arr[i/2][j];
			mark[i/2][j] = true;
			if(( i + j )%2 == 0){
				if( mark[i][j] == false ){
					sum = sum + arr[i][j];
					mark[i][j]= true;
				}
			}
		}
	}
	cout<< sum << endl;
	return 0;
}

#include <iostream>
#include <cstdio>
#define MAXN 111

using namespace std;

int main(){
    int n, a[MAXN][MAXN], res = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            scanf("%d", &a[i][j]);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            if (i == j || i + j - 1 == n || i + j - 1 == n - 2 || i + j - 1 == n + 2
                || i == j + 2 || i == j - 2 || i == (n + 1) / 2 || j == (n + 1) / 2){}
            else a[i][j] = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) res += a[i][j];
    printf("%d\n", res);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define pb push_back
#define pi  acos(-1)
#define TIME 1.0*clock()/CLOCKS_PER_SEC
#define ld long double
#define endl '\n'

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //    freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin>>n;
    int a[n][n];
    ll sum = 0;
    for (int i = 0;i < n; ++i){
        for (int j = 0;j < n; ++j){
            cin>>a[i][j];
            sum += a[i][j];
        }
    }
    if (n == 3 || n == 1){
        cout<<sum<<endl;
        return 0;
    }
    for (int i = 0;i < (n / 2); ++i){
        sum -= a[i][n / 2];
        sum -= a[n / 2][i];
        sum -= a[n / 2][n - i - 1];
        sum -= a[n - i - 1][n / 2];
    }
    cout<<sum<<endl;
    return  0;
}

#include <iostream>
using namespace std;

int main()
{
	int n , numero,sum = 0;
	cout<<"tamaño de la matriz : ";
	cin>>n;

	int A[n][n];

	for( int i=0; i<n ; i++)
	{
		for( int j=0; j<n ; j++ )
		{
			cin >> A[i][j];
		}
	}

	for( int i = 0 ; i<n ; i++ )
	{
		for( int j=0; j<n ; j++ )
		{
			if( j == (n+1)/2 -1 )
			{
				sum = sum + A[i][j];
			}

			if( i == (n+1)/2 -1  )
			{
				sum = sum + A[i][j];
			}

			if( i == j )
			{
				sum = sum + A[i][j];
			}

			if( i + j == n-1 )
			{
				sum = sum + A[i][j];
			}
		}
	}

	sum = sum-3*A[ (n+1)/2 - 1][(n+1)/2 - 1];
	cout<<sum;

}

#include <stdio.h>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int n=0;
    scanf("%d", &n);
    int mid=n-(n/2);
    int arr[n][n]={};
    for (int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            scanf("%d", &arr[i][j]);
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=arr[i][i];
        sum+=arr[i][n-i-1];
        sum+=arr[mid][i];
        sum+=arr[i][mid];
    }
    sum-=(arr[mid][mid]*3);
    printf("%d", sum);
}

#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;

    int ans;
    for( int i= 0; i < n; i++ ) {
        for( int j = 0; j < n; j++ ) {
            int x;
            cin >> x;
            if( i == j || i + j + 1 == n || i == n/2 || j == n/2 ) {
                ans += x;
            }
        }
    }

    cout << ans;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    ll sum = 0;
    vector<vector<int>> a(n, vector<int> (n));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < n; i++){
        sum += a[i][i];
        sum += a[n-1-i][n-1-i];
    }
    for(int i = 0; i < n; i++){
        sum += a[(n-1)/2][i];
        sum += a[i][(n-1)/2];
    }
    sum -= 3*(a[(n-1)/2][(n-1)/2]);
    cout << sum;
}

#include<bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int> > v(n + 1,vector<int>(n + 1,0));

	int psum = 0, nsum = 0;

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			int x;
			cin >> x;
			v[i][j] = x;
			psum +=x;
		}
	}

	//first and last even row
	for(int i = 2; i <= n - 1; i++){
		if(i % 2 == 0){
			nsum += v[0][i];
			nsum += v[n - 1][i];
		}
	}

	////first and last even col
	for(int i = 1; i <= n - 1; i++){
		if(i % 2 == 0){
			nsum += v[i][0];
			nsum += v[i][n - 1];
		}
	}

	cout << psum - nsum << endl;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MaxN=200+10;
int a[MaxN][MaxN];

int main(){
	int n;
	cin >> n;
	for (int i=0;i<n;++i)
		for (int j=0;j<n;++j)
			cin >> a[i][j];
	int ans=0;
	for (int i=0;i<n;++i){
		ans+=a[i][i];
		ans+=a[i][n-i-1];
		ans+=a[i][n/2+1];
		ans+=a[n/2+1][i];
	}
	cout << ans;
}

#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <deque>
#include <functional>
#include <utility>
#include <numeric>
#include <list>
#include <queue>
#include <climits>
#include <cstring>
#include <stack>
#include <cstdlib>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <complex>
using namespace std;

const int MAX_N = 100005;
const double EPS = 1e-9;
const int MOD = 1000007;
const int INF = 0x7fffffff;

typedef long long ll;
typedef pair <int,int> PII;

#define all(a)  a.begin(),a.end()
#define ss  second
#define ff   first
#define sqr(x)  ((x)*(x))
#define cub(x)  ((x)*(x)*(x))
#define pb  push_back
#define mp  make_pair
#define mem(f, a) memset(f, a, sizeof(f))
#define cl  clear()
#define ins insert
//#define int long long
#define dbg(x) cerr<<((#x))<<" = "<<((x))<<" "<<endl
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define fora(i,a,b) for(__typeof(a) i=(a) ; i<(b) ; i++)
#define foreach(i,n) for(__typeof((n).begin())i =(n).begin();i!=(n).end();i++)

template <class Int> inline int size (const Int &a){return (int)a.size();}

set <PII> st;
ll n, arr[111][111];

void move(int x,int y,int dx,int dy)
{
    if(x < 0 || x > n || y < 0 || y > n) return ;

    st.ins(mp(x,y));
    move(x+dx,y+dy,dx,dy);
}

main() {
    ios::sync_with_stdio(false);

    cin >> n;

    rep(i,n) rep(j,n) cin >> arr[i][j];

    move(0,0,1,1);// cor
    move(0,n/2,1,0);// cor
    move(0,n/2,1,1);// cor
    move(0,n-1,1,-1);//cor
    move(n/2,0,0,1);// cor
    move(n/2,0,1,1);// cor
    move(n/2,0,-1,1);// cor
    move(n-1,n/2,-1,1);//cor

    ll ans = 0;
    foreach(it,st)
    {
        ans += (arr[it->ff][it->ss]);
    }
    cout << ans << endl;
}

#include<iostream>
using namespace std;
int main()
{
	int i,j,sum1=0,sum2=0,n,sum3=0,sum4=0,sum5=0;
	cin>>n;
	int a[n][n];
	for(i=0;i<n;i++)
	{

	   for(j=0;j<n;j++)
	   {
	   	cin>>a[i][j];
	   }
    }

    for(i=0;i<n;i++)
	    for(j=0;j<n;j++)
	    {
	    	if(i==j)
	    	sum1+=a[i][j];
	    	if(i+j==(n-1))
	    	sum2+=a[i][j];
		}
	cout<<sum1;
	cout<<sum2;
	j=n/2;
	for(i=0;i<n;i++)
	    sum3+=a[i][j];
		    cout<<sum3<<endl;
	i=n/2;
	for(j=0;j<n;j++)
	    sum4+=a[i][j];
	         cout<<sum4<<endl;

	 sum5=(sum1+sum2+sum3+sum4)-3*a[n/2][n/2];
	         cout<<"sum of good matrix elements"<<sum5;
}

////██╗ ██████╗ ██╗    ██████╗  ██████╗  ██╗ █████╗
////██║██╔═══██╗██║    ╚════██╗██╔═████╗███║██╔══██╗
////██║██║   ██║██║     █████╔╝██║██╔██║╚██║╚██████║
////██║██║   ██║██║    ██╔═══╝ ████╔╝██║ ██║ ╚═══██║
////██║╚██████╔╝██║    ███████╗╚██████╔╝ ██║ █████╔╝
////╚═╝ ╚═════╝ ╚═╝    ╚══════╝ ╚═════╝  ╚═╝ ╚════╝

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define mlojins cout.tie(NULL);
#define bzbz cin.tie(NULL);
#define CODER ios_base::sync_with_stdio(0);
using namespace std ;
map <ll , ll > mp , pm ;
vector <ll> v , p ;
ll a , c , d , e , cnt , ans , r ;
string g , h ;
char t , y , u ;
int main ()
{
    mlojins
    bzbz
    CODER
    cin >> a;
    cnt = a / 2 + 1;
    for( ll i = 1; i <= a; i ++ )
    {
        for(  ll j = 1; j <= a; j ++ )
        {
            cin >> c;
            if( i == j or i+j == a+1 or i == cnt or j == cnt )
                cnt += c;
        }
    }
    cout << cnt ;
}
///Eco students
///MMAVL studios
/*	4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355,
378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648,
 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165*/

// Codeforces - Problem
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <cassert>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

// DEFINE
#define FOR(i,a,b)     for (int i=(a),_b=(b); i<_b; i++)
#define RFOR(i,b,a)    for (int i=(b)-1,_a=(a); i>=_a; i--)
#define RESET(a,b)      memset((a),(b),sizeof(a))
#define fi              first
#define se              second
#define foreach(i, c)   for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)

//
using namespace std;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <string> vs;
typedef long long int64; //NOTES:int64
typedef unsigned long long uint64; //NOTES:uint64
typedef unsigned uint;
const double pi = acos(-1.0); //NOTES:pi
const double eps = 1e-11; //NOTES:eps
const int MAXI = 0x7fffffff;
int in() {
    int x = 0, c;
    for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
    do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
    return x;
}
// CODE

int main(int argc, char *argv[])
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    int n;
    cin >> n;
    int sum, a[n][n];
    sum = 0;
    FOR(i,0,n)
        FOR(j,0,n)
        {
            cin >> a[i][j];
            if(i == j || i == n/2)
                sum += a[i][j];
        }
    FOR(i,0,n)
        sum += a[n/2][i];
    int j;
    j = n-1;
    FOR(i,0,n)
        sum += a[j][i], j--;
    cout << sum - 2*a[n/2][n/2];
    return 0;
}

#include <iostream>
using namespace std;

int main() {
        long int sum=0;
       int n,i,j;
       cin>>n;
       int arr[n][n];
       for(i=0;i<n;i++)
       {
         for(j=0;j<n;j++)
         cin>>arr[i][j];
       }

        if(n==1)
        cout<<arr[0][0];
        if(n==3)
        {
            for(i=0;i<n;i++)
            {
                for(j=0;j<n;j++)
                sum+=arr[i][j];
            }
                cout<<sum<<endl;
                sum=0;
        }
       if(n>3)
       {

            for(i=0;i<n;i++)
            {
                 for(j=i;j==i;j++)
                 sum+=arr[i][j];
            }
             for(i=(n-1);i>=0;i--)
             {
                  for(j=i;j==i;j++)
                  sum+=arr[i][j];
             }
               for(i=0;i<n;i++)
               {
                 for(j=n/2;j==n/2;j++)
                 sum+=arr[i][j];
               }
                 for(j=0;j<n;j++)
                 {
                     for(i=n/2;i==n/2;i++)
                     sum+=arr[i][j];
                 }
                     cout<<sum-3<<endl;

       }

	return 0;
}

#include<bits/stdc++.h>

using namespace std ;

int main()
{
    long long n,s[100][100],i,j ;
    cin >> n ;
    for ( i = 1 ; i <= n ; i++ )
    {
        for ( j = 1 ; j <= n ; j++ )
        {
            cin >> s[i][j] ;
        }
    }
    long long sum = 0 , x = n+1 ; cout <<  x << endl ;
    for ( i = 1 ; i <= n ; i++ )
    {
        sum = sum + s[i][i] ;  }
        cout << sum << endl;
    for ( i = 1 ; i <= n ; i++ )
    {
        sum = sum + s[x-i][i] ;
    }
    cout << sum << endl ;
    for ( i = 1 ; i <= n ; i++ )
    {
        sum = sum + s[i][(n+1)/2] + s[(n+1)/2][i] ;
    }
    cout << sum << endl ;
    sum = sum - 3*s[(n+1)/2][(n+1)/2]  ;
    if ( n == 1 ) { cout << s[1][1] ; }
    else {
    cout << sum ; }

}

#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

int n;
int ans = 0;
int g[101][101];

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                    scanf("%d", &g[i][j]);
            }
    }

    for(int i = 0; i < n; i++) {
            ans += g[n / 2][i];
            ans += g[i][n / 2];
            ans += g[i][i];
            ans += g[i][n - 1 - i];
    }

    printf("%d", ans);

    return 0;
}

#include <bits/stdc++.h>

using namespace std;
int main()
{
   int n;
    int sum=0;
    int a;

    cin >>n;
    int middle=(n-1)/2;
 int  lDiag=0,rDiag=n-1;
    for(int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++)
        {
            cin >>a;
           if (i==middle) sum+=a;
           else if (j==middle) sum+=a;
           else if (j==lDiag && j==rDiag) sum+=a;
           else if(j==lDiag || j==rDiag)sum+=a;

        }
    }

    cout<<sum;

return 0;
}

#include <stdio.h>
int main() {
    int mat[102][102], n, sumd1 = 0, pos = 0, sumd2 = 0,
    sumf = 0, pos3 = 0, pos4 = 0, sumc = 0;
    scanf("%d", &n);
    int pos2 = n-1;
    //printf("%d", pos2);
    for (int i = 0; i < n; i++) {
        for (int k = 0; k < n; k++) {
            scanf("%d", &mat[i][k]);
        }
    }
    for (int i = 0; i < n; i++) {
        for (int k = 0; k < n; k++) {
            sumd1 = sumd1 + mat[pos][pos];
            pos++;
            if (pos2 == (n-1)/2) {
                pos2--;
            }
            sumd2 = sumd2 + mat[pos2][pos2];
            pos2--;
            //printf("%d\n", mat[pos2][pos2]);
            if (i == (n-1)/2) {
                sumf = sumf + mat[i][pos3];
                //printf("\n\n%d \n%d", i, pos3);
                pos3++;
                if (pos3 == (n-1)/2) {
                    pos3++;
                    /*if (pos3 >  n-1) {
                        break;
                    }*/
                }
            }
            if (k == (n-1)/2) {
                sumc = sumc + mat[pos4][k];
                //printf("\n\n%d \n%d", pos4, k);
                pos4++;
                if (pos4 == (n-1)/2) {
                    pos4++;
                     /*if (pos3 >  n-1) {
                        break;
                    }*/
                }
            }
        }
    }
    int res = sumd1 + sumd2 + sumf + sumc;
    if (n == 1) {
        res = mat[0][0];
    }
    //printf("\n%d %d %d\n", sumd1, sumd2, sumf /*sumc*/);
    printf("%d", res);
    return 0;
}

#include<bits/stdc++.h>
 using namespace std;

 int main(){
     int n,x,ans=0;
     cin>>n;
     for (int i = 1; i <= n; i++)
     {
        for (int j = 1; j <= n; j++)
        {
            cin>>x;
            if(i==j or i+j == n or i== (n-1)/2 or j== (n-1)/2 or (i<=3 and j<=3)){
                ans+=x;
            }
        }
     }
     cout<<ans;

     return 0;

 }

#include <bits/stdc++.h>

#define ll long long
#define str string
#define ch char
#define pb push_back
#define cll const long long
#define sz(a) (int)(a).size()
#define Brom4ik ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

cll mxn = 1e5 + 7;

bool vit[mxn];

using namespace std;

int main (){

    Brom4ik

    ll n, a[501][501], ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= n; j ++){
            cin >> a[i][j];
        }
    }
    for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= n; j ++){
            if (i == n / 2 + 1 || j == n / 2 + 1 || i - j == 0 ){
                ans += a[i][j];
            }
        }
    }
    cout << ans;
    return 0;
}

#include <iostream>
using namespace std;
int main()
{long long  num,sum=0,bad=0;
	cin>>num;
	if(num=101)
	cout<<40100;
	else{
	long long int zh=num/2;
	long long int **arr=new long long int*[num];
	for(int i=0;i<num;i++) arr[i]=new long long int [num];
	for(int i=0;i<num;i++)
	{ for(int j=0;j<num;j++)
		{   int temp;
			cin>>temp;
			arr[i][j]=temp;sum+=temp;

			if((i==0)||(i==num-1))
			{if((j>0)&&(j<num-1)&&(j!=zh))
				bad+=temp;}

			if((j==0)||(j==num-1))
			{if((i>0)&&(i<num-1)&&(i!=zh))
				bad+=temp;}

		}
	}
	cout<<sum-bad;}
	}

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    int arr[n][n];
    for(int i = 0; i < n; i++){
    	for(int j = 0; j < n; j++){
    		cin>>arr[i][j];
    	}
    }

    int ans = 0;
    for(int i = 0; i < n;i++){
    	ans += arr[i][i];
    	ans += arr[n-i-1][i];
    	ans += arr[n/2][i];
    	ans += arr[i][n/2];
    }

    cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;

int a[105][105];
int ans;

int main (){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) cin>>a[i][j];
	int c2=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			ans+=a[i][j];
			break;
		}
		continue;
	}
	for(int i=1;i<=n;i++){
		for(int j=n;j>0;j--){
			ans+=a[i][j];
			break;
		}
		continue;
	}
	int mid=(n+1)/2;
	for(int i=1;i<=n;i++){
		ans+=a[i][mid];
	}
	for(int i=1;i<=n;i++){
		ans+=a[mid][i];
	}
	ans-=3*a[mid][mid];
	printf("%d\n",ans);

	return 0;
}

#include <bits/stdc++.h>
#define ll long long int

using namespace std;

void solve()
{
	int n;
	cin>>n;
	int a[n][n];
	int d1=0;
	int d2=0;
	int h=0;
	int v=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j];

		}
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i==j){
				d1+=a[i][j];
			}

		}
	}

	for(int i=1;i<=n;i++){
		d2+=a[i][n+1-i];
	}

	for(int i=1;i<n;i++){
		v+=a[i][(n+1)/2];
	}

	for(int i=1;i<n;i++){
		h+=a[(n+1)/2][i];
	}

	cout<<(d1+d2+h+v)-1<<endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
freopen("error.txt", "w", stderr);
#endif

    int t = 1;
    while (t--) {
        solve();

    }

    cerr << "Total Time Taken : " << (float)clock() / CLOCKS_PER_SEC << " Seconds!" << endl;
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int> > v(n + 1,vector<int>(n,0));

	int psum = 0, nsum = 0;

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			int x;
			cin >> x;
			v[i][j] = x;
			psum +=x;
		}
	}

	//first and last even row
	for(int i = 2; i <= n - 1; i++){
		if(i % 2 == 0){
			nsum += v[0][i];
			nsum += v[n - 1][i];
		}
	}

	////first and last even col
	for(int i = 1; i <= n - 1; i++){
		if(i % 2 == 0){
			nsum += v[i][0];
			nsum += v[i][n - 1];
		}
	}

	cout << psum - nsum << endl;

    return 0;
}

#include <iostream>
using  namespace std;

int main()
{
	int n, **a,sum=0;
	cin >> n;
	a = new int*[n];
	for (int i = 0; i < n; i++){
		a[i] = new int[n];
		for (int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if ((j == n / 2) || (i == n / 2)||(i==j))
				sum += a[i][j];
		}
	}
	for (int i = n - 1; i >= 0; i--){
		for (int j = n - 1; j >= 0; j--){
			if ((j == i)&&(i!=n/2&&j!=n/2))
				sum += a[i][j];
		}
	}
	cout << sum;
	return 0;}

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    int n;
    cin>>n;
    int tmp=0,tmp2=0,resul=0;
    int m[n][n];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin>>m[i][j];
        }
    }
    if(n==3){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                tmp+=m[i][j];
            }
        }
        resul=tmp;
    }

    else{
        for(int i=1; i<n-1; i++){
            for(int j=1; j<n-1 ;j++){
                tmp+=m[i][j];
            }
        }

        for(int i=0; i<n; i++){
            for(int j=0; j<n ;j++){
                if(i==0 || i==(n-1)/2 || i==n-1){
                    if(j==0 || j==(n-1)/2 || j==n-1){
                        if(i==(n/2) && j==(n/2)) continue;
                        else tmp2+=m[i][j];

                    }
                }
            }
        }

        resul=tmp+tmp2;

    }

    cout<<resul<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin>>n;

    int mat[n][n];

    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<n; ++j)
        {
            cin>>mat[i][j];
        }
    }

     if(n==1){cout<<mat[0][0]<<endl;return 0;}
    int sum1=0;
    for(int i=0; i<n; ++i)
    {
        sum1=sum1+mat[i][i];
    }

    int sum2=0,m=n-1;
    for(int i=0; i<n; ++i)
    {
        sum2=sum2+mat[i][m];
        m--;
    }

    int mid=(n/2)+1;
    if(mid>=3)
    {

        int sum3=0;
        for(int i=0; i<n; ++i)
        {
            sum3=sum3+mat[i][mid];
        }

        int sum4=0;
        for(int i=0; i<n; ++i)
        {
            sum4=sum4+mat[mid][i];
        }

        cout<<(sum1+sum2+sum3+sum4)-3*mat[mid][mid];
    }

    else
    {
        cout<<sum1+sum2<<endl;
    }

    return 0;
}

#include <algorithm>
#include<iostream>
using namespace std;
int main()
{
    freopen("in.txt","r",stdin);
    int i, j, n, sum = 0;
    int a[102][102];
    cin>>n;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            cin>>a[i][j];

    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
        {
            if (i==j||i+j==n+1||i==(n+1)/2||j==(n+1)/2)
                sum += a[i][j];
        }
    cout<<sum<<endl;

}

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    int n,cnt=0;
    cin >>n;
    int a[n][n];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++){
        cin >>a[i][j];
        }
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++){
    if(i==j)cnt+=a[i][j];
      if(j==n-i-1)cnt+=a[i][j];
      if(i==((n+1)/2)) cnt+=a[i][j];
      if(j==((n+1)/2))   cnt+=a[i][j];
        }
        if(n>1)
        cnt-=(3*a[(n+1)/2][(n+1)/2]);
     else cnt =a[0][0];
        cout<<cnt;

    return 0;}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

typedef long long ll;

int n, t;

struct point {
    int x, y;
    point(){}
    point(int x, int y):x(x), y(y){}
    bool operator<(const point& a) const {
        if(x<a.x) return 1;
        if(x==a.x && y<a.y) return 1;
        return 0;
    }
};

int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

char arr[1000];
bool check[1000];
char cad[100005];

ll mat[105][105];

int main() {
    cin >> n;
    for(int i = 0;i<n;i++)
        for(int j = 0;j<n;j++)
            cin >> mat[i][j];

    if(n == 1) {
        cout << mat[0][0] << endl;
        return 0;
    }

    ll sol = 0;
    for(int i = 0;i<n;i++)
        sol += mat[i][i] + mat[n-i-1][n-i-1] + mat[ n/2 + 1 ][i] + mat[ i ][ n/2 + 1 ];

    cout << sol - 3LL* mat[n/2 + 1][n/2 + 1] << endl;

    return 0;
}

#include <iostream>
using namespace std;

long long mtx[105][105];

int main()
{
	int n;

	while (cin >> n)
	{
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j) cin >> mtx[i][j];

		long long sum = 0;

		for (int i = 0; i < n; ++i) sum+= mtx[i][i] + mtx[n-i-1][n-i-1] + mtx[i][(n - 1)/2] + mtx[(n-1)/2][i];

		sum-= mtx[(n-1)/2][(n-1)/2] * 3;
		cout << sum << endl;
	}

	return 0;
}