#include<cstdio>
#include <iostream>
#include<cmath>
#include<set>
#include<cstdio>
#include<algorithm>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<string>
#include<cstring>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1.0);

int a[11][11], w, h;

int chp(int y1, int y2, int x1, int x2) {
	int res = 0, ans = 0, t = 1e9;
	for (int i = y1; i <= y2; i++) {//寻找此区域内的最大高度
		for (int j = x1; j <= x2; j++) {
			res = max(res, a[i][j]);
		}
	}

	//检查是否能够围成池塘，并寻找池塘中水平面的最高高度
	for (int i = y1 - 1; i <= y2 + 1; i++) {
		for (int j = x1 - 1; j <= x2 + 1; j++) {
			if (i == y1 - 1 || i == y2 + 1 || j == x1 - 1 || j == x2 + 1) {
				if (a[i][j] <= res)return 0;
				t = min(t, a[i][j]);
			}
		}
	}

	//计算池塘容积
	for (int i = y1; i <= y2; i++) {
		for (int j = x1; j <= x2; j++) {
			ans += t - a[i][j];
		}
	}
	return ans;
}

int ch(int y, int x) {
	int ans = 0;

	//枚举池塘
	for (int i = y; i <= h - 2; i++) {
		for (int j = x; j <= w - 2; j++) {
			ans = max(ans, chp(y, i, x, j));
		}
	}
	return ans;
}

int main() {
	while (cin >> h >> w, h) {
		int ans = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> a[i][j];
			}
		}
		for (int i = 0; i < h - 1; i++) {
			for (int j = 0; j < w - 1; j++) {
				if (i&&j)ans = max(ans, ch(i, j));
			}
		}
		cout << ans << endl;
	}
	return 0;
}
