#include <bits/stdc++.h>
using namespace std;
int k;
int scoreMax(vector<int> &a) {
  int ans = 0;
  for (int i = 0; i < a.size() - k + 1; i++) {
    int s = 1;
    for (int j = 0; j < k; j++) {
      s *= a[i + j];
    }
    ans = max(s, ans);
  }
  return ans;
}
int main() {
  int n;
  while (cin >> n >> k && n) {
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 0, t = scoreMax(a);
    cout << t << endl;
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
        swap(a[i], a[j]), ans = max(ans, scoreMax(a) - t), swap(a[i], a[j]);
    cout << ans << endl;
  }
}
