#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  for (; cin >> n >> k, n;) {
    k--;
    int data[n];
    int mul[n];
    for (int i = 0; i < n; i++) {
      cin >> data[i];
      mul[i] = data[i];
    }
    int max = 0;
    int max_num = 0;
    for (int i = 0; i < n - k; i++) {
      for (int j = 1; j <= k; j++) mul[i] *= mul[i + j];
      if (max < mul[i]) {
        max = mul[i];
        max_num = i;
      }
    }
    int tmp_min = 10, tmp_max = 0;
    for (int i = 0; i < n; i++) {
      if (i >= max_num && i < max_num + k) {
        if (tmp_min > data[i]) {
          tmp_min = data[i];
        }
      } else {
        if (tmp_max < data[i]) {
          tmp_max = data[i];
        }
      }
    }
    if (tmp_max < tmp_min)
      cout << 0 << endl;
    else
      cout << (max / tmp_min * tmp_max) - max << endl;
  }
}
