#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  while (cin >> N >> K && (N | K)) {
    int C[N];
    for (int i = 0; i < N; i++) {
      cin >> C[i];
    }
    int mx1 = 1;
    for (int i = 0; i < N; i++) {
      int mul = 1;
      for (int j = i; j < i + K; j++) {
        if (j >= N) {
          mul = 0;
          break;
        }
        mul *= C[j];
      }
      mx1 = max(mx1, mul);
    }
    int ans = -1 << 29;
    for (int i = 0; i < N; i++)
      for (int j = i + 1; j < N; j++) {
        swap(C[i], C[j]);
        for (int k = 0; k < N; k++) {
          int mul = 1;
          for (int l = k; l < l + K; l++) {
            if (l >= N) {
              mul = -1 << 29;
              break;
            }
            mul *= C[l];
          }
          ans = max(ans, mul - mx1);
        }
        swap(C[i], C[j]);
      }
    if (ans < 0) {
      cout << 0 << endl;
    } else {
      cout << ans << endl;
    }
  }
  return 0;
}
