let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    const arr = readLine()
      .split(" ")
      .map((n) => n);
    let output = "";
    let max = -Infinity;
    arr.sort((a, b) => b - a);

    for (let i = 0; i <= 5; i++) {
      let mul = 1n;
      for (let j = 0; j < i; j++) mul *= BigInt(arr[j]);
      for (let k = len - 1; k >= len - 5 + i; k--) mul *= BigInt(arr[k]);

      if (max < mul) max = mul;
    }
    max = max === -0n ? 0n : max;
    output += max;

    console.log(output);
  }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = ''
let currentLine = 0

process.stdin.on('data', inputStdin => {
    inputString += inputStdin
})

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n')

    main()
})

function readLine() {
    return inputString[currentLine++]
}

const s2i = s => parseInt(s, 10)

const readLineOfBigInts = () => {
  const split = readLine().split(' ')
  const result = []
  for (let i = 0, l = split.length; i < l; i++) {
    result.push(BigInt(split[i]));
  }
  return result
}

const cmpi = (a, b) => a - b

function main() {
  let T = s2i(readLine())
  let out = ''

  const multToBigInt = (a1, a2, a3, a4, a5) => BigInt(a1 * a2 * a3) * BigInt(a4 * a5)

  const descComp = (a, b) => b - a
let i = 0
  while (T--) {

    const n = s2i(readLine())
    const a = readLine().split(' ').map(s2i)

    let result = 1n

    if (a.length === 5) {
      out += multToBigInt(...a) + '\n'
      continue
    }

    const neg = []
    const pos = []

    for (let i = 0, l = a.length; i < l; i++) {
      const x = a[i]
      if (x < 0) neg.push(x)
      else pos.push(x)
    }

    pos.sort(descComp)
    neg.sort(cmpi)

    const nl = neg.length
    const pl = pos.length

    if (pl === 0) {
      for (let i = 5; i > 0; i--) {
        result *= BigInt(neg[nl - i])
      }
    } else if (nl === 0) {
      for (let i = 0; i < 5; i++) {
        result *= BigInt(pos[i])
      }
    } else {
      let lastNeg = null
      let lastPos = null
      let ni = 0
      let pi = 0

      for (let i = 0; i < 5; i++) {
        const pn = pos[pi]
        const nn = neg[ni]
        if (pi === pl) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else if (ni === nl) {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        } else if (pn > -nn) {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        } else if (pn < -nn) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else if (result < 0n) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        }
      }

      if (result < 0n) {
        const pn = pos[pi]
        const nn = neg[ni]
        if (pi === pl || lastNeg === null) {
          result /= BigInt(lastPos)
          result *= BigInt(nn)
        } else if (ni === nl || lastPos === null) {
          result /= BigInt(lastNeg)
          result *= BigInt(pn)
        } else if (pn * lastPos > nn * lastNeg) {
          result /= BigInt(lastNeg)
          result *= BigInt(pn)
        } else  {
          result /= BigInt(lastPos)
          result *= BigInt(nn)
        }
      }
    }

    out += result + '\n'
  }

  console.log(out)
}

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, cb) {
  let res;
  if (a < b) {
    for (let i = a; i <= b; i++) {
      if ((res = cb(i)) !== undefined) return res;
    }
  } else {
    for (let i = a; i >= b; i--) {
      if ((res = cb(i)) !== undefined) return res;
    }
  }
}

function Arr(a, b, cb, prev) {
  let p = prev || 0;
  if (a < b) return Array(b - a + 1).fill(0).map((v, i) => cb ? (p = cb(a + i, p)) : a + i);
  return Array(a - b + 1).fill(0).map((v, i) => cb ? (p = cb(a - i, p)) : a - i);
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}

function max(a, b) {
  if (a > b) return a;
  return b;
}
function min(a, b) {
  if (a > b) return b;
  return a;
}

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v); r = 0;
  let t = inp[r++];
  For(1, t, i => {
    let n = inp[r++];
    let a = inp.slice(r, r = r + n);
    // console.log(a);
    a=a.map(v => BigInt(v));
    let min1 = Arr(0, n - 1, (i, p) => min(p, a[i]), 1e100);
    let max1 = Arr(0, n - 1, (i, p) => max(p, a[i]), -1e100);
    let min2 = Arr(0, n - 2, (i, p) => min(p, min(a[i+1] * min1[i], a[i+1] * max1[i])), 1e100);
    let max2 = Arr(0, n - 2, (i, p) => max(p, max(a[i+1] * min1[i], a[i+1] * max1[i])), -1e100);
    let min3 = Arr(0, n - 3, (i, p) => min(p, min(a[i+2] * min2[i], a[i+2] * max2[i])), 1e100);
    let max3 = Arr(0, n - 3, (i, p) => max(p, max(a[i+2] * min2[i], a[i+2] * max2[i])), -1e100);
    let min4 = Arr(0, n - 4, (i, p) => min(p, min(a[i+3] * min3[i], a[i+3] * max3[i])), 1e100);
    let max4 = Arr(0, n - 4, (i, p) => max(p, max(a[i+3] * min3[i], a[i+3] * max3[i])), -1e100);
    let min5 = Arr(0, n - 5, (i, p) => min(p, min(a[i+4] * min4[i], a[i+4] * max4[i])), 1e100);
    let max5 = Arr(0, n - 5, (i, p) => max(p, max(a[i+4] * min4[i], a[i+4] * max4[i])), -1e100);
    console.log(max5[n-5]+'')
  })
})();

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    const arr = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    let max = Number.MIN_SAFE_INTEGER;
    arr.sort((a, b) => b - a);

    for (let i = 0; i <= 5; i++) {
      let mul = 1;
      for (let j = 0; j < i; j++) mul *= arr[j];
      for (let k = len - 1; k >= len - 5 + i; k--) mul *= arr[k];
      max = Math.max(max, mul);
    }
    max = max === -0 ? 0 : max;
    console.log(max);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let [plusArr, minusArr] = [[], []];
    const arr = readLine()
      .split(" ")
      .map((n) => {
        n = parseInt(n);
        if (n >= 0) plusArr.push(n);
        else minusArr.push(n);
        return n;
      });

    plusArr.sort((a, b) => b - a);
    minusArr.sort((a, b) => a - b);

    let max = Number.MIN_SAFE_INTEGER;

    if (plusArr.length >= 3) {
      let [_plusAll, _plusThree] = [1, 1];
      for (let i = 0; i < plusArr.length; i++) {
        _plusAll *= plusArr[i];
        if (i < 3) _plusThree *= plusArr[i];
      }
      max = Math.max(max, _plusAll, _plusThree * minusArr[0] * minusArr[1]);
    }
    if (minusArr.length >= 4) {
      let [_minusAll, _minusThree] = [1, 1];
      for (let i = 0; i < minusArr.length; i++) {
        _minusAll *= minusArr[i];
        if (i < 4) _minusThree *= minusArr[i];
      }
      if (plusArr.length !== 0) {
        max = Math.max(max, _minusAll, _minusThree * plusArr[0]);
      } else {
        max = Math.max(max, _minusAll);
      }
    }
    console.log(max);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    const arr = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    let max = Number.MIN_SAFE_INTEGER;
    arr.sort((a, b) => b - a);

    for (let i = 0; i <= 5; i++) {
      let mul = 1;
      for (let j = 0; j < i; j++) mul *= arr[j];
      for (let k = len - 1; k >= len - 5 + i; k--) mul *= arr[k];
      max = Math.max(max, mul);
    }
    max === -0 ? 0 : max;
    console.log(max);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let [plusArr, minusArr] = [[], []];
    const arr = readLine()
      .split(" ")
      .map((n) => {
        n = parseInt(n);
        if (n >= 0) plusArr.push(n);
        else minusArr.push(n);
        return n;
      });

    plusArr.sort((a, b) => b - a);
    minusArr.sort((a, b) => a - b);

    let max = Number.MIN_SAFE_INTEGER;

    if (arr.length === 5) {
      const mul = arr[0] * arr[1] * arr[2] * arr[3] * arr[4];
      max = Math.max(max, mul);
    }

    if (plusArr.length >= 5) {
      let _plusAll = plusArr[0] * plusArr[1] * plusArr[2] * plusArr[3] * plusArr[4];

      max = Math.max(max, _plusAll);
    }

    if (plusArr.length >= 3 && minusArr.length >= 2) {
      let _plusThree = plusArr[0] * plusArr[1] * plusArr[2];

      max = Math.max(max, _plusThree * minusArr[0] * minusArr[1]);
    }

    if (plusArr.length >= 1 && minusArr.length >= 4) {
      let _plusTwo = plusArr[0];

      max = Math.max(max, _plusTwo * minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3]);
    }

    if (minusArr.length >= 5 && plusArr.length === 0) {
      let _minusAll = minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3] * minusArr[4];

      max = Math.max(max, _minusAll);
    }
    max = max === -0 ? 0 : max;
    console.log(max);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    const arr = readLine()
      .split(" ")
      .map((n) => n);
    let output = "";
    let max = Number.MIN_SAFE_INTEGER;
    arr.sort((a, b) => b - a);

    for (let i = 0; i <= 5; i++) {
      let mul = 1n;
      for (let j = 0; j < i; j++) mul *= BigInt(arr[j]);
      for (let k = len - 1; k >= len - 5 + i; k--) mul *= BigInt(arr[k]);

      if (max < mul) max = mul;
    }
    max = max === -0n ? 0n : max;
    output += max;

    console.log(output);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let [plusArr, minusArr] = [[], []];
    const arr = readLine()
      .split(" ")
      .map((n) => {
        n = parseInt(n);
        if (n >= 0) plusArr.push(n);
        else minusArr.push(n);
        return n;
      });

    plusArr.sort((a, b) => b - a);
    minusArr.sort((a, b) => a - b);

    let max = Number.MIN_SAFE_INTEGER;

    if (plusArr.length >= 5) {
      let _plusAll = 1;
      for (let i = 0; i < plusArr.length; i++) {
        _plusAll *= plusArr[i];

        max = Math.max(max, _plusAll);
      }
    }

    if (plusArr.length >= 3 && minusArr.length >= 2) {
      let _plusThree = 1;
      for (let i = 0; i < plusArr.length; i++) {
        if (i < 3) _plusThree *= plusArr[i];
      }
      max = Math.max(max, _plusThree * minusArr[0] * minusArr[1]);
    }

    if (plusArr.length >= 1 && minusArr.length >= 4) {
      let _plusTwo = plusArr[0];

      max = Math.max(max, _plusTwo * minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3]);
    }

    if (minusArr.length >= 5 && plusArr.length === 0) {
      let _minusAll = minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3] * minusArr[4];

      max = Math.max(max, _minusAll);
    }
    console.log(max);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let [plusArr, minusArr] = [[], []];
    const arr = readLine()
      .split(" ")
      .map((n) => {
        n = parseInt(n);
        if (n >= 0) plusArr.push(n);
        else minusArr.push(n);
        return n;
      });

    plusArr.sort((a, b) => b - a);
    minusArr.sort((a, b) => a - b);

    let max = Number.MIN_SAFE_INTEGER;

    if (plusArr.length >= 5) {
      let _plusAll = plusArr[0] * plusArr[1] * plusArr[2] * plusArr[3] * plusArr[4];

      max = Math.max(max, _plusAll);
    }

    if (plusArr.length >= 3 && minusArr.length >= 2) {
      let _plusThree = plusArr[0] * plusArr[1] * plusArr[2];

      max = Math.max(max, _plusThree * minusArr[0] * minusArr[1]);
    }

    if (plusArr.length >= 1 && minusArr.length >= 4) {
      let _plusTwo = plusArr[0];

      max = Math.max(max, _plusTwo * minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3]);
    }

    if (minusArr.length >= 5 && plusArr.length === 0) {
      let _minusAll = minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3] * minusArr[4];

      max = Math.max(max, _minusAll);
    }
    console.log(max);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    const arr = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    let max = Number.MIN_SAFE_INTEGER;
    arr.sort((a, b) => b - a);

    for (let i = 0; i <= 5; i++) {
      let mul = 1;
      for (let j = 0; j < i; j++) mul *= arr[j];
      for (let k = len - 1; k >= len - 5 + i; k--) mul *= arr[k];
      max = Math.max(max, mul);
    }
    console.log(max);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let [plusArr, minusArr] = [[], []];
    const arr = readLine()
      .split(" ")
      .map((n) => {
        n = parseInt(n);
        if (n >= 0) plusArr.push(n);
        else minusArr.push(n);
        return n;
      });

    plusArr.sort((a, b) => b - a);
    minusArr.sort((a, b) => a - b);

    let max = Number.MIN_SAFE_INTEGER;

    if (arr.length === 5) {
      const mul = arr[0] * arr[1] * arr[2] * arr[3] * arr[4];
      max = Math.max(max, mul);
    }

    if (plusArr.length >= 5) {
      let _plusAll = plusArr[0] * plusArr[1] * plusArr[2] * plusArr[3] * plusArr[4];

      max = Math.max(max, _plusAll);
    }

    if (plusArr.length === 3) {
      max = Math.max(
        max,
        plusArr[0] * plusArr[1] * plusArr[2] * minusArr[0] * minusArr[1],
        plusArr[0] * minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3]
      );
    }

    if (plusArr.length === 1 || plusArr.length === 2) {
      max = Math.max(max, plusArr[0] * minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3]);
    }

    if (minusArr.length >= 5 && plusArr.length === 0) {
      let _minusAll = minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3] * minusArr[4];

      max = Math.max(max, _minusAll);
    }
    max = max === -0 ? 0 : max;
    console.log(max);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    const arr = readLine()
      .split(" ")
      .map((n) => n);
    let output = "";
    let max = Number.MIN_SAFE_INTEGER;
    arr.sort((a, b) => b - a);

    for (let i = 0; i <= 5; i++) {
      let mul = 1n;
      for (let j = 0; j < i; j++) mul *= BigInt(arr[j]);
      for (let k = len - 1; k >= len - 5 + i; k--) mul *= BigInt(arr[k]);
      mul = mul + "";
      max = Math.max(max, mul);
    }
    max = max === -0n ? 0n : max;
    output += max;

    console.log(max);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let [plusArr, minusArr] = [[], []];
    const arr = readLine()
      .split(" ")
      .map((n) => {
        n = parseInt(n);
        if (n >= 0) plusArr.push(n);
        else minusArr.push(n);
        return n;
      });

    plusArr.sort((a, b) => b - a);
    minusArr.sort((a, b) => a - b);

    let max = Number.MIN_SAFE_INTEGER;

    if (arr.length === 5) {
      const mul = arr[0] * arr[1] * arr[2] * arr[3] * arr[4];
      max = Math.max(max, mul);
    }

    if (plusArr.length >= 5) {
      let _plusAll = plusArr[0] * plusArr[1] * plusArr[2] * plusArr[3] * plusArr[4];

      max = Math.max(max, _plusAll);
    }

    if (plusArr.length === 3 || plusArr.length === 4) {
      max = Math.max(max, plusArr[0] * plusArr[1] * plusArr[2] * minusArr[0] * minusArr[1]);

      if (minusArr.length >= 4) {
        max = Math.max(max, plusArr[0] * minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3]);
      }
    }

    if (plusArr.length === 1 || plusArr.length === 2) {
      max = Math.max(max, plusArr[0] * minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3]);
    }

    if (minusArr.length >= 5 && plusArr.length === 0) {
      let _minusAll = minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3] * minusArr[4];

      max = Math.max(max, _minusAll);
    }
    max = max === -0 ? 0 : max;
    console.log(max);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let [plusArr, minusArr] = [[], []];
    const arr = readLine()
      .split(" ")
      .map((n) => {
        n = parseInt(n);
        if (n >= 0) plusArr.push(n);
        else minusArr.push(n);
        return n;
      });

    plusArr.sort((a, b) => b - a);
    minusArr.sort((a, b) => a - b);

    let max = Number.MIN_SAFE_INTEGER;

    if (arr.length === 5) {
      const mul = arr[0] * arr[1] * arr[2] * arr[3] * arr[4];
      max = Math.max(max, mul);
    }

    if (plusArr.length >= 5) {
      let _plusAll = plusArr[0] * plusArr[1] * plusArr[2] * plusArr[3] * plusArr[4];

      max = Math.max(max, _plusAll);
    }

    if (plusArr.length >= 3 && minusArr.length >= 2) {
      let _plusThree = plusArr[0] * plusArr[1] * plusArr[2];

      max = Math.max(max, _plusThree * minusArr[0] * minusArr[1]);
    }

    if (plusArr.length >= 1 && minusArr.length >= 4) {
      let _plusTwo = plusArr[0];

      max = Math.max(max, _plusTwo * minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3]);
    }

    if (minusArr.length >= 5 && plusArr.length === 0) {
      let _minusAll = minusArr[0] * minusArr[1] * minusArr[2] * minusArr[3] * minusArr[4];

      max = Math.max(max, _minusAll);
    }
    console.log(max);
  }
}

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, cb) {
  let res;
  if (a < b) {
    for (let i = a; i <= b; i++) {
      if ((res = cb(i)) !== undefined) return res;
    }
  } else {
    for (let i = a; i >= b; i--) {
      if ((res = cb(i)) !== undefined) return res;
    }
  }
}

function Arr(a, b, cb, prev) {
  let p = prev || 0;
  if (a < b) return Array(b - a + 1).fill(0).map((v, i) => cb ? (p = cb(a + i, p)) : a + i);
  return Array(a - b + 1).fill(0).map((v, i) => cb ? (p = cb(a - i, p)) : a - i);
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}

function max(a, b) {
  if (a > b) return a;
  return b;
}
function min(a, b) {
  if (a > b) return b;
  return a;
}
var min = Math.min;
var max = Math.max;

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v); r = 0;
  let t = inp[r++];
  For(1, t, i => {
    let n = inp[r++];
    let a = inp.slice(r, r = r + n);
    let amin = [], amax = [];
    let min1 = Arr(0, n - 1, (i, p) => min(p, a[i]), 1e100);
    let max1 = Arr(0, n - 1, (i, p) => max(p, a[i]), -1e100);
    let min2 = Arr(0, n - 2, (i, p) => min(p, a[i + 1] * min1[i], a[i + 1] * max1[i]), 1e100);
    let max2 = Arr(0, n - 2, (i, p) => max(p, a[i + 1] * min1[i], a[i + 1] * max1[i]), -1e100);
    let min3 = Arr(0, n - 3, (i, p) => min(p, a[i + 2] * min2[i], a[i + 2] * max2[i]), 1e100);
    let max3 = Arr(0, n - 3, (i, p) => max(p, a[i + 2] * min2[i], a[i + 2] * max2[i]), -1e100);
    let min4 = Arr(0, n - 4, (i, p) => min(p, a[i + 3] * min3[i], a[i + 3] * max3[i]), 1e100);
    let max4 = Arr(0, n - 4, (i, p) => max(p, a[i + 3] * min3[i], a[i + 3] * max3[i]), -1e100);
    let min5 = Arr(0, n - 5, (i, p) => min(p, a[i + 4] * min4[i], a[i + 4] * max4[i]), 1e100);
    let max5 = Arr(0, n - 5, (i, p) => max(p, a[i + 4] * min4[i], a[i + 4] * max4[i]), -1e100);
    console.log(max5[n - 5]+'')
  })
})();

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, cb) {
  let res;
  if (a < b) {
    for (let i = a; i <= b; i++) {
      if ((res = cb(i)) !== undefined) return res;
    }
  } else {
    for (let i = a; i >= b; i--) {
      if ((res = cb(i)) !== undefined) return res;
    }
  }
}

function Arr(a, b, cb, prev) {
  let p = prev || 0;
  if (a < b) return Array(b - a + 1).fill(0).map((v, i) => cb ? (p = cb(a + i, p)) : a + i);
  return Array(a - b + 1).fill(0).map((v, i) => cb ? (p = cb(a - i, p)) : a - i);
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}

function max(a, b) {
  if (a > b) return a;
  return b;
}
function min(a, b) {
  if (a > b) return b;
  return a;
}
var min = Math.min;
var max = Math.max;

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v); r = 0;
  let t = inp[r++];
  For(1, t, i => {
    let n = inp[r++];
    let a = inp.slice(r, r = r + n);
    let amin = [], amax = [];
    let min1 = Arr(0, n - 1, (i, p) => min(p, a[i]), 1e100);
    let max1 = Arr(0, n - 1, (i, p) => max(p, a[i]), -1e100);
    let min2 = Arr(0, n - 2, (i, p) => min(p, a[i + 1] * min1[i], a[i + 1] * max1[i]), 1e100);
    let max2 = Arr(0, n - 2, (i, p) => max(p, a[i + 1] * min1[i], a[i + 1] * max1[i]), -1e100);
    let min3 = Arr(0, n - 3, (i, p) => min(p, a[i + 2] * min2[i], a[i + 2] * max2[i]), 1e100);
    let max3 = Arr(0, n - 3, (i, p) => max(p, a[i + 2] * min2[i], a[i + 2] * max2[i]), -1e100);
    let min4 = Arr(0, n - 4, (i, p) => min(p, a[i + 3] * min3[i], a[i + 3] * max3[i]), 1e100);
    let max4 = Arr(0, n - 4, (i, p) => max(p, a[i + 3] * min3[i], a[i + 3] * max3[i]), -1e100);
    let min5 = Arr(0, n - 5, (i, p) => min(p, a[i + 4] * min4[i], a[i + 4] * max4[i]), 1e100);
    let max5 = Arr(0, n - 5, (i, p) => max(p, a[i + 4] * min4[i], a[i + 4] * max4[i]), -1e100);
    console.log(max5[n - 5])
  })
})();

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = ''
let currentLine = 0

process.stdin.on('data', inputStdin => {
    inputString += inputStdin
})

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n')

    main()
})

function readLine() {
    return inputString[currentLine++]
}

const s2i = s => parseInt(s, 10)

const readLineOfBigInts = () => {
  const split = readLine().split(' ')
  const result = []
  for (let i = 0, l = split.length; i < l; i++) {
    result.push(BigInt(split[i]));
  }
  return result
}

const cmpi = (a, b) => a - b

function main() {
  let T = s2i(readLine())
  let out = ''

  const multToBigInt = (a1, a2, a3, a4, a5) => BigInt(a1 * a2 * a3) * BigInt(a4 * a5)

  const descComp = (a, b) => b - a

  while (T--) {
    const n = s2i(readLine())
    const a = readLine().split(' ').map(s2i)

    let result = 1n

    if (a.length === 5) {
      out += multToBigInt(...a) + '\n'
      continue
    }

    const neg = []
    const pos = []

    for (let i = 0, l = a.length; i < l; i++) {
      const x = a[i]
      if (x < 0) neg.push(x)
      else pos.push(x)
    }

    pos.sort(descComp)
    neg.sort(cmpi)

    const nl = neg.length
    const pl = pos.length

    if (pl === 0) {
      for (let i = 5; i > 0; i--) {
        result *= BigInt(neg[nl - i])
      }
    } else if (nl === 0) {
      for (let i = 0; i < 5; i++) {
        result *= BigInt(pos[i])
      }
    } else {
      let lastNeg = null
      let lastPos = null
      let ni = 0
      let pi = 0

      for (let i = 0; i < 5; i++) {
        const pn = pos[pi]
        const nn = neg[ni]
        if (pi === pl) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else if (ni === nl) {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        } else if (pn > nn) {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        } else if (pn < nn) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else if (result < 0n) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        }
      }

      if (result < 0n) {
        const pn = pos[pi]
        const nn = neg[ni]
        if (pi === pl) {
          result /= BigInt(lastPos)
          result *= BigInt(nn)
        } else if (ni === nl) {
          result /= BigInt(lastNeg)
          result *= BigInt(pn)
        } else if (pn > -nn) {
          result /= BigInt(lastNeg)
          result *= BigInt(pn)
        } else  {
          result /= BigInt(lastPos)
          result *= BigInt(nn)
        }
      }
    }

    out += result + '\n'
  }

  console.log(out)
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = ''
let currentLine = 0

process.stdin.on('data', inputStdin => {
    inputString += inputStdin
})

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n')

    main()
})

function readLine() {
    return inputString[currentLine++]
}

const s2i = s => parseInt(s, 10)

const readLineOfBigInts = () => {
  const split = readLine().split(' ')
  const result = []
  for (let i = 0, l = split.length; i < l; i++) {
    result.push(BigInt(split[i]));
  }
  return result
}

const cmpi = (a, b) => a - b

function main() {
  let T = s2i(readLine())
  let out = ''

  const multToBigInt = (a1, a2, a3, a4, a5) => BigInt(a1 * a2 * a3) * BigInt(a4 * a5)

  const descComp = (a, b) => b - a

  while (T--) {

    const n = s2i(readLine())
    const a = readLine().split(' ').map(s2i)

    let result = 1n
try {
    if (a.length === 5) {
      out += multToBigInt(...a) + '\n'
      continue
    }

    const neg = []
    const pos = []

    for (let i = 0, l = a.length; i < l; i++) {
      const x = a[i]
      if (x < 0) neg.push(x)
      else pos.push(x)
    }

    pos.sort(descComp)
    neg.sort(cmpi)

    const nl = neg.length
    const pl = pos.length

    if (pl === 0) {
      for (let i = 5; i > 0; i--) {
        result *= BigInt(neg[nl - i])
      }
    } else if (nl === 0) {
      for (let i = 0; i < 5; i++) {
        result *= BigInt(pos[i])
      }
    } else {
      let lastNeg = null
      let lastPos = null
      let ni = 0
      let pi = 0

      for (let i = 0; i < 5; i++) {
        const pn = pos[pi]
        const nn = neg[ni]
        if (pi === pl) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else if (ni === nl) {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        } else if (pn > -nn) {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        } else if (pn < -nn) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else if (result < 0n) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        }
      }

      if (result < 0n) {
        const pn = pos[pi]
        const nn = neg[ni]
        if (pi === pl || lastNeg === null) {
          result /= BigInt(lastPos)
          result *= BigInt(nn)
        } else if (ni === nl || lastPos === null) {
          result /= BigInt(lastNeg)
          result *= BigInt(pn)
        } else if (pn > -nn) {
          result /= BigInt(lastNeg)
          result *= BigInt(pn)
        } else  {
          result /= BigInt(lastPos)
          result *= BigInt(nn)
        }
      }
    }

    out += result + '\n'
  } catch (e) {
    console.log(e)
    console.log('n = ', n, 'a = ', a)
  }
  }

  console.log(out)
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = ''
let currentLine = 0

process.stdin.on('data', inputStdin => {
    inputString += inputStdin
})

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n')

    main()
})

function readLine() {
    return inputString[currentLine++]
}

const s2i = s => parseInt(s, 10)

const readLineOfBigInts = () => {
  const split = readLine().split(' ')
  const result = []
  for (let i = 0, l = split.length; i < l; i++) {
    result.push(BigInt(split[i]));
  }
  return result
}

const cmpi = (a, b) => a - b

function main() {
  let T = s2i(readLine())
  let out = ''

  const multToBigInt = (a1, a2, a3, a4, a5) => BigInt(a1 * a2 * a3) * BigInt(a4 * a5)

  const descComp = (a, b) => b - a

  while (T--) {

    const n = s2i(readLine())
    const a = readLine().split(' ').map(s2i)

    let result = 1n
try {
    if (a.length === 5) {
      out += multToBigInt(...a) + '\n'
      continue
    }

    const neg = []
    const pos = []

    for (let i = 0, l = a.length; i < l; i++) {
      const x = a[i]
      if (x < 0) neg.push(x)
      else pos.push(x)
    }

    pos.sort(descComp)
    neg.sort(cmpi)

    const nl = neg.length
    const pl = pos.length

    if (pl === 0) {
      for (let i = 5; i > 0; i--) {
        result *= BigInt(neg[nl - i])
      }
    } else if (nl === 0) {
      for (let i = 0; i < 5; i++) {
        result *= BigInt(pos[i])
      }
    } else {
      let lastNeg = null
      let lastPos = null
      let ni = 0
      let pi = 0

      for (let i = 0; i < 5; i++) {
        const pn = pos[pi]
        const nn = neg[ni]
        if (pi === pl) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else if (ni === nl) {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        } else if (pn > -nn) {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        } else if (pn < -nn) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else if (result < 0n) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        }
      }

      if (result < 0n) {
        const pn = pos[pi]
        const nn = neg[ni]
        if (pi === pl) {
          result /= BigInt(lastPos)
          result *= BigInt(nn)
        } else if (ni === nl) {
          result /= BigInt(lastNeg)
          result *= BigInt(pn)
        } else if (pn > -nn) {
          result /= BigInt(lastNeg)
          result *= BigInt(pn)
        } else  {
          result /= BigInt(lastPos)
          result *= BigInt(nn)
        }
      }
    }

    out += result + '\n'
  } catch (e) {
    console.log(e)
    console.log('n = ', n, 'a = ', a)
  }
  }

  console.log(out)
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = ''
let currentLine = 0

process.stdin.on('data', inputStdin => {
    inputString += inputStdin
})

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n')

    main()
})

function readLine() {
    return inputString[currentLine++]
}

const s2i = s => parseInt(s, 10)

const readLineOfBigInts = () => {
  const split = readLine().split(' ')
  const result = []
  for (let i = 0, l = split.length; i < l; i++) {
    result.push(BigInt(split[i]));
  }
  return result
}

const cmpi = (a, b) => a - b

function main() {
  let T = s2i(readLine())
  let out = ''

  const multToBigInt = (a1, a2, a3, a4, a5) => BigInt(a1 * a2 * a3) * BigInt(a4 * a5)

  const descComp = (a, b) => b - a
let i = 0
  while (T--) {
i++
    const n = s2i(readLine())
    const a = readLine().split(' ').map(s2i)

    let result = 1n
try {
    if (a.length === 5) {
      out += multToBigInt(...a) + '\n'
      continue
    }

    const neg = []
    const pos = []

    for (let i = 0, l = a.length; i < l; i++) {
      const x = a[i]
      if (x < 0) neg.push(x)
      else pos.push(x)
    }

    pos.sort(descComp)
    neg.sort(cmpi)

    const nl = neg.length
    const pl = pos.length

    if (pl === 0) {
      for (let i = 5; i > 0; i--) {
        result *= BigInt(neg[nl - i])
      }
    } else if (nl === 0) {
      for (let i = 0; i < 5; i++) {
        result *= BigInt(pos[i])
      }
    } else {
      let lastNeg = null
      let lastPos = null
      let ni = 0
      let pi = 0

      for (let i = 0; i < 5; i++) {
        const pn = pos[pi]
        const nn = neg[ni]
        if (pi === pl) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else if (ni === nl) {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        } else if (pn > -nn) {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        } else if (pn < -nn) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else if (result < 0n) {
          lastNeg = nn
          result *= BigInt(lastNeg)
          ni++
        } else {
          lastPos = pn
          result *= BigInt(lastPos)
          pi++
        }
      }

      if (result < 0n) {
        const pn = pos[pi]
        const nn = neg[ni]
        if (pi === pl || lastNeg === null) {
          result /= BigInt(lastPos)
          result *= BigInt(nn)
        } else if (ni === nl || lastPos === null) {
          result /= BigInt(lastNeg)
          result *= BigInt(pn)
        } else if (pn > -nn) {
          result /= BigInt(lastNeg)
          result *= BigInt(pn)
        } else  {
          result /= BigInt(lastPos)
          result *= BigInt(nn)
        }
      }
    }

    out += result + '\n'
    if (i === 39) {
      console.log('n=', n, 'a=', a)
    }
  } catch (e) {
    console.log(e)
    console.log('n = ', n, 'a = ', a)
  }
  }

  console.log(out)
}


function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i - a] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  a = a || 0;
  b = b || (this.length - 1);
  let prev = a;
  for (let i = a; i <= b; i++) {
    if (i == b || fn(this[i], this[i + 1], i, this)) {
      arr.push(this.slice(prev, i + 1));
      prev = i + 1;
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
function inv(b, m) {
  for (var a = m, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + m) % m;
}

// let MOD = 1e9 + 7
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[MOD % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }
// alpha = "abcdefghijklmnopqrstuvwxyz"

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
async function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, { min, max, ceil, floor, sqrt, abs, log2 } = Math,
    bi = BigInt, rand = n => Math.random() * n | 0;

  let n = $(), a = $(n)
  let r = n;
  let rc = Arr(n, i => 0)
  let fr = n - 1;
  ForR(n, i => {
    if (a[i] == 0) return;
    if (a[i] == 1) {
      r--;
      rc[r] = 1;
      out.push([r + 1, i + 1])
    } else if (a[i] == 2) {
      while (fr >= 0 && rc[fr] != 1) fr--;
      if (fr < 0) {
        log(-1);
        process.exit()
      }
      rc[fr] = 2;
      out.push([fr + 1, i + 1])
    } else {
      if (!out.length) {
        log(-1);
        process.exit();
      }
      r--;
      rc[r] = 2;
      let x = out[out.length - 1];
      rc[x[0] - 1] = 2;
      out.push([r + 1, x[1]])
      out.push([r + 1, i + 1])
    }
  })
  log(out.length);
  log(out.map(v => v.join(' ')).join('\n'));
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => string.trim());

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
    const n = Number.parseInt(readLine());
    const expectedColHits = readLine().split(' ').map(h => Number.parseInt(h));
    let targets = 0;
    let nextRow = 0;
    let answer = '';
    try {
        for (let i = 0; i < expectedColHits.length; i++) {
            if (expectedColHits[i] === 1) {
                targets++;
                answer += (nextRow++ + 1) + ' ' + (i + 1) + '\n';
            } else if (expectedColHits[i] === 2) {
                targets += 2;
                answer += (nextRow + 1) + ' ' + (i + 1) + '\n';
                answer += (nextRow++ + 1) + ' ' + (1 + nextCol1(expectedColHits, i)) + '\n';
            } else if (expectedColHits[i] === 3) {
                targets += 2;
                answer += (nextRow + 1) + ' ' + (i + 1) + '\n';
                answer += (nextRow++ + 1) + ' ' + (1 + nextColGreater0(expectedColHits, i)) + '\n';
            }
        }
    } catch (e) {
        console.log(-1);
        return;
    }
    if (nextRow > n) {
        console.log(-1);
        return;
    }
    console.log(targets);
    console.log(answer);
}

function nextCol1(expectedColHits, i) {
    for (let k = i+1; k < expectedColHits.length; k++) {
        if (expectedColHits[k] === 1) {
            expectedColHits[k] = 0;
            return k;
        }
    }
    throw new Error();
}
function nextColGreater0(expectedColHits, i) {
    for (let k = i+1; k < expectedColHits.length; k++) {
        if (expectedColHits[k] > 0) {
            return k;
        }
    }
    throw new Error();
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i - a] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  a = a || 0;
  b = b || (this.length - 1);
  let prev = a;
  for (let i = a; i <= b; i++) {
    if (i == b || fn(this[i], this[i + 1], i, this)) {
      arr.push(this.slice(prev, i + 1));
      prev = i + 1;
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
function inv(b, m) {
  for (var a = m, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + m) % m;
}

// let MOD = 1e9 + 7
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[MOD % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }
// alpha = "abcdefghijklmnopqrstuvwxyz"

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
async function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, { min, max, ceil, floor, sqrt, abs, log2 } = Math,
    bi = BigInt, rand = n => Math.random() * n | 0;

  let n = $(), a = $(n)
  let r = n;
  let rc = Arr(n, i => 0)
  let fr = n - 1;
  ForR(n, i => {
    if (a[i] == 0) return;
    if (a[i] == 1) {
      r--;
      rc[r] = 1;
      out.push([r + 1, i + 1])
    } else if (a[i] == 2) {
      while (fr >= 0 && rc[fr] != 1) fr--;
      if (fr < 0) {
        log(-1);
        process.exit()
      }
      rc[fr] = 2;
      out.push([fr + 1, i + 1])
    } else {
      if (!out.length) {
        log(-1);
        process.exit();
      }
      r--;
      rc[r] = 2;
      out.push([r + 1, out[out.length - 1][1]])
      out.push([r + 1, i + 1])
    }
  })
  log(out.length);
  log(out.map(v => v.join(' ')).join('\n'));
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => string.trim());

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
    const n = Number.parseInt(readLine());
    const expectedColHits = readLine().split(' ').map(h => Number.parseInt(h));
    let targets = [];
    let nextRow = 0;
    try {
        for (let i = 0; i < expectedColHits.length; i++) {
            if (expectedColHits[i] === 1) {
                targets.push([nextRow++, i]);
            } else if (expectedColHits[i] === 2) {
                targets.push([nextRow, i]);
                targets.push([nextRow++, nextCol(expectedColHits, i)])
            } else if (expectedColHits[i] === 3) {
                const col = nextCol(expectedColHits, i);
                targets.push([nextRow, i]);
                targets.push([nextRow++, col])
                targets.push([nextRow++, col])
            }
        }
    } catch (e) {
        console.log(-1);
        return;
    }
    if (nextRow > n) {
        console.log(-1);
        return;
    }
    console.log(targets.length);
    for (let i = 0; i < targets.length; i++) {
        console.log(targets[i][0] + 1, targets[i][1] + 1);
    }
}

function nextCol(expectedColHits, i) {
    for (let k = i; k < expectedColHits.length; k++) {
        if (expectedColHits[k] === 1) {
            expectedColHits[k] = 0;
            return k;
        }
    }
    throw new Error();
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => string.trim());

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
    const n = Number.parseInt(readLine());
    const expectedColHits = readLine().split(' ').map(h => Number.parseInt(h));
    let targets = 0;
    let nextRow = 0;
    let answer = '';
    try {
        for (let i = 0; i < expectedColHits.length; i++) {
            if (expectedColHits[i] === 1) {
                targets++;
                answer += nextRow++ + ' ' + i + '\n';
            } else if (expectedColHits[i] === 2) {
                targets += 2;
                answer += nextRow++ + ' ' + i + '\n';
                answer += nextRow++ + ' ' + nextCol1(expectedColHits, i) + '\n';
            } else if (expectedColHits[i] === 3) {
                targets += 2;
                answer += nextRow++ + ' ' + i + '\n';
                answer += nextRow++ + ' ' + nextColGreater0(expectedColHits, i) + '\n';
            }
        }
    } catch (e) {
        console.log(-1);
        return;
    }
    if (nextRow > n) {
        console.log(-1);
        return;
    }
    console.log(targets);
    console.log(answer);
}

function nextCol1(expectedColHits, i) {
    for (let k = i+1; k < expectedColHits.length; k++) {
        if (expectedColHits[k] === 1) {
            expectedColHits[k] = 0;
            return k;
        }
    }
    throw new Error();
}
function nextColGreater0(expectedColHits, i) {
    for (let k = i+1; k < expectedColHits.length; k++) {
        if (expectedColHits[k] > 0) {
            return k;
        }
    }
    throw new Error();
}


let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var a = lines[i].split(' ').map(Number);
            var ans = 0;
            for(j = 0; j < n; j++){
                ans += a[j];
            }
            console.log(Math.abs(ans));
        }
    }
});

/*
* auther yeling
*
*
*/
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
function print(str) {
    console.log(str);
}

// const { readline, print, testOutput } = require('@ip-algorithmics/codeforces-io');
// main();
// testOutput();

function begin(n, nums) {
    // print(n, nums);
    let s1 = 0, s2 = 0;
    for(let i = 0; i < n; i++) {
        if(nums[i] >= 0) {
            s1 += nums[i];
        } else {
            s2 += nums[i];
        }
    }
    let res = Math.abs(Math.abs(s1) -Math.abs(s2));
    print(res);

}

function main() {
    var caseNum = parseInt(readline(), 10);
    for (var i = 0; i < caseNum; i++) {
        var n = parseInt(readline(), 10);
        var x = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
        begin(n, x);
    }
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    return Math.abs(arr.reduce((s, x) => s + x, 0))
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main() {
    const testCases = Number(readline());
    for (let i = 0; i < testCases; i++) {
        const n = Number(readline());
        let arr = readline().split(" ").map(x => Number(x))
        console.log(findMaximumSum(arr))
    }
}

function findMaximumSum(arr) {
    arr.sort((a, b) => a - b)
    let sum1 = 0, sum2 = 0, i = 0;
    while (i < arr.length) {
        if (arr[i] < 0) sum1 += arr[i]
        else sum2 += arr[i]
        i++
    }

    return Math.abs(Math.abs(sum2) - Math.abs(sum1))
}

const fs = require("fs");
const input = fs.readFileSync(0, 'utf8').trim().split('\r\n');
let currentline = 0;
function readline(){
      return input[currentline++];
}

function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
function abs(x) {
  return x < 0 ? x*(-1) : x;
}

var T = readline();
var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
	var n = readline();
	var a = readline().split(" ").map(w => parseInt(w));
	a.sort((x, y) => x-y);
	var cur = 0, sum = 0;
	for(var i=0;i<n;i++) sum += a[i];
	var ans = sum;
	for(var i=0;i<n;i++) {
		cur += a[i];
		ans = max(ans, abs(sum - cur) - abs(cur));
		ans = max(ans, abs(cur) - abs(sum-cur));
	}
	console.log(ans)
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

// your code goes here

// declare global variables
var input_stdin = "";
var lines = "";
var input_currentline = 0;

// standard input is stored into input_stdin
process.stdin.on('data', function (data) {
    input_stdin += data;
});

// standard input is done and stored into an array
process.stdin.on('end', function () {
    lines = input_stdin.split("\n");
    start();
});

function start() {
    const T = parseInt(lines[0])
    let line = 1
    for (let t = 1; t <= T; t++) {
        const n = parseInt(lines[line++].split(' ')[0], 10)
        let s1 = 0, s2 = 0
        lines[line++].split(' ').map(x => {
            const a = parseInt(x, 10)
            if (a > 0) s1 += a;
            else s2 += a
        })
        console.log(Math.abs(s1+s2))
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});

process.stdin.on('end', function() {
    inputString = inputString.split('\n');

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function powerOfTwo(x) {
    return Math.log2(x) % 1 === 0;
}

function mode(arr){
    return arr.sort((a,b) =>
          arr.filter(v => v===a).length
        - arr.filter(v => v===b).length
    ).pop();
}

function main() {

    let t = parseInt(readLine());

    loopwhile:
    while(t--)
    {
        let n = parseInt(readLine())

        let arr = readLine().split(" ").map(x=>parseInt(x))

        let sumpos=0
        let sumneg=0
        //console.log("arr" + arr)
        for(let i=0;i<n;i++)
        {
            if(arr[i]>0)
                sumpos+=arr[i]
            else
                sumneg+=-arr[i]
        }
        //console.log("sumpos" + sumpos)
        //console.log("sumneg" + sumneg)
        if(sumpos>sumneg)
            console.log(sumpos - sumneg)
        else
            console.log(sumneg - sumpos)

   }
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  rn();
        const a = rns();
  let x = 0,
      y = 0;
  for (let num of a) {
    if (num > 0) {
      x += num;
    } else if (num < 0) {
      y -= num;
    }
  }
  return Math.abs(x - y);
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      let s = solve(r);
      if (s === undefined) s = '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\r?\n/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

const x = readline(); // first line

for(var i = 0 ; i < x ; i++) {
  readline(); // skip line
  var inp = readline().split(' ').map(x => parseInt(x));
  var func = arr => Math.abs(arr.reduce((prev, curr) => prev + curr, 0));
  print(func(inp));
}

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    var caseLength = parseInt(readline());
    var caseArray = readline().split(" ");
    var total = 0;
    for (var j = 0; j < caseLength; j++)
    {
        total += parseInt(caseArray[j]);
    }
    if (total < 0) total *= -1;
    print(total);
}

t=readline()
while(t--){
  readline()
  r=0
  a=readline().split(" ").map(Number)
  for(i=0;i<a.length;i++)r+=a[i]
  print(Math.abs(r))
}

const cntInput = readline();
for (var i=0; i<cntInput; i++) {
    var arrLen = readline();
    var arrStr = readline();

    var s1 = 0;
    var s2 = 0;

    var inputArr = arrStr.split(' ');

    for (var k=0; k<arrLen; k++) {
        if (inputArr[k] < 0) {
            s1 = s1 + parseInt(inputArr[k]);
        }
        else {
            s2 = s2 + parseInt(inputArr[k]);
        }
    }

    var absS1 = Math.abs(s1);
    var absS2 = Math.abs(s2);

    var ret = (absS1 > absS2) ? (absS1 - absS2) : (absS2 - absS1);

    print(ret);
}

"use strict";

const rl = require('readline').createInterface(process.stdin, process.stdout);
let all_input = [];

rl.on('line', function(input){
  all_input.push(input);
});

rl.on('close', function(line){
  let index = 0;
  let t = parseInt(all_input[index]);
  index++;

  //for(int i = 0; i < t; i++)
  while(t--)
  {
    let n = parseInt(all_input[index]);
    index++;

    let arr = all_input[index].trim().split(' ').map(Number);
    index++;
    solve(arr, n);
  }
});

function solve(arr, n)
{
  let negative_sum = 0, positive_sum = 0;

  for(let i = 0; i < n; i++)
  {
    if(arr[i] <= 0)
      negative_sum += Math.abs(arr[i]);
    else
      positive_sum += arr[i];
  }

  console.log(Math.abs(negative_sum - positive_sum));
}

/*
* auther yeling
*
*
*/
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
function print(str) {
    console.log(str);
}

// const { readline, print, testOutput } = require('@ip-algorithmics/codeforces-io');
// main();
// testOutput();

function begin2(n, nums) {
    // print(n, nums);
    let s1 = 0, s2 = 0;
    for(let i = 0; i < n; i++) {
        if(nums[i] >= 0) {
            s1 += nums[i];
        } else {
            s2 += nums[i];
        }
    }
    let res = Math.abs(Math.abs(s1) -Math.abs(s2));
    print(res);
}

function begin(n, nums) {
    // print(n, nums);
    let sum = 0;
    for(let i = 0; i < n; i++) {
        sum += nums[i]
    }
    let res = Math.abs(sum);
    print(res);
}

function main() {
    var caseNum = parseInt(readline(), 10);
    for (var i = 0; i < caseNum; i++) {
        var n = parseInt(readline(), 10);
        var x = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
        begin(n, x);
    }
}

"use strict";

function solve(array)
{
  let len = array.length;
  let negative_sum, positive_sum;

  negative_sum = positive_sum = 0;

  for(let i = 0; i < len; i++)
  {
    if(parseInt(array[i]) <= 0)
      negative_sum += Math.abs(parseInt(array[i]));
    else
      positive_sum += parseInt(array[i]);
  }

  console.log(Math.abs(negative_sum - positive_sum));
}

let test_count = 0, n = 0;

const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

readline.on('line', function(line){
  let arr = line.split(' ');

  if(test_count === 0)
    n = arr[0];
  else if( (test_count != 0) && (test_count % 2 === 0) )
  {
    solve(arr);
  }

  if(test_count == (2 * n) )
    readline.close();

  test_count++;
});


function main(a,b,k,m,ar,br){

  var ans = 0;
  for(var i = b ; i > b-m-1 ; i--){

  if(ar[k-1] < br[i])ans++;
  }
  if(ans == m){
    print("YES");
    return;
  }
    print("NO");
}

var ab = readline().split(" ");
for(var i = 0 ; i < ab.length ; i++)ab[i] = parseInt(ab[i]);

var km = readline().split(" ");
for(var i = 0 ; i < km.length ; i++)km[i] = parseInt(km[i]);

var ar = readline().split(" ");
for(var i = 0 ; i < ar.length ; i++)ar[i] = parseInt(ar[i]);

var br = readline().split(" ");
for(var i = 0 ; i < br.length ; i++)br[i] = parseInt(br[i]);

main(ab[0],ab[1],km[0],km[1],ar,br);

var input = readline().split(" "), na = +input[0], nb = +input[1],
	input = readline().split(" "), k = +input[0], m = +input[1],
	a = readline().split(" ").map(Number), b = readline().split(" ").map(Number),
	arrA = [], arrB = [], maxA, minB;

if(a[na-1] < a[nb-1]){
	write("YES");
}
else{
	arrA = a.slice(0,k);
	arrB = b.reverse().slice(0,m).reverse();

	maxA = Math.max.apply(null,arrA);
	minB = Math.min.apply(null,arrB);

	if(maxA < minB){
		write("YES");
	}
	else{
		write("NO");
	}
}

var data = readline().split(' ');
var Na = parseInt(data[0]);
var MasA=[];
var MasB=[];
var Nb = parseInt(data[1]);
var data = readline().split(' ');
var k = parseInt(data[0]);
var m = parseInt(data[1]);
var data = readline().split(' ');
for (i=0;i<Na;i++){
	MasA[i]=parseInt(data[i]);
}
var data = readline().split(' ');
for (i=0;i<Nb;i++){
	MasB[i]=parseInt(data[i]);
}
var result = "YES"
if (MasA[k-1]>=MasB[MasB.length-m]){
	result = "NO";
}
//write(MasA[k-1]+" ");
//write(MasB[MasB.length-m]+ " ");
write(result);

var n1n2 = readline().split(' ');

var n1 = Number(n1n2[0]),
	n2 = Number(n1n2[1]);

var km = readline().split(' ');

var k = Number(km[0]);
var m = Number(km[1]);

var a = readline().split(' ').map(Number);
var b = readline().split(' ').map(Number);

var maxOfArr1 = a.slice(0, k)[k - 1];
var largerNumsInB = 0;

for (var i = b.length - 1; i >= 0; i--) {
	if (b[i] > maxOfArr1) {
		largerNumsInB++;
	}
}

if (largerNumsInB >= m) {
	print('YES');
} else {
	print('NO');
}

function getInputs() {
    return readline().split(' ').map(function(x) { return parseInt(x) });
}

var inputs = getInputs();

var sizeA = inputs[0];
var sizeB = inputs[1];

var limits = getInputs();

var k = limits[0];
var m = limits[1];

var A = getInputs();
var B = getInputs();

var first = A.slice(0, k);
var second = B.slice(-m);

var answer = 'YES';

for (var i = 0; i < k; i++) {
    var item = first[i];

    var isLess = false;

    for (var j = 0; j < m; j++) {

        if (item < second[j]) {
            isLess = true;
            break;
        } else {
            isLess = false;
            break;
        }
    }

    if (!isLess) {
        answer = 'NO';
        break;
    }
}

print(answer);

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const lengths = readline().split(' ');
  const choosenNumbers = readline().split(' ');
  const arrayA = readline().split(' ');
  const arrayB = readline().split(' ');
  const choosenNumbersFromA = parseInt(choosenNumbers[0])
  const choosenNumbersFromB = parseInt(choosenNumbers[1])

  console.log(helper(choosenNumbersFromA, choosenNumbersFromB, arrayA, arrayB) ? 'YES' : 'NO')
}

function helper(choosenNumbersFromA, choosenNumbersFromB, arrayA, arrayB) {
  return parseInt(arrayA[choosenNumbersFromA - 1]) < parseInt(arrayB[arrayB.length - choosenNumbersFromB])
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let k, m;
let arr1, arr2;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  if (c === 1) {
    [k, m] = d.split(' ').map(Number);
    c++;
    return;
  }

  if (c === 2) {
    arr1 = d.split(' ').map(Number);
    c++;
    return;
  }

  arr2 = d.split(' ').map(Number).reverse();

  if (arr1[k - 1] < arr2[m - 1]) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  c++;
});

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const lengths = readline().split(' ');
  const choosenNumbers = readline().split(' ');
  const arrayA = readline().split(' ');
  const arrayB = readline().split(' ');
  const choosenNumbersFromA = parseInt(choosenNumbers[0])
  const choosenNumbersFromB = parseInt(choosenNumbers[1])

  console.log(helper(choosenNumbersFromA, choosenNumbersFromB, arrayA, arrayB) ? 'YES' : 'NO')
}

function helper(choosenNumbersFromA, choosenNumbersFromB, arrayA, arrayB) {
  return arrayA[choosenNumbersFromA - 1] < arrayB[arrayB.length - choosenNumbersFromB]
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const lengths = readline();
  const choosenNumbers = readline();
  const arrayA = readline();
  const arrayB = readline();

  console.log(helper(parseInt(choosenNumbers.split(' ')[0]), arrayA.split(' '), arrayB.split(' ')) ? 'YES' : 'NO')
}

function helper(choosenNumbersFromA, arrayA, arrayB) {
  return arrayA[choosenNumbersFromA - 1] < arrayB[0]
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const lengths = readline();
  const choosenNumbers = readline();
  const arrayA = readline();
  const arrayB = readline();

  console.log(helper(choosenNumbers[0], arrayA, arrayB) ? 'YES' : 'NO')
}

function helper(choosenNumbersFromA, arrayA, arrayB) {
  return arrayA[choosenNumbersFromA - 1] < arrayB[0]
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const lengths = readline();
  const choosenNumbers = readline();
  const arrayA = readline();
  const arrayB = readline();

  console.log(helper(parseInt(choosenNumbers.split(' ')[0]), parseInt(choosenNumbers.split(' ')[1]), arrayA.split(' '), arrayB.split(' ')) ? 'YES' : 'NO')
}

function helper(choosenNumbersFromA, choosenNumbersFromB, arrayA, arrayB) {
  return arrayA[choosenNumbersFromA - 1] < arrayB[arrayB.length - choosenNumbersFromB - 1]
}

var data = readline().split(' ');
var Na = data[0];
var MasA=[];
var MasB=[];
var Nb = data[1];
var data = readline().split(' ');
var k = data[0]-1;
var m = data[1]-1;
var data = readline().split(' ');
for (i=0;i<Na;i++){
	MasA[i]=data[i];
}
var data = readline().split(' ');
for (i=0;i<Nb;i++){
	MasB[i]=data[i];
}
var result = "YES"
if (MasA[k]>=MasB[MasB.length-Nb]){
	result = "NO";
}
write(result);

var data = readline().split(' ');
var Na = data[0];
var MasA=[];
var MasB=[];
var Nb = data[1];
var data = readline().split(' ');
var k = data[0];
var m = data[1];
var data = readline().split(' ');
for (i=0;i<Na;i++){
	MasA[i]=data[i];
}
var data = readline().split(' ');
for (i=0;i<Nb;i++){
	MasB[i]=data[i];
}
var result = "YES"
if (MasA[k-1]>=MasB[MasB.length-m]){
	result = "NO";
}
//write(MasA[k-1]+" ");
//write(MasB[MasB.length-m]+ " ");
write(result);

function getInputs() {
    return readline().split(' ').map(function(x) { return parseInt(x) });
}

var inputs = getInputs();

var sizeA = inputs[0];
var sizeB = inputs[1];

var limits = getInputs();

var k = limits[0];
var m = limits[1];

var A = getInputs();
var B = getInputs();

var first = A.slice(0, k);
var second = B.slice(-m);

var answer = 'YES';

for (var i = 0; i < k; i++) {
    var item = first[i];

    var isLess = false;

    for (var j = 0; j < m; j++) {

        if (item < second[j]) {
            isLess = true;
            break;
        }
    }

    if (!isLess) {
        answer = 'NO';
        break;
    }
}

print(answer);

function getInputs() {
    return readline().split(' ').map(function(x) { return parseInt(x) });
}

var inputs = getInputs();

var sizeA = inputs[0];
var sizeB = inputs[1];

var limits = getInputs();

var k = limits[0];
var m = limits[1];

var A = getInputs();
var B = getInputs();

var first = A.slice(k);
var second = B.slice(-m);

var answer = 'YES';

for (var i = 0; i < k; i++) {
    var item = first[i];

    var isLess = false;

    for (var j = 0; j < m; j++) {

        if (item < second[j]) {
            isLess = true;
            break;
        }
    }

    if (!isLess) {
        answer = 'NO';
        break;
    }
}

print(answer);


function getInt(num){
    return parseInt(num, 10)
}

var t = parseInt(readline(), 10);

for(var i = 0; i<t; i++){
    var line1 = readline().split(' ').map(getInt);
    print(solution.apply(undefined,line1));
}
function solution(a, b){
    return a*b
}

T = readline()
while(T--){
   c = readline().split(' ').map(c => +c)
   a = c[0]
   b = c[1]
   print(a*b)
}

T = readline()

while (T--) {
    n = readline().split(' ').map(x => +x)
    a = n[0]
    b = n[1]
    print(a*b)
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    }
)

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve([a,b]) {
    console.log(a*b)
}

function main() {
    for (let i = 0; i < inputArr.length; i++) {
        solve(inputArr[i])
    }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var a = nextInt();
		var b = nextInt();
		myout(a * b);
	}
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

// Make a Snippet for the code above this and then write your logic in main();
var mod = 998244353n
var maxN = 10e6 + 1

function main() {
  var x = parseInt(readline())
  //
  Array(parseInt(x)).fill(1).map((t, iii) => {
    // var n = parseInt(readline())
    //   var a = new Array(n)
    //   var marked = new Array(n).fill(false)
    //   var found = new Array(n).fill(false)
    var [a,b] = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    // var b = readline().split('').map((x, iii) => {
    //   return x
    // });
    console.log(a*b)
  })
}

function find(value, a) {
  var l = -1
  var r = a.length
  while (r > l + 1) {
    var m = Math.floor((r + l) / 2)
    // console.log(a[m], f, l, r)
    if (a[m] <= value) l = m
    if (a[m] > value) r = m
  }
  return r
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    }
)

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve([a,b]) {
    console.log(a*b)
}

function main() {
    for (let i = 0; i < inputArr.length; i++) {
        console.log(inputArr[i])
    }
}


let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0, x = 0;
    for(i = 1; i <= t * 2; i++){
        var a = lines[i].split(' ').map(Number);
        if(i % 2 == 1){
            n = a[0], x = a[1];
        }else{
            var ans = 0;
            var min = 2e9;
            var max = 0;
            for(j = 0; j < n; j++){
                min = Math.min(min, a[j]);
                max = Math.max(max, a[j]);
                if(max - min > x * 2){
                    ans++;
                    min = max = a[j];
                }
            }
            console.log(ans);
        }
    }
});

var tests = parseInt(readline());
    var n, x;
    var arr;
    for (var t=0; t < tests; t++) {
        var nx = readline().split(' ').map(x=>parseInt(x));
        n = nx[0];
        x = nx[1];
        var f = readline().split(' ').map(x=>parseInt(x));
        var count = 0;
        var min = f[0], max = f[0];
        for (var i = 1; i < n; i++) {
            var fi = f[i];
            if (fi < min) {
                min = fi;
            }
            if (fi > max) {
                max = fi;
            }
            if (max - min > 2 * x) {
                count++;
                max = fi;
                min = fi;
            }
        }
        print(count);
    }