func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   long long ara[505][505];   bool row_check(long long val) {     for (int i = 0; i < n; i++) {       long long tmp = 0;       for (int j = 0; j < n; j++) {         tmp += ara[i][j];       }       if (tmp != val) return false;     }     return true;   }   bool col_check(long long val) {     for (int i = 0; i < n; i++) {       long long tmp = 0;       for (int j = 0; j < n; j++) {         tmp += ara[j][i];       }       if (tmp != val) return false;     }     return true;   }   bool diagonal_check(long long val) {     long long tmp = 0;     for (int i = 0; i < n; i++) tmp += ara[i][i];     if (tmp != val) return false;     tmp = 0;     for (int i = 0; i < n; i++) {       tmp += ara[i][n - 1 - i];     }     return (tmp == val);   }   bool check() {     long long row = 0;     for (int i = 0; i < n; i++) row += ara[i][0];     return row_check(row) & col_check(row) & diagonal_check(row);   }   int main() {     ios_base::sync_with_stdio(false);     while (cin >> n) {       int r, c;       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           cin >> ara[i][j];           if (ara[i][j] == 0) {             r = i;             c = j;           }         }       }       if (n > 1) {         long long sum = 0;         int x = 0;         if (r == 0) x++;         for (int i = 0; i < n; i++) sum += ara[x][i];         for (int i = 0; i < n; i++) sum -= ara[r][i];         if (sum > 0) {           ara[r][c] = sum;           if (check()) {             cout << ara[r][c] << endl;           } else {             printf( -1 n );           }         } else {           printf( -1 n );         }       } else         printf( 1 n );     }     return 0;   }   