#include <bits/stdc++.h>
using namespace std;
int c[101], n, k;
int func(int p, int q) {
  int mx = 1, t;
  for (int i = 0; i < k; ++i) mx *= c[i];
  t = mx;
  for (int i = p + k; i < q; ++i) {
    t /= c[i - k];
    t *= c[i];
    mx = max(t, mx);
  }
  return mx;
}
int main() {
  int cmx, s, t, p, q;
  while (cin >> n >> k && n + k) {
    cmx = 1;
    for (int i = 0; i < n; ++i) cin >> c[i];
    t = cmx = func(0, n);
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j) continue;
        swap(c[i], c[j]);
        p = max(j - k, 0);
        q = min(j + k, n);
        t = max(t, func(p, q));
      }
    }
    cout << (t - cmx) << endl;
  }
  return 0;
}
