#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n, k;
    while(cin >> n >> k, n+k){
        vector<int> v(n);
        rep(i, n) cin >> v[i];
        int a = 0, b = 0;
        rep(i, n-k+1){
            int t = 1;
            rep(j, k)t *= v[i+j];
            a = max(a, t);
        }

        rep(i, n)rep(j, n){
            if(i == j) continue;
            swap(v[i], v[j]);
            int t = 1;
            rep(l, n-k+1){
                int t = 1;
                rep(m, k) t *= v[l+m];
                b = max(b, t);
            }
            swap(v[i], v[j]);
        }
        cout << max(0, b-a) << endl;
    }
}