Help me in solving CHEFA problem

My issue

why am i getting the test case’s output as 13

My code

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

int main() {
int t;
cin>> t;
while(t--){
    int n,a[n] ;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
   long int sum=0;
     for(int i=n-1;i>=0;i=i-2){
         sum+=a[i];
     }
     cout<<sum<<endl;
}
return 0;
}

Learning course: Sorting using C++
Problem Link: Chef and easy problem Practice Problem in - CodeChef

@code_2004
declare a[n] after taking input of n .

ohh…done!! thanks