#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int d,w,map[11][11];
int main(){
    while(cin>>d>>w){
        if(!d&&!w) break;
        memset(map,0,sizeof map);
        for(int i=1;i<=d;i++)
            for(int j=1;j<=w;j++) cin>>map[i][j];
        int ans=0;
        for(int i=1;i<=d-2;i++)
            for(int j=1;j<=w-2;j++)
                for(int x=3;x+i-1<=d;x++)
                    for(int y=3;y+j-1<=w;y++){
                        int minn=100,maxn=-1;
                        for(int z=0;z<x;z++){
                            if(minn>map[i+z][j]) minn=map[i+z][j];
                            if(minn>map[i+z][j+y-1]) minn=map[i+z][j+y-1];
                        }
                        for(int z=0;z<y;z++){
                            if(minn>map[i][j+z]) minn=map[i][j+z];
                            if(minn>map[i+x-1][j+z]) minn=map[i+x-1][j+z];
                        }
                        for(int u=i+1;u<=i+x-2;u++)
                            for(int v=j+1;v<=j+y-2;v++) maxn=max(maxn,map[u][v]);
                        if(maxn>=minn) continue;
                        int ans0=0;
                        if(maxn<=minn){
                            for(int u=i+1;u<=i+x-2;u++)
                                for(int v=j+1;v<=j+y-2;v++) ans0+=minn-map[u][v];
                        }
                        ans=max(ans,ans0);
                    }
        cout<<ans<<endl;
    }
    return 0;
}

