#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
const int MAXN = 5010;

int N, M;
vector<vector<int>> A;
vector<int64> D, pref;

template <class T>
struct SparseTable {
    int N;
    
    vector<vector<T>> table;
    vector<int> logs;
    
    T op(T a, T b) {
        return max(a, b);
    }

    void ComputeLogs(int N) {
        logs.resize(N + 1);
        logs[0] = logs[1] = 0;
        for (int i = 2; i <= N; i++) {
            logs[i] = logs[i / 2] + 1;
        }
    }

    void BuildSparseTable(const vector<T>& A) {
        N = A.size();
        ComputeLogs(N);

        table = vector<vector<T>> (logs[N] + 1, vector<T>(N));

        for (int i = 0; i <= logs[N]; i++) {
            int curLen = 1 << i; // 2^i
            for (int j = 0; j + curLen <= N; j++) {
                if (curLen == 1) {
                    table[i][j] = A[j];
                } else {
                    table[i][j] = op(table[i - 1][j], table[i - 1][j + (curLen / 2)]);
                }
            }
        }
    }

    int GetOp(int l, int r) {
        if (l > r)
            swap(l, r);
        int p = logs[r - l + 1];
        int pLen = 1 << p; // 2^p
        return op(table[p][l], table[p][r - pLen + 1]);
    }
};

// Memory
SparseTable<int> RMQ[200];

int64 GetDist(int i, int j) {
    if (i < j)
        swap (i, j);
    return pref[i] - pref[j];
}

int64 calc(int l, int r, int optl, int optr) {
    if (l > r)
        return 0;

    int m = (l + r) >> 1;

    int64 bst = 0;
    int bsto = optl;

    //debug() << l << " " << r << ": " << optl << " " << optr;

    for (int o = max(m, optl); o <= optr; o++) {
        int64 cur = -GetDist(o, m);
        for (int i = 0; i < M; i++) {
            cur += RMQ[i].GetOp(o, m);
        }

        if (cur > bst) {
            bst = cur;
            bsto = o;
        }
    }

    return max(bst, max(calc(l, m - 1, optl, bsto), calc(m + 1, r, bsto, optr)));
}

// void Test() {
//     vector<int> v = {3, 5, 7, 0, 1, -2};
//     SparseTable<int> rmq;
//     rmq.BuildSparseTable(v);

//     for (int i = 0; i < v.size(); i++) {
//         for (int j = i; j < v.size(); j++) {
//             debug() << i << " " << j << " : " << rmq.GetOp(i, j);
//         }
//     }
// }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> M;
    D.resize(N);
    pref.resize(N);
    for (int i = 1; i < N; i++) {
        cin >> D[i];
        pref[i] = pref[i-1] + D[i];
    }

    A = vector<vector<int>> (N, vector<int>(M));

    for (int i = 0; i < N; i++)
        for (int j = 0; j < M; j++)
            cin >> A[i][j];

    for (int i = 0; i < M; i++) {
        vector<int> v (N);
        for (int j = 0; j < N; j++)
            v[j] = A[j][i];
        RMQ[i].BuildSparseTable(v);
    }

    cout << calc(0, N - 1, 0, N - 1) << "\n";

    return 0;
}


Measured memory_bytes: 61312