#include <bits/stdc++.h>
using namespace std;
template <class T>
void max_swap(T& a, const T& b) {
  a = max(a, b);
}
template <class T>
void min_swap(T& a, const T& b) {
  a = min(a, b);
}
const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
bool valid_pos(int x, int y, int w, int h) {
  return 0 <= x && x < w && 0 <= y && y < h;
}
int ck(const vector<int>& v, int k) {
  int res = 0;
  for (int i = 0; i + k <= v.size(); ++i) {
    int s = 1;
    for (int j = 0; j < k; ++j) s *= v[i + j];
    max_swap(res, s);
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  int ori = ck(v, k);
  int res = -1;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      vector<int> u = v;
      swap(u[i], u[j]);
      max_swap(res, ck(u, k) - ori);
    }
  }
  cout << res << endl;
}
