#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 5010;
const int M = 210;
inline int read(){
	int ans=0;
	char last=' ',ch=getchar();
	while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();
	return ans;
}
int n,m,b[N][M];
ll a[N];
int q[M][N],head[M],tail[M];
ll f[N];
ll cal(){
	memset(head,0,sizeof(head));
	memset(tail,0,sizeof(tail));
	ll ret = 0,tmp;
	for(int i=1;i<=n;i++){
		tmp = 0 ;
		for(int j=1;j<=m;j++){
			while(head[j]<tail[j] && b[i][j]>=b[q[j][tail[j]-1]][j]) tail[j]--;
			q[j][tail[j]++] = i;
		}
		memset(f,0,sizeof(f));
		tmp = 0;
		for(int j=1;j<=m;j++){
			for(int k=head[j];k<tail[j]-1;k++) f[q[j][k]] += b[q[j][k]][j]-b[q[j][k+1]][j];
			f[i] += b[i][j];
		}
		for(int k=i;k>=1;k--){
			tmp+=f[k];
			ret=max(ret,tmp-a[i]+a[k]);
		}
	}
	return ret;
}

int main(){
	n = read(), m = read();
	for(int i=2;i<=n;i++) a[i] = read(), a[i] += a[i-1];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) 
			b[i][j] = read();
	}
	printf("%lld\n",cal());
	return 0;
}