/*  -*- coding: utf-8 -*-
 *
 * 1618.cc: A Garden with Ponds
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 10;
const int MAX_W = 10;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int flds[MAX_H][MAX_W];

/* subroutines */

inline void setmin(int &a, int b) { if (a > b) a = b; }
inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  for (int h, w; scanf("%d%d", &h, &w) == 2 && h > 0;) {
    for (int y = 0; y < h; y++)
      for (int x = 0; x < w; x++) scanf("%d", &flds[y][x]);

    int maxc = 0;
    for (int y0 = 0; y0 < h; y0++)
      for (int y1 = y0 + 2; y1 < h; y1++)
	for (int x0 = 0; x0 < w; x0++)
	  for (int x1 = x0 + 2; x1 < w; x1++) {
	    int mino = INF, maxd = 0, dsum = 0;

	    for (int x = x0; x <= x1; x++) {
	      setmin(mino, flds[y0][x]);
	      setmin(mino, flds[y1][x]);
	    }

	    for (int y = y0 + 1; y < y1; y++) {
	      setmin(mino, flds[y][x0]);
	      setmin(mino, flds[y][x1]);

	      for (int x = x0 + 1; x < x1; x++) {
		int &d = flds[y][x];
		setmax(maxd, d);
		dsum += d;
	      }
	    }

	    if (mino > maxd)
	      setmax(maxc, mino * (y1 - y0 - 1) * (x1 - x0 - 1) - dsum);
	  }

    printf("%d\n", maxc);
  }
  return 0;
}

