#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int N; cin >> N; vector<long long> data(N); for(int i = 0; i < N; ++i) cin >> data[i]; sort(data.begin(), data.end() ); //升序排列 long long result = max(data[0]*data[1]*data[N-1], data[N-1]*data[N-2]*data[N-3]); cout << result << endl; return 0; }