提交时间:2023-12-17 13:46:07
运行 ID: 222876
#include<bits/stdc++.h> using namespace std; int n = 0; long long sum = 0; int tmp = 0; long long temp = 0; int a = 0; long long summ = 0; int gb1=0,gb2=0; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for(int i = 0;i < n;i++) { cin >> tmp; temp += tmp; if(i) { if(tmp + a < tmp * a) { gb1 = tmp; gb2 = a; } } a = tmp; } cout << temp - gb1 - gb2 + gb1 * gb2<< endl; return 0; }