#include <cstdio>
#include <utility>
#include <algorithm>
#include <smmintrin.h>

using std::scanf;
using std::printf;
using std::max;
using std::min;
using std::pair;
using std::make_pair;

template <typename T, typename U>
inline void chmin(T& a,U b){a=min<T>(a,b);}
template <typename T, typename U>
inline void chmax(T& a,U b){a=max<T>(a,b);}

typedef int loop_int_;
#define REP(i,n) for(loop_int_ i=0;i<(loop_int_)n;i++)
#define FOR(i,a,b) for(loop_int_ i=(loop_int_)a;i<(loop_int_)b;i++)
#define FORR(i,a,b) for(loop_int_ i=(loop_int_)b-1;i>=(loop_int_)a;i--)

#define AL16 __attribute__((aligned(16)))

// static inline __m128i __attribute__((always_inline))
// po_mm_max_epi64(__m128i a, __m128i b){
//   __m128i c;
//   __asm__("vpmaxsq %0, %1, %2" : "+x" (c) : "xm" (a), "xm" (b));
//   return c;
// }
static inline __m128i __attribute__((always_inline))
po_mm_cmpgt_epi64(__m128i a, __m128i b){
  __asm__("pcmpgtq %1, %0" : "+x" (a) : "xm" (b));
  return a;
}

namespace sparse_table{
  const int ST_MAX = 5000;
  const int ST_K = 13;  // 2^12 = 4096 < 5000
  const int ST_2K = 4096;
  unsigned long long st[ST_K][ST_MAX + ST_2K/2] AL16;

  short mylog[ST_MAX+1];
  void precalc(){
    // mylog[0] = 0;
    mylog[1] = 0;
    FOR(i,2,ST_MAX+1)mylog[i]=mylog[i/2]+1;
  }

  inline unsigned long long zip(unsigned int v,unsigned int p){
    return ((unsigned long long)v<<32) | ((unsigned long long)p);
  }
  const int MASK = 4294967295;
  inline void unzip(long long z,unsigned int &v,unsigned int &p){
    v = (unsigned int)(z>>32);
    p = (unsigned int)(z&MASK);
  }

  // O(nlogn)
  void init(int n, unsigned int *arr){
    REP(i,n)st[0][i] = zip((unsigned int)(arr[i]),(unsigned int)i);
    FOR(i,n,ST_MAX)st[0][i] = 0;
    // {
    //   const __m128i zero = _mm_setzero_si128();
    //   __m128i posx = {0, 1};
    //   __m128i posy = {2, 3};
    //   const __m128i adder = {4, 4};
    //   for(unsigned int i=0;i<ST_MAX;i+=4){
    //     __m128i xx = _mm_load_si128((__m128i*)(arr+i));
    //     __m128i yy = _mm_unpackhi_epi32(zero,xx);
    //             xx = _mm_unpacklo_epi32(zero,xx);
    //     xx = _mm_add_epi32(xx,posx);
    //     yy = _mm_add_epi32(yy,posy);
    //     _mm_store_si128((__m128i*)(st[0]+i),xx);
    //     _mm_store_si128((__m128i*)(st[0]+2+i),yy);
    //     posx = _mm_add_epi32(posx,adder);
    //     posy = _mm_add_epi32(posy,adder);
    //   }
    // }
    // int base = 1;
    // FOR(k,1,ST_K){
    //   REP(i,ST_MAX)st[k][i] = max(st[k-1][i], st[k-1][i+base]);
    //   base <<= 1;
    // }
    REP(i,ST_MAX)st[1][i] = max(st[0][i],st[0][i+1]);
    int base = 2;
    FOR(k,2,ST_K){
      for(unsigned int i=0;i<ST_MAX;i+=2){
        __m128i xx = _mm_load_si128((__m128i*)(st[k-1]+i));
        __m128i yy = _mm_load_si128((__m128i*)(st[k-1]+base+i));
        // _mm_max_epi64 ってないの……
        __m128i zz = po_mm_cmpgt_epi64(xx,yy);
        xx = _mm_and_si128(zz,xx);
        yy = _mm_andnot_si128(zz,yy);
        xx = _mm_or_si128(xx,yy);
        _mm_store_si128((__m128i*)(st[k]+i),xx);
      }
      base <<= 1;
    }
  }
  // O(1)
  // [l,r)
  long long rmq(int l,int r){
    int lg = mylog[r-l];
    return max(st[lg][l], st[lg][r-(1<<lg)]);
  }
}

int n,m;
long long a[5000] AL16;
unsigned int b[200][5000] AL16;

long long imos[5004][5004] AL16;
pair<short,short> stack[5000];
int stack_tail;

int main(){
  scanf("%d%d",&n,&m);
  REP(i,n-1)scanf("%lld",a+i+1);
  REP(i,n)REP(j,m)scanf("%u",&b[j][i]);
  // REP(i,n-1)a[i+1] = 1;
  // REP(i,n)REP(j,m)b[j][i] = 1;

  REP(i,n-1)a[i+1] += a[i];
  
  sparse_table::precalc();

  REP(i,m){
    sparse_table::init(n, b[i]);
    stack_tail = 0;
    stack[stack_tail++] = make_pair<short,short>(0,n);
    REP(_,n){
      // printf("stacktail %d\n",stack_tail);
      stack_tail--;
      int l = stack[stack_tail].first;
      int r = stack[stack_tail].second;
      // printf("(l,r) = (%d,%d)\n",l,r);
      unsigned int v,p;
      sparse_table::unzip(sparse_table::rmq(l,r), v, p);
      // printf("(v,p) = (%u,%u)\n",v,p);
      imos[l  ][p] += v;
      imos[p+1][p] -= v;
      imos[l  ][r] -= v;
      imos[p+1][r] += v;
      if(l<p)stack[stack_tail++] = make_pair<short,short>(l,p);
      if(p+1<r)stack[stack_tail++] = make_pair<short,short>(p+1,r);
    }
  }

  REP(i,n)FOR(j,max(0,i-1),n)imos[i][j+1] += imos[i][j];
  REP(i,n)FOR(j,max(0,i-1),n)imos[i+1][j] += imos[i][j];
  // REP(i,n-1){
  //   // imos[i+1] += imos[i]
  //   int beg = max(0,i-1);
  //   if(beg&1){
  //     imos[i+1][beg] += imos[i][beg];
  //     beg++;
  //   }
  //   for(;beg<n;beg+=2){
  //     __m128i xx = _mm_load_si128((__m128i*)(imos[i+1]+beg));
  //     __m128i yy = _mm_load_si128((__m128i*)(imos[i]+beg));
  //     xx = _mm_add_epi64(xx,yy);
  //     _mm_store_si128((__m128i*)(imos[i+1]+beg),xx);
  //   }
  // }

  long long ans = 0;
  REP(i,n)FOR(j,i,n)chmax(ans,imos[i][j]-a[j]+a[i]);
  printf("%lld\n",ans);
}


Measured memory_bytes: 121472