#include <stdio.h>

int main(void) {
	int d, w;
	while (scanf("%d%d", &d, &w) == 2 && (d|w) != 0) {
		int e[10][10];
		int i, j, k, l;
		int answer = 0;
		for (i = 0; i < d; i++) {
			for (j = 0; j < w; j++) {
				if (scanf("%d", &e[i][j]) != 1) return 1;
			}
		}
		for (i = 0; i < d; i++) {
			for (j = 0; j < w; j++) {
				for (k = i + 2; k < d; k++) {
					for (l = j + 2; l < w; l++) {
						int min = 9999, max = -9999, sum = 0;
						int m, n;
						for (m = i; m <= k; m++) {
							for (n = j; n <= l; n++) {
								if (m == i || m == k || n == j || n == l) {
									if (e[m][n] < min) min = e[m][n];
								} else {
									if (e[m][n] > max) max = e[m][n];
									sum += e[m][n];
								}
							}
						}
						if (max < min) {
							int candidate = (k - i - 1) * (l - j - 1) * min - sum;
							if (candidate > answer) answer = candidate;
						}
					}
				}
			}
		}
		printf("%d\n", answer);
	}
	return 0;
}

