#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxn = 4005;
void go() {
  int n;
  cin >> n;
  long long mx[n + 5][6], mi[n + 5][6];
  memset(mx, 0xc4, sizeof(mx));
  memset(mi, 0x3f, sizeof(mi));
  mx[0][0] = mi[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    for (int j = 0; j <= 5; j++) {
      mx[i][j] = mx[i - 1][j];
      if (j && i >= j) {
        mx[i][j] = max(mx[i][j], mx[i - 1][j - 1] * x);
        mx[i][j] = max(mx[i][j], mi[i - 1][j - 1] * x);
      }
      mi[i][j] = mi[i - 1][j];
      if (j && i >= j) {
        mi[i][j] = min(mi[i][j], mx[i - 1][j - 1] * x);
        mi[i][j] = min(mi[i][j], mi[i - 1][j - 1] * x);
      }
    }
  }
  cout << mx[n][5] << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int c = 1;
  int t;
  if (!c) {
    t = 1;
  } else {
    cin >> t;
  }
  while (t--) {
    go();
  }
}
