文件目录

#include <iostream>
using namespace std;
int main()
{
    int m, n, a;
    cin >> m >> n;
    int sum = 0;
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            cin >> a;
            if (i == 1 || i == m || j == 1 || j == n)
                sum += a;
        }
    }
    cout << sum;
    return 0;
}