#include using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; template using MaxHeap = std::priority_queue; template using MinHeap = std::priority_queue, greater>; #define rep2(i, n) for (ll i = 0; i < (n); i++) #define rep3(i, l, r) for (ll i = (l); i < (r); i++) #define rrep2(i, n) for (ll i = n; i-- > 0;) #define rrep3(i, r, l) for (ll i = (r); i-- > (l);) #define overload(a, b, c, d, ...) d #define rep(...) overload(__VA_ARGS__, rep3, rep2)(__VA_ARGS__) #define rrep(...) overload(__VA_ARGS__, rrep3, rrep2)(__VA_ARGS__) #define all(x) begin(x), end(x) bool chmin(auto& lhs, auto rhs) { return lhs > rhs ? lhs = rhs, 1 : 0; } bool chmax(auto& lhs, auto rhs) { return lhs < rhs ? lhs = rhs, 1 : 0; } struct IOIO { IOIO() { std::cin.tie(0)->sync_with_stdio(0); } } ioio; void solve() { int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; if (all_of(all(a), [](ll x) { return x > 0; })) { cout << ranges::min(a) * ranges::max(a) << '\n'; } else if (all_of(all(a), [](ll x) { return x < 0; })) { cout << ranges::min(a) * ranges::max(a) << '\n'; } else if (find(all(a), 0) != end(a)) { cout << 0 << '\n'; } else { ll mn = 1e18; ll mx = -1e18; rep(i, n) { if (a[i] < 0) { chmax(mx, a[i]); } else { chmin(mn, a[i]); } } cout << mn * mx << '\n'; } } int main() { int t = 1; cin >> t; while (t--) solve(); }