#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 1;
long long cs[N],ans;
int p[14] = {1},is[N],n,m,dp[200][14][N];
long long find(int l,int r){
	int dis = r - l;
	long long ret = 0;
	for(int i = 0;i < m;i++)
		ret+=max(dp[i][is[dis]][l],dp[i][is[dis]][r - p[is[dis]] + 1]);
	return ret;
}
void calc(int l,int r,int bl,int br){
	if(l > r)return;
	int mid = (l + r)/2,bst = bl,best;
	long long temp = 0,temp1 = 0,to = min(mid,br);
	for(;bst <= to;bst++){
		temp1 = find(bst,mid) - cs[mid - 1] + cs[bst - 1];
		if(temp < temp1)temp = temp1,best = bst;
	}
	ans = max(ans,temp);
	calc(l,mid - 1,bl,best);
	calc(mid + 1,r,best,br);
}
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i = 1;i < 14;i++)p[i] = p[i - 1]<<1;
	for(int i = 0,l = 0;i <= n;i++){
		while(l + 1 < 14 && p[l + 1] - 1 <= i)l++;
		is[i] = l;
	}
	for(int i = 1;i < n;i++)scanf("%lld",cs + i),cs[i]+=cs[i - 1];
	for(int i = 1;i <= n;i++)
		for(int j = 0;j < m;j++)
			scanf("%d",&dp[j][0][i]);
	for(int k = 0;k < m;k++)
		for(int i = 1;i < 14;i++)
			for(int j = 1;j <= n;j++)
				dp[k][i][j] = max(dp[k][i - 1][j],dp[k][i - 1][j + p[i - 1]]);
	calc(1,n,1,n);
	printf("%lld\n",ans);
}