For brute force partition run two nested loops and remove a[i] and a[j] from the array and insert (a[i] * a[j] ) into the array. Repeat the process until you get the desired size.
Spoiler
// left is number of times we need to compress the array
void partition(int left, vector <ll> v1){
if(left==0){
ll temp=0;
for(auto itr: v1){
temp+=itr;
}
sum=min(sum,temp);
return;
}
for(ll i=0;i<v1.size();i++){
for(ll j=i+1;j<v1.size();j++){
vector <ll> v2;
v2.pb(v1[i]*v1[j]);
for(ll k=0;k<v1.size();k++){
if(k!=i && k!=j){
v2.pb(v1[k]);
}
}
partition(left-1,v2);
}
}
}