#include <bits/stdc++.h>
using namespace std;
int getscore(int n, int k, int *in) {
  int ret = 0;
  for (int i = 0; i + k <= n; i++) {
    int tmp = 1;
    for (int j = 0; j < k; j++) {
      tmp *= in[i + j];
    }
    ret = max(ret, tmp);
  }
  return ret;
}
int main() {
  int n, k;
  int in[500];
  while (cin >> n >> k && n) {
    for (int i = 0; i < n; i++) {
      cin >> in[i];
    }
    int ans = 0;
    int tmp = getscore(n, k, in);
    for (int i = 0; i < n - 1; i++) {
      swap(in[i], in[i + 1]);
      int t2 = getscore(n, k, in) - tmp;
      ans = max(ans, t2);
      swap(in[i], in[i + 1]);
    }
    cout << ans << endl;
  }
}
