#include <iostream>
#include <vector>
using namespace std;

int max4(int a, int b, int c, int d) {
  return max(max(a, b), max(c, d));
}

int min4(int a, int b, int c, int d) {
  return min(min(a, b), min(c, d));
}

int opmax(int a, int b) {
  if (b == 0) {
    return max(max(a + b, a - b), a * b);
  }
  return max4(a + b, a - b, a * b, a / b);
}

int opmin(int a, int b) {
  if (b == 0) {
    return min(min(a + b, a - b), a * b);
  }
  return min4(a + b, a - b, a * b, a / b);
}

int main() {
  int N;
  cin >> N;

  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  vector<vector<int> > DP(N);
  for (int i = 0; i < N; i++) {
    DP[i].resize(2);
    DP[i][0] = DP[i][1] = 0;
  }

  DP[0][0] = DP[0][1] = a[0];
  for (int i = 1; i < N; i++) {
    DP[i][0] = max(opmax(DP[i - 1][0], a[i]),
		   opmax(DP[i - 1][1], a[i]));
    DP[i][1] = min(opmin(DP[i - 1][0], a[i]),
		   opmin(DP[i - 1][1], a[i]));
  }

  cout << DP[N - 1][0] << endl;

  return 0;
}