#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { int N; cin >> N; vector A(N); for (int i = 0; i < N; i++) cin >> A[i]; bool hasZero = false; bool hasPos = false, hasNeg = false; long long minA = LLONG_MAX, maxA = LLONG_MIN; long long minPos = LLONG_MAX; // smallest positive long long maxNeg = LLONG_MIN; // largest negative (closest to 0) for (long long x : A) { if (x == 0) hasZero = true; if (x > 0) { hasPos = true; minPos = min(minPos, x); } if (x < 0) { hasNeg = true; maxNeg = max(maxNeg, x); } minA = min(minA, x); maxA = max(maxA, x); } long long ans; if (hasZero) { ans = 0; } else if (!hasPos || !hasNeg) { // all same sign ans = minA * maxA; } else { ans = minPos * maxNeg; } cout << ans << '\n'; } return 0; }