#include using namespace std; typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; set b; b.insert(a[0]); for (int i = 1; i < n; i++) { set c(b); bool flag = (a[i] != 0); for (ll x : c) { b.insert(x * a[i]); b.insert(x + a[i]); b.insert(x - a[i]); if (flag) b.insert(x / a[i]); } } ll ans = -1e9; for (ll x : b) ans = max(ans, x); cout << ans << endl; return 0; }