提交时间:2023-11-07 21:36:45
运行 ID: 109251
#include<bits/stdc++.h> using namespace std; int n,a[1000005],sum1,sum2,ans1,ans2; int main(){ while(cin>>n&&n){ ans1=ans2=sum1=sum2=1; for(int i=1;i<=n;i++){ cin>>a[i]; } sort(a+1,a+n+1); for(int i=1;i<=n;i++){ ans1*=a[i]; } ans1++; ans2=ans1; for(int i=1;i<n-1;i++){ sum1*=a[i]; sum2*=a[n-i+1]; ans1+=sum1; ans2+=sum2; } cout<<ans2-ans1<<endl; } return 0; }