#include<bits/stdc++.h>
#define int long long
using namespace std;
priority_queue<pair<int,int> > q;
int t,n,a;
int ans,sum;
signed main()
{
cin>>t;
while(t--)
{
cin>>n;
while(!q.empty())
{
q.pop();
}
sum=0;
ans=0;
for(int i=1;i<=n;i++)
{
cin>>a;
q.push(make_pair(-a,0));
q.push(make_pair(-a,1));
ans+=a+q.top().first;
if(!q.top().second) sum+=2;
q.pop();
}
cout<<ans<<" "<<sum<<endl;
}
return 0;
}
来源:zr