Just checking them in loop for n[i][i] would solve the isuue.