提交时间:2023-11-04 11:33:19
运行 ID: 108904
#include<bits/stdc++.h> using namespace std; int main(){ int n; int a[50005]; while(n!=0){ scanf("%d",&n); if(n == 0){ break; } for(int i = 1;i <= n;i++){ scanf("%d",&a[i]); } sort(a+1,a+n+1); for(int i = n;i >= 2;i--){ a[i-1] = a[i] * a[i-1] + 1; } for(int i = 1;i <= n-1;i++){ a[i+1] = a[i] * a[i+1] + 1; } printf("%d",a[n]-a[1]); } return 0; }