#include <bits/stdc++.h>
#define ll long long
#define INF (1LL << 60)
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 5003;

#define getchar getchar_unlocked

inline int in() {
    int n, c;
    while ((c = getchar()) < '0') if (c == EOF) return -1;
    n = c - '0';
    while ((c = getchar()) >= '0') n = n * 10 + c - '0';
    return n;
}

int b[MAX_N][200];
ll dp[MAX_N][MAX_N];
ll sm[MAX_N];
int n,m;

template<typename T> class SparseTable {
private:
    vector<T> Arr;
    vector<int> LogTable;
    vector<vector<int> > Table; //最小値のインデックスを保持
    int sz;
public:
    SparseTable(int kind){
        sz = n;
        Arr.resize(sz);
        rep(i,sz){
            Arr[i] = b[i][kind];
        }
        LogTable.resize(sz+1);
        for(int i = 2; i < sz + 1; i++){
            LogTable[i] = LogTable[i >> 1] + 1;
        }
        Table.resize(sz,vector<T>(LogTable[sz]+1));
        rep(i,sz){
            Table[i][0] = i;
        }
        for(int k = 1; (1 << k) <= sz; k++){
            for(int i = 0; i + (1 << k) <= sz; i++){
                int s = Table[i][k-1];
                int t = Table[i + (1 << (k-1))][k-1];
                if(Arr[s] > Arr[t]){
                    Table[i][k] = s;
                }else{
                    Table[i][k] = t;
                }
            }
        }
    }
    pair<T,int> query(int l,int r){
        int k = LogTable[r-l];
        if(Arr[Table[l][k]] > Arr[Table[r-(1<<k)][k]]){
            return make_pair(Arr[Table[l][k]],Table[l][k]);
        }else{
            return make_pair(Arr[Table[r-(1<<k)][k]],Table[r-(1<<k)][k]);
        }
    }
};

inline void dfs(int l, int r, SparseTable<int>& sp)
{
    if(r <= l) return;
    P p = sp.query(l,r);
    dp[l][r] += p.fi, dp[l][p.se] -= p.fi, dp[p.se+1][r] -= p.fi, dp[p.se+1][p.se] += p.fi;
    dfs(l,p.se,sp), dfs(p.se+1,r,sp);
}

int main()
{
    n = in(), m = in();
    rep(i,n-1){
        int a = in();
        sm[i+2] = sm[i+1] + a;
    }
    rep(i,n){
        rep(j,m){
            b[i][j] = in();
        }
    }
    rep(i,m){
        SparseTable<int> sp(i);
        dfs(0,n,sp);
    }
    rep(i,n+1){
        rrep(j,n+1){
            dp[i][j] += dp[i][j+1];
        }
    }
    rrep(j,n+1){
        rep(i,n+1){
            dp[i+1][j] += dp[i][j];
        }
    }
    ll ans = -INF;
    rep(i,n){
        srep(j,i+1,n+1){
            cmx(ans,dp[i][j]-(sm[j]-sm[i+1]));
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 199904