Help me in solving KO_MON problem

My issue

Where am i going wrong i sorted array an took same

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin>>t;
    while(t--){
int n,x;
cin>>n>>x;
vector<int> a(n);
for(int i=0;i<n;i++){
    cin>>a[i];
}
sort(a.begin(),a.end());
int m1=-1;
int cnt=0;
for(int i=n-1;i>=0;i--){
    m1=max(m1,a[i]+x*cnt);
    cnt++;
}
cout<<m1<<"\n";



}
}

Problem Link: Monster Monster Practice Coding Problem