#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  while (cin >> n >> k, n || k) {
    vector<int> card(n);
    for (int i = 0; i < n; ++i) {
      cin >> card[i];
    }
    int Ck = 0;
    for (int i = 0; i < n - k + 1; ++i) {
      int a = 1;
      for (int j = 0; j < k; ++j) {
        a *= card[i + j];
      }
      Ck = max(Ck, a);
    }
    sort(card.begin(), card.end(), greater<int>());
    int maxCk = 1;
    for (int i = 0; i < k; ++i) {
      maxCk *= card[i];
    }
    cout << maxCk - Ck << endl;
  }
}
int main() {
  solve();
  return (0);
}
