#include <stdio.h>

int main(void)
{
	int d, w;		/* d: ???????\\??????, w:????????? */
	int rectangle[10][10];	/* ????????§?????? */
	int left, right;		/* ?±??????§??????????±??????????????????°?????? */
	int top, bottom;		/* ?±??????§??????????±??????????????????°????\\??????*/
	int i, j;
	int min_case = 100, max_lake = 0;	/* min_case: ?±???£????¨???????????°????, max_lake: ?±???????????????????????¨???? */
	int max_volume = 0;		/* ??????: ?±???????????????¨?????§???????????§????????? */
	int volume = 0;			/* ?±?????????? */

	while (1) {
		/* ??\??? */
		scanf("%d %d", &d, &w);
		if (d == 0 && w == 0)
			break;
		else {
			for (j = 0; j < d; j++) {
				for (i = 0; i < w; i++) {
					scanf("%d", &rectangle[i][j]);
				}
			}

			/* ?±??????§??????????±?????????¨??°???  ??°?????????B_LakeCreate?????§ */
			for (top = 0; top <= d - 3; top++) {
				for (bottom = top + 3; bottom <= d; bottom++) {
					for (left = 0; left <= w - 3; left++) {
						for (right = left + 3; right <= w; right++) {

							/* ?±???????????????????????????¢???????±??????????????±??????? */
							/* 1. ?±??????????????°????????±??????? */
							for (i = left; i < right; i++) {
								if (min_case > rectangle[i][top])
									min_case = rectangle[i][top];
								/*printf("top: i = %d, data = %d, %d\n", i, rectangle[i][top], min_case);*/
								if (min_case > rectangle[i][bottom - 1])
									min_case = rectangle[i][bottom - 1];
								/*printf("bottom: i = %d, data = %d, %d\n", i, rectangle[i][bottom - 1], min_case);*/
							}
							for (j = top + 1; j < bottom - 1; j++) {
								if (min_case > rectangle[left][j])
									min_case = rectangle[left][j];
								/*printf("left: j = %d, data = %d, %d\n", j, rectangle[left][j], min_case);*/
								if (min_case > rectangle[right - 1][j])
									min_case = rectangle[right - 1][j];
								/*printf("right: j = %d, data = %d, %d\n", j, rectangle[right - 1][j], min_case);*/
							}

							/* 2. ?±???????????¨????????????§???????±??????? */
							for (j = top + 1; j < bottom - 1; j++) {
								for (i = left + 1; i < right - 1; i++) {
									if (max_lake < rectangle[i][j])
										max_lake = rectangle[i][j];
									/*printf("i,j = %d,%d, data = %d, max = %d\n", i, j, rectangle[i][j], max_lake);*/
								}
							}

							/* 3. ?±???£???????°??????¨?±?????¨????????????§???????????? */
							if (max_lake >= min_case) {
								max_lake = 0;
								min_case = 100;
								continue;
							}
							/* 4. ?±??????????????±??????? */
							else {
								for (j = top + 1; j < bottom - 1; j++) {
									for (i = left + 1; i < right - 1; i++) {
										volume += (min_case - rectangle[i][j]);
									}
								}
							}

							/* ?±??????????????????? */
							if (max_volume < volume)
								max_volume = volume;


							/* ????????? */
							max_lake = 0;
							min_case = 100;
							volume = 0;
						}
					}
				}
			}

			/* ?????? */
			printf("%d\n", max_volume);

			/* ????????? */
			max_volume = 0;
		}
	}
	return 0;
}