#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll a[12][12];
int main(){
	ll h,w;
	while(scanf("%lld%lld",&h,&w),h){
		rep(i,0,h)rep(j,0,w)scanf("%lld",&a[i][j]);
		ll ans=0;
		//[hl,hr]×[wl,wr]を池にする
		rep(hl,1,h-1)rep(hr,hl,h-1)rep(wl,1,w-1)rep(wr,wl,w-1){
			ll inM=0;
			ll ins=0;
			ll oum=10;
			rep(hh,hl,hr+1)rep(ww,wl,wr+1){
				inM=max(inM,a[hh][ww]);
				ins+=a[hh][ww];
			}
			rep(hh,hl-1,hr+2)oum=min(oum,min(a[hh][wl-1],a[hh][wr+1]));
			rep(ww,wl-1,wr+2)oum=min(oum,min(a[hl-1][ww],a[hr+1][ww]));
			if(inM<oum)ans=max(ans,oum*(hr-hl+1)*(wr-wl+1)-ins);
		}
		printf("%lld\n",ans);
	}
}

