#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  while (cin >> n >> k, n) {
    int c[n], a, tmp = 1e9, ckd = 0, ch, pl;
    for (int i = 0; i < n; ++i) cin >> c[i];
    for (int i = 0; i < n - k + 1; ++i) {
      a = 1;
      tmp = 1e9;
      for (int j = 0; j < k; ++j) {
        a *= c[i + j];
        tmp = min(tmp, c[i + j]);
      }
      if (a > ckd) {
        ckd = a;
        ch = tmp;
        pl = i;
      }
    }
    int w = ch, x = 0;
    for (int i = 0; i < pl; ++i) {
      w = max(w, c[i]);
      x = max(x, c[i]);
    }
    for (int i = pl + k; i < n; ++i) {
      w = max(w, c[i]);
      x = max(x, c[i]);
    }
    cout << ckd / ch * w - ckd << endl;
  }
  return 0;
}
