LearnPy Hub
← Arena
EasyRating 1000

Border Sum

Print the sum of the numbers on the border (first and last row, first and last column) of the grid. Count each cell once.

Input

r and c, then r rows of c integers.

Output

One integer.

Sample 1

Input
3 3
1 2 3
4 5 6
7 8 9
Output
40

Sample 2

Input
1 4
1 2 3 4
Output
10
solution.py
Output appears here
Border Sum · Python Arena problem · LearnPy Hub