#include <iostream>
#include <cmath>
using namespace std;
int main(){
int i,j,n,a[20][20],suma=0;
cout<<"Introduceti dimensiunea matricii:";
cin>>n;
cout<<"Introduceti elementele din matrice:\n";
for(i=0;i<n;i++){
for(j=0;j<n;j++){
cin>>a[i][j];
if(abs(i-j)==1){
suma+=a[i][j];
}
}
}
cout<<"Suma diagonalelor vecine este:"<<suma;
return 0;
}