import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int H, W;
    int[][] F;
    bool input() {
        readf("%d %d\n", &H, &W);
        if (H == 0 && W == 0) return false;
        F = iota(0, H, 1).map!((i) => readln.chomp.split(" ").map!(to!int).array).array;
        return true;
    }
    void solve() {
        int calc_vol(int sy, int sx, int ty, int tx) {
            auto ys = [sy - 1, ty + 1];
            auto xs = [sx - 1, tx + 1];
            int min_height = int.max;
            foreach (y; ys) {
                for (int x = sx - 1; x <= tx + 1; x++) {
                    min_height = min(min_height, F[y][x]);
                }
            }
            foreach (x; xs) {
                for (int y = sy - 1; y <= ty + 1; y++) {
                    min_height = min(min_height, F[y][x]);
                }
            }

            int vol = 0;
            for (int y = sy; y <= ty; y++) {
                for (int x = sx; x <= tx; x++) {
                    if (F[y][x] >= min_height) return 0;
                    vol += min_height - F[y][x];
                }
            }
            return vol;
        }

        int ans = 0;
        for (int sy = 1; sy <= H - 2; sy++) {
            for (int sx = 1; sx <= W - 2; sx++) {
                for (int ty = sy; ty <= H - 2; ty++) {
                    for (int tx = sx; tx <= W - 2; tx++) {
                        ans = max(ans, calc_vol(sy, sx, ty, tx));
                    }
                }
            }
        }
        writeln(ans);
    }
    while (input()) {
        solve();
    }
}