#include<bits/stdc++.h>usingnamespacestd;constintinf=1e7;voidsolve(vector<int>&a,intk){intn=a.size();intmx=*max_element(a.begin(),a.end());vector<vector<int>>dp(n+1,vector<int>(mx+1,-inf));// dp[len][lst] is the maximum sum subsequence ending at lst with length
// len.
dp[0][0]=0;for(intcurr:a){autondp=dp;for(intlen=0;len<n;len++){for(intlst=0;lst<=mx;lst++){// Append the current element to all those subsequences.
intnval=dp[len][lst]+curr;if(len>1){nval+=lst;}ndp[len+1][curr]=max(ndp[len+1][curr],nval);}}swap(dp,ndp);}intans=0;for(intlst=1;lst<=mx;lst++){ans=max(ans,dp[k][lst]);}cout<<ans<<"\n";}intmain(){ios_base::sync_with_stdio(false);cin.tie(NULL);intt;cin>>t;while(t--){intn,k;cin>>n>>k;vector<int>a(n);for(inti=0;i<n;i++){cin>>a[i];}solve(a,k);}}