Find the sum of all the elements in the matrix which do not lie at the border


Description

You are given a matrix A of size N X M. Find the sum of all the elements in the matrix which do not lie at the border.

Input

The first line of the input contains N and M, denoting the dimensions of the matrix.

The next N lines contain M space separated integers each, denoting the elements of the matrix.

Constraints

1 <= N, M <= 100

1 <= A[i][j] <= 100

Output

Print a single integer denoting the sum of all the elements in the matrix, which do not lie at the border.

Sample Input 1 

4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

Sample Output 1

34

Hint

In the sample test case, the elements which do not lie at the border, are {6,7,10,11}. Therefore, the sum of the elements are => 6 + 7 + 10 + 11 = 34, which is the required answer.

Comments

Popular posts from this blog

Multer file upload and delete - Nodejs, Mongodb, Express

Money Management

Sub array quest IX