#include <bits/stdc++.h>
using namespace std;
using s64 = signed long long;
using u64 = unsigned long long;
using f128 = long double;

int main()
{
    u64 h, w;
    cin >> h >> w;
    vector<vector<u64>> a;
    for(u64 i = 0; i < h; i++)
    {
        a.push_back(vector<u64>());
        for(u64 j = 0; j < w; j++)
        {
            u64 aij;
            cin >> aij; 
            a[i].push_back(aij);
        }
    }

    u64 minBlock = ULONG_LONG_MAX;
    for(u64 i = 0; i < h; i++)
    {
        for(u64 j = 0; j < w; j++)
        {
            if(minBlock > a[i][j])
            {
                minBlock = a[i][j];
            }
        }
    }

    u64 removeBlock = 0;
    for(u64 i = 0; i < h; i++)
    {
        for(u64 j = 0; j < w; j++)
        {
            removeBlock += a[i][j] - minBlock;
        }
    }

    cout << removeBlock << endl;

    return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define forn(i,n) for(int i = 0; i < n; i++)
int32_t main() {
    int n, q, k; cin >> n >> q;
    vector<int> a(n);
    forn(i, n) cin >> a[i];
    vector<int> ps(n);
    ps[0] = a[0] - 1;
    forn(i, n - 1) ps[i + 1] = ps[i] + a[i + 1] - a[i] - 1;
    while (q--) {
        cin >> k;
        int x = --lower_bound(ps.begin(), ps.end(), k) - ps.begin();
        if (x == -1) cout << k;
        else cout << a[x] + k - ps[x];
        cout << "\n";
    }
}