提交时间:2023-11-08 21:13:37
运行 ID: 109460
#include<bits/stdc++.h> using namespace std; bool cmp(int a,int b){ return a>b; } int n,a[1000005],a1[1000005],a2[1000005],Max,Min; int main(){ while(cin>>n&&n){ for(int i=1;i<=n;i++){ cin>>a[i]; a1[i]=a2[i]=a[i]; } for(int i=1;i<n;i++){ sort(a1+1,a1+n+1); a1[1]=a1[1]*a1[2]+1; a1[2]=0x7fffffff; } for(int i=1;i<n;i++){ sort(a2+1,a2+n+1,cmp); a2[1]=a2[1]*a2[2]+1; a2[2]=-1; } cout<<a1[1]-a2[1]<<endl; } return 0; }