Easy Math Problem

Chef has a sequence of positive integers , but he should find two different elements of this sequence such that the sum of digits (in base 1010) of their product is maximum possible.

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll int Sum(int a)
{
ll int add = 0;

while(a!=0)
{
    add+=a%10;
    a/=10;
}
return add;

}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int tc;
cin>>tc;

while(tc--)
{
    int n;
    cin>>n;
    
    int a[n];
    
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    
    vector<pair<ll int,int>> ans;
    
    for(int i=0;i<n;i++)
    {
        ll int b = Sum(a[i]);
        ans.push_back(make_pair(b,a[i]));
    }
    
    sort(ans.begin(),ans.end());
    for(auto i:ans)
    {
        cout<<i.first<<" "<<i.second<<endl;
    }
    int z = ans[ans.size()-2].second * ans[ans.size()-1].second;
    
    cout<<Sum(z)<<endl;
    
}
return 0;

}

What is going Wrong in this Code?