#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair Pr; int N; int a[17]; queue q; int main() { cin >> N; for (int i = 0; i < N; i++) cin >> a[i]; ll num = a[0]; ll sum = num; for (int i = 1; i < N; i++) { if (num * a[i] > sum) { sum = num * a[i]; } else if (num - a[i] > sum) { sum = num - a[i]; } else if (num + a[i] > sum) { sum = num + a[i]; } else if(num != 0 && num/a[i] > sum){ sum = num / a[i]; } num = sum; } cout << sum << endl; return 0; }