#include #include using namespace std; using isize = size_t; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; using i128 = __int128_t; using u128 = __uint128_t; using f64 = long double; using p2 = pair; using el = tuple; using mint = atcoder::modint998244353; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(3); _main(); } i32 pow(i32 x, i32 n) { i32 res = 1; i32 a = x; while (n > 0) { if (n & 1) res *= a; a *= a; n >>= 1; } return res; } void _main() { i64 t; cin >> t; for (;t--;) { i64 n; cin >> n; vector a(n); bool zero = false; for (i64 i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 0) zero = true; } sort(a.begin(), a.end()); if (zero) { cout << "0\n"; continue; } if (a[0] < 0 && a[n - 1] > 0) { i64 x = -1e18, y = 1e18; for (i64 i = 0; i < n; i++) { if (a[i] < 0) x = max(x, a[i]); else y = min(y, a[i]); } cout << x * y << "\n"; continue; } if (a[0] < 0) { for (i64 i = 0; i < n; i++) { a[i] = -a[i]; } reverse(a.begin(), a.end()); } cout << a[0] * a[n - 1] << "\n"; } }