/* -*- coding: utf-8 -*- * * 3372.cc: No.3372 Suitable Constraint - yukicoder */ #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ using ll = long long; using vi = vector; using pii = pair; /* global variables */ int as[MAX_N]; /* subroutines */ pii minmaxv(vi &bs) { int minb = *min_element(bs.begin(), bs.end()); int maxb = *max_element(bs.begin(), bs.end()); return {minb, maxb}; } /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); int zc = 0; vi pas, mas; for (int i = 0; i < n; i++) { if (as[i] > 0) pas.push_back(as[i]); else if (as[i] < 0) mas.push_back(as[i]); else zc++; } ll x = 0; if (zc > 0) x = 0; else if (mas.empty()) { auto [minp, maxp] = minmaxv(pas); x = (ll)minp * maxp; } else if (pas.empty()) { auto [minm, maxm] = minmaxv(mas); x = (ll)minm * maxm; } else { int minp = *min_element(pas.begin(), pas.end()); int maxm = *max_element(mas.begin(), mas.end()); x = (ll)minp * maxm; } printf("%lld\n", x); } return 0; }