#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  for (; cin >> n >> k && n;) {
    int c[100], r0 = 1, r1;
    for (int i = 0; i < n; i++) cin >> c[i];
    for (int i = 0; i < n - k + 1; i++) {
      int t = 1;
      for (int j = 0; j < k; j++) t *= c[i + j];
      r0 = max(r0, t);
    }
    r1 = r0;
    for (int k = 0; k < n - 1; k++) {
      for (int l = k + 1; l < n; l++) {
        swap(c[k], c[l]);
        for (int i = 0; i < n - k + 1; i++) {
          int t = 1;
          for (int j = 0; j < k; j++) t *= c[i + j];
          r1 = max(r1, t);
        }
        swap(c[k], c[l]);
      }
    }
    cout << r1 - r0 << endl;
  }
  return 0;
}
