#include <iostream>
#include <vector>

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)

int calc(vector<int>& c,int k)
{
	int res=1;
	rep(i,c.size()-k+1){
		int temp=1;
		rep(j,k)
			temp*=c[i+j];
		res=max(res,temp);
	}
	return res;
}

int main()
{
	for(int n,k;cin>>n>>k,n|k;){
		vector<int> c(n);
		rep(i,n) cin>>c[i];
		
		int before=calc(c,k);
		int after=before;
		rep(i,n) rep(j,i){
			swap(c[i],c[j]);
			after=max(after,calc(c,k));
			swap(c[i],c[j]);
		}
		cout<<after-before<<endl;
	}
	
	return 0;
}