#include #include using namespace std; long maximumValue(vector a) { // Return the maximum value of f among all subsegments [l..r]. int *maxf=(int*)new int; *maxf=NULL; for(int i=0;imax)max=a[j]; sum+=a[j]; gcd=__gcd(gcd,abs(a[j]); } int f=gcd*(sum-max); if(!maxf)*maxf=f; else if(*maxf> n; vector a(n); for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } long result = maximumValue(a); cout << result << endl; return 0; }