Help me in solving REDUARRAY problem

My issue

#include<bits/stdc++.h>
define t int t;cin>>t;while (t–)
define ll long long
define all(x) begin(x),end(x)
define endl “\n”
using namespace std;
int main(){
t
{
int n;cin>>n;
int a[n];
int countmin=0;
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
int min=*min_element(a,a+n);
for(int i=0;i<n;i++){
if(a[i]==min){
countmin++;
}
}
cout<<(n-countmin)*min<<endl;

}

return 0;
}
what is wrong with code

My code

#include<bits/stdc++.h>
#define t int t;cin>>t;while (t--)
#define ll long long
#define all(x) begin(x),end(x)
#define endl "\n"
using namespace std;
int main(){
t
    {
        int n;cin>>n;
        int a[n];
        int countmin=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a,a+n);
        int min=*min_element(a,a+n);
        for(int i=0;i<n;i++){
            if(a[i]==min){
                countmin++;
            }
        }
        cout<<(n-countmin)*min<<endl;

    }
 return 0;
}

Problem Link: Redundant Array Practice Coding Problem

your code will fail for testcase like this
3
2 3 3
your ans=4
correct ans=3