#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;

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

template<typename T> class SparseTable {
private:
    int sz;
    vector<T> arr;
    vector<int> logTable;
    vector<vector<int> > table; //最小値のインデックスを保持
    bool max_query;
    bool greater(T a, T b){ return (max_query) ? (a > b) : (a < b); }
public:
    SparseTable(vector<T>& v, bool max_query_=false) : sz((int)v.size()), arr(v),
        logTable(sz+1), max_query(max_query_){
        for(int i = 2; i < sz + 1; i++){
            logTable[i] = logTable[i >> 1] + 1;
        }
        table.resize(sz,vector<T>(logTable[sz]+1));
        for(int i = 0; i < sz; i++){
            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(greater(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(greater(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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i,n-1){
        int a;
        cin >> a;
        sm[i+2] = sm[i+1] + a;
    }
    rep(i,n){
        rep(j,m){
            cin >> b[i][j];
        }
    }
    rep(i,m){
        vi hoge(n);
        rep(j,n){
            hoge[j] = b[j][i];
        }
        SparseTable<int> sp(hoge, true);
        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: 199872