#include using namespace std; const int INF = 1e9 + 7; typedef long long ll; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n; cin >> n; ll maxmn = 0; ll arr[n]; for(int i = 0; i < n; i++)cin >> arr[i]; for(int i = 0; i < n; i++){ for (int j = i+1; j <= n; j++){ ll sum = 0; ll maxm = -INF; ll g = arr[i]; for(int k = i; k < j; k++){ g = __gcd(g,arr[k]); maxm = max(maxm,arr[k]); sum += arr[k]; } //cout << g << (sum - maxm) << endl; maxmn = max(maxmn,g*(sum-maxm)); } } cout << maxmn << endl; return 0; }