#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  while (cin >> n >> k, n || k) {
    map<int, int> mp;
    int a[200];
    priority_queue<int> q;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      q.push(a[i]);
    }
    int ck = 0;
    for (int i = 0; i < n - k + 1; i++) {
      int m = 1;
      for (int j = 0; j < k; j++) {
        m *= a[i + j];
      }
      ck = max(m, ck);
    }
    int ckd = 0;
    for (int l = 0; l < n - k + 1; l++) {
      int ma = 0;
      int m = 1;
      priority_queue<int> que;
      for (int i = 0; i < n; i++) {
        if (i >= l && i < l + k) {
          que.push(a[i]);
        } else {
          ma = max(ma, a[i]);
        }
      }
      for (int i = 0; i < k - 1; i++) {
        m *= que.top();
      }
      m *= ma;
      ckd = max(ckd, m);
    }
    if (ckd < ck)
      cout << 0 << endl;
    else
      cout << ckd - ck << endl;
  }
  return 0;
}
