代码语言:javascript复制
#include<bits/stdc .h>
using namespace std;
priority_queue<int ,vector<int>,greater<int> >q;
int main()
{
int n,sum=0;
cin>>n;
for(int i=1;i<=n;i )
{
int a;
cin>>a,q.push(a);
}
while(q.size()>=2)
{
int i=q.top();
q.pop();
int j=q.top();
q.pop();
sum =i j;
q.push(i j);
}
cout<<sum<<endl;
return 0;
}