int fun(int a[M][N]) {
int sum = 0;
for (int i = 0; i != M; i++)
for (int j = 0; j != N; j++) {
if (i == 0 || i == M - 1 || j == 0 || j == N - 1)
sum += a[i][j];
}
return sum;
}