#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
#include <functional>

template <class T>
struct SegmentTree {
    using Merger = std::function<T(T, T)>;

    int length;
    std::vector<T> dat;
    T unit;
    Merger merge;

    explicit SegmentTree(int n, T unit, Merger merge)
        : length(1), unit(unit), merge(merge) {
        while (length < n) length <<= 1;
        dat.assign(length * 2, unit);
    }

    T query(int ql, int qr) {
        ql = std::max(ql, 0);
        qr = std::min(qr, length);
        ql += length, qr += length;

        T lacc = unit, racc = unit;
        while (ql < qr) {
            if (ql & 1) {
                lacc = merge(lacc, dat[ql]);
                ++ql;
            }
            if (qr & 1) {
                --qr;
                racc = merge(dat[qr], racc);
            }
            ql >>= 1, qr >>= 1;
        }
        return merge(lacc, racc);
    }

    void update(int nidx, T elem) {
        nidx += length;
        dat[nidx] = elem;

        while (nidx > 0) {
            nidx >>= 1;
            T vl = dat[nidx * 2 + 0];
            T vr = dat[nidx * 2 + 1];
            dat[nidx] = merge(vl, vr);
        }
    }
};

using lint = long long;

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<lint> xs(n);
    xs[0] = 0;
    for (int i = 1; i < n; ++i) {
        lint d;
        std::cin >> d;
        xs[i] = xs[i - 1] + d;
    }

    auto yss = vec(m, vec(n, 0LL));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            std::cin >> yss[j][i];
        }
    }

    auto dp = vec(n + 1, vec(n + 1, 0LL));
    for (const auto& ys : yss) {
        SegmentTree<std::pair<lint, int>>
            seg(n, std::make_pair(0, 0),
                [](auto a, auto b) { return std::max(a, b); });

        for (int i = 0; i < n; ++i) {
            seg.update(i, std::make_pair(ys[i], i));
        }

        std::queue<std::pair<int, int>> segs;
        segs.emplace(0, n);
        while (!segs.empty()) {
            int l, r;
            std::tie(l, r) = segs.front();
            segs.pop();
            if (r <= l) continue;

            lint v;
            int i;
            std::tie(v, i) = seg.query(l, r);

            // l <= x <= i, i <= y < r
            dp[l][i] += v;
            dp[l][r] -= v;
            dp[i + 1][i] -= v;
            dp[i + 1][r] += v;

            segs.emplace(l, i);
            segs.emplace(i + 1, r);
        }
    }

    for (int l = 1; l < n; ++l) {
        for (int r = 0; r < n; ++r) {
            dp[l][r] += dp[l - 1][r];
        }
    }
    for (int l = 0; l < n; ++l) {
        for (int r = 1; r < n; ++r) {
            dp[l][r] += dp[l][r - 1];
        }
    }

    lint ans = 0;
    for (int r = 0; r < n; ++r) {
        for (int l = 0; l <= r; ++l) {
            ans = std::max(ans, dp[l][r] - (xs[r] - xs[l]));
        }
    }

    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 204032