#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn=5050;
ll n,m,a[maxn][maxn],stac[maxn],l[maxn][maxn],r[maxn][maxn];
ll dis[maxn],del[maxn][maxn];
int main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=2;i<=n;++i)scanf("%lld",&dis[i]),dis[i]=dis[i]+dis[i-1];
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) scanf("%lld",&a[i][j]);
	for(int j=1;j<=m;++j)
	{
		int top=0;
		for(int i=1;i<=n;++i){
			while(top&&a[stac[top]][j]<a[i][j])--top;
			l[i][j]=top?stac[top]+1:1;
			stac[++top]=i;
		}
		top=0;
		for(int i=n;i>=1;--i){
			while(top&&a[stac[top]][j]<a[i][j])--top;
			r[i][j]=top?stac[top]-1:n;
			stac[++top]=i;
		}
		for(int i=1;i<=n;++i){
			del[l[i][j]][i]+=a[i][j];
			del[i+1][i]-=a[i][j];
			del[l[i][j]][r[i][j]+1]-=a[i][j];
			del[i+1][r[i][j]+1]+=a[i][j];
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)del[i][j]+=del[i][j-1];
		for(int j=1;j<=n;j++)del[i][j]+=del[i-1][j];
		for(int j=i;j<=n;j++)ans=max(ans,del[i][j]-dis[i]+dis[j]); 
	} 
	printf("%lld\n",ans); 
}