#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"

int getnum(const vector<int>&as, int K) {
	int ans = 0;
	for (int l = 0; l <= as.size() - K; ++l) {
		int num = 1;
		for (int i = l; i < l + K; ++i) {
			num *= as[i];
		}
		ans = max(ans, num);
	}
	return ans;
}

int main() {
	while (1) {
		int N, K; cin >> N >> K;
		if (!N)break;
		vector<int>as(N);
		for (int i = 0; i < N; ++i) {
			cin >> as[i];
		}
		int fst = getnum(as, K);
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = 1; j < N; ++j) {
				swap(as[i], as[j]);
				int n = getnum(as, K);
				ans = max(ans, n - fst);
				swap(as[i], as[j]);

			}
		}
		cout << ans << endl;
	}
	
	return 0;
}