You are given $n$ integers $a_1, a_2, \ldots, a_n$. Find the maximum value of $max(a_l, a_{l + 1}, \ldots, a_r) \cdot min(a_l, a_{l + 1}, \ldots, a_r)$ over all pairs $(l, r)$ of integers for which $1 \le l < r \le n$.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10000$)  — the number of test cases.

The first line of each test case contains a single integer $n$ ($2 \le n \le 10^5$).

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^6$).

It is guaranteed that the sum of $n$ over all test cases doesn't exceed $3 \cdot 10^5$.


-----Output-----

For each test case, print a single integer  — the maximum possible value of the product from the statement.


-----Examples-----

Input
4
3
2 4 3
4
3 2 3 1
2
69 69
6
719313 273225 402638 473783 804745 323328
Output
12
6
4761
381274500335


-----Note-----

Let $f(l, r) = max(a_l, a_{l + 1}, \ldots, a_r) \cdot min(a_l, a_{l + 1}, \ldots, a_r)$.

In the first test case,

$f(1, 2) = max(a_1, a_2) \cdot min(a_1, a_2) = max(2, 4) \cdot min(2, 4) = 4 \cdot 2 = 8$.

$f(1, 3) = max(a_1, a_2, a_3) \cdot min(a_1, a_2, a_3) = max(2, 4, 3) \cdot min(2, 4, 3) = 4 \cdot 2 = 8$.

$f(2, 3) = max(a_2, a_3) \cdot min(a_2, a_3) = max(4, 3) \cdot min(4, 3) = 4 \cdot 3 = 12$.

So the maximum is $f(2, 3) = 12$.

In the second test case, the maximum is $f(1, 2) = f(1, 3) = f(2, 3) = 6$.

Difficulty: EASY
Tags: Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
def test():
	n = int(input())
	l = list(map(int, input().split()))
	mx = 0
	for i in range(n - 1):
		mx = max(mx, l[i] * l[i + 1])
	print(mx)
t = int(input())
while t:
	test()
	t -= 1


t = int(input().strip())
result = []
for i in range(t):
	n = int(input())
	numbers = list(map(int, input().strip().split()))[:n]
	r = 0
	for j in range(n - 1):
		r = max(r, numbers[j] * numbers[j + 1])
	result.append(r)
for i in result:
	print(i)


import sys
input = sys.stdin.buffer.readline

def solve():
	ans = 1
	for i in range(1, N):
		ans = max(ans, A[i] * A[i - 1])
	return ans
test_cases = int(input())
for test_case in range(test_cases):
	N = int(input())
	A = list(map(int, input().split()))
	print(solve())


res = []
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans = max(ans, a[i] * a[i + 1])
	res.append(ans)
print(*res, sep='\n')


from collections import defaultdict
tc = int(input())
for _ in range(tc):
	n = int(input())
	l = list(map(int, input().split()))
	m = l[0] * l[1]
	for i in range(n - 1):
		m = max(m, l[i] * l[i + 1])
	print(m)


from itertools import permutations
import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 * 10 ** 9, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ma = max(l)
	ans = l[0] * l[1]
	for i in range(n):
		if i > 0:
			ans = max(ans, l[i] * l[i - 1])
		if i < n - 1:
			ans = max(ans, l[i] * l[i + 1])
	print(ans)


import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import *
from collections import defaultdict, deque, Counter
import math, string
from heapq import *
from operator import add
from itertools import accumulate
BUFSIZE = 8192
sys.setrecursionlimit(10 ** 5)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
inf = float('inf')
en = lambda x: list(enumerate(x))
ceil_ = lambda a, b: (a + b - 1) // b
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())

def solve():
	n = ii()
	arr = rr()
	a = -inf
	for (i, j) in zip(arr[:-1], arr[1:]):
		a = max(a, i * j)
	print(a)
for _ in ' ' * ii():
	solve()


PI = 3.141592653589793
INF = float('inf')
MOD = 1000000007

def bin32(num):
	return '{0:032b}'.format(num)

def add(x, y):
	return (x + y) % MOD

def sub(x, y):
	return (x - y + MOD) % MOD

def mul(x, y):
	return x * y % MOD

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def power(x, y):
	res = 1
	x %= MOD
	while y != 0:
		if y & 1:
			res = mul(res, x)
		y >>= 1
		x = mul(x, x)
	return res

def mod_inv(n):
	return power(n, MOD - 2)

def prob(p, q):
	return mul(p, power(q, MOD - 2))

def ii():
	return int(input())

def li():
	return [int(i) for i in input().split()]

def ls():
	return [i for i in input().split()]
for t in range(ii()):
	t += 1
	n = ii()
	a = li()
	ans = 0
	for i in range(n - 1):
		ans = max(ans, a[i] * a[i + 1])
	print(ans)


import sys
t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	max_val = 0
	for i in range(len(lst) - 1, 0, -1):
		if lst[i] * lst[i - 1] > max_val:
			max_val = lst[i] * lst[i - 1]
	print(max_val)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	maxx = 0
	for i in range(n - 1):
		maxx = max(arr[i] * arr[i + 1], maxx)
	print(maxx)


import sys
input = sys.stdin.readline
t = int(input())
maxProd = 1
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	for i in range(n - 1):
		if (temp := (a[i] * a[i + 1])) > maxProd:
			maxProd = temp
	print(maxProd)
	maxProd = 1


for _ in range(int(input())):
	n = int(input())
	ans = 1
	l = list(map(int, input().split()))
	for i in range(1, n):
		m = l[i] * l[i - 1]
		ans = max(ans, m)
	print(ans)


import os, sys
import itertools
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
try:
	(sys.stdin, sys.stdout) = (open('input.txt', 'r'), open('output.txt', 'w'))
except:
	pass
mod = int(1000000000.0 + 7)
from collections import *
import math
from sys import stdin, stdout

def input_array():
	return list(map(int, stdin.readline().split()))

def input_one():
	return int(stdin.readline())

def input_two():
	(a, b) = map(int, stdin.readline().split())
	return (a, b)

def input_three():
	(a, b, c) = map(int, stdin.readline().split())
	return (a, b, c)

def input_four():
	(a, b, c, d) = map(int, stdin.readline().split())
	return (a, b, c, d)

def input_five():
	(a, b, c, d, e) = map(int, stdin.readline().split())
	return (a, b, c, d, e)

def input_six():
	(a, b, c, d, e, f) = map(int, stdin.readline().split())
	return (a, b, c, d, e, f)

def input_s():
	s = input()
	return s
n = int(input())
while n > 0:
	t = int(input())
	l = [int(x) for x in input().split()]
	count = 0
	for i in range(1, t):
		count = max(count, l[i] * l[i - 1])
	print(count)
	n -= 1


for _ in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	mx = max(m)
	out = 0
	for i in range(1, n - 1):
		if out < max(m[i - 1:i + 2]) * min(m[i - 1:i + 2]):
			out = max(m[i - 1:i + 2]) * min(m[i - 1:i + 2])
		out = max(out, m[i - 1] * m[i], m[i] * m[i + 1])
	if n == 2:
		out = m[0] * m[1]
	print(out)


t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))[:n]
	Max = 0
	for i in range(1, n):
		Max = max(Max, arr[i - 1] * arr[i])
	print(Max)


for _ in range(int(input())):
	amount = int(input())
	numbers = [int(x) for x in input().split()]
	summe = 0
	for i in range(amount - 1):
		min_1 = numbers[i]
		max_1 = numbers[i + 1]
		for i2 in range(i + 1, amount):
			if numbers[i2] > max_1:
				max_1 = numbers[i2]
			else:
				summe = max(summe, max_1 * min_1)
				break
	print(summe)


from sys import stdin
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, stdin.readline().split()))
	arr.append(-1)
	arr2 = []
	c = 1
	for i in range(1, n + 1):
		if arr[i] != arr[i - 1]:
			arr2.append([arr[i - 1], c])
			c = 1
		else:
			c += 1
	ans = 0
	l = len(arr2)
	for i in range(l):
		if arr2[i][1] > 1:
			ans = max(ans, arr2[i][0] * arr2[i][0])
		if i > 0:
			ans = max(ans, arr2[i][0] * arr2[i - 1][0])
		if i < l - 1:
			ans = max(ans, arr2[i][0] * arr2[i + 1][0])
	print(ans)


t = int(input())
output = []
for c in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans = max(ans, a[i] * a[i + 1])
	output.append(ans)
for e in output:
	print(e)


k = []
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = a[0] * a[1]
	for i in range(1, n - 1):
		p = max(p, a[i] * a[i + 1])
	k.append(p)
for i in k:
	print(i)


mod = 1000000007
from math import factorial, ceil, pow, sqrt, floor, gcd
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	l = list(map(int, stdin.readline().split()))
	maxy = 0
	for i in range(1, n):
		maxy = max(maxy, l[i] * l[i - 1])
	print(maxy)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	max_val = 0
	for i in range(n - 1):
		max_val = max(max_val, max(array[i], array[i + 1]) * min(array[i], array[i + 1]))
	print(max_val)


def cast(cre, typ):
	return type(typ)(map(cre, typ))

def inp_lis(cre):
	if cre == str:
		return input().split()
	elif cre == bool:
		return cast(bool, cast(int, input().split()))
	else:
		return cast(cre, input().split())

def repl(str_, idx=-1, char=''):
	leng = len(str_)
	return str_[:idx] + char + str_[(leng + idx) % leng + 1:]

def solution():
	for t in range(int(input())):
		n = int(input())
		seq = inp_lis(int)
		maxv = 0
		for i in range(n - 1):
			if maxv < seq[i] * seq[i + 1]:
				maxv = seq[i] * seq[i + 1]
		print(maxv)
	return
solution()


t = int(input())
for i in range(t):
	n = int(input())
	var = list(map(int, input().split()))
	res = 0
	for p in range(n - 1):
		res = max(res, var[p] * var[p + 1])
	print(res)


def sex(n, a):
	m = 0
	for i in range(n - 1):
		if m < a[i] * a[i + 1]:
			m = a[i] * a[i + 1]
	return m
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(sex(n, a))


for _ in range(int(input())):
	n = int(input())
	lst = []
	a = list(map(int, input().split()))
	for i in range(n - 1):
		x = a[i] * a[i + 1]
		lst.append(x)
	print(max(lst))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = 0
	for i in range(1, n):
		m = max(m, a[i] * a[i - 1])
	print(m)


def solve():
	n = int(input())
	a = [int(item) for item in input().strip().split()]
	maxi = 0
	for i in range(n - 1):
		maxi = max(maxi, a[i] * a[i + 1])
	print(maxi)
t = 1
t = int(input())
for i in range(t):
	solve()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(max((a[i] * a[i + 1] for i in range(n - 1))))


def solve(n, l):
	p = l[0]
	ma = 0
	for i in range(1, n):
		prod = p * l[i]
		ma = max(prod, ma)
		p = l[i]
	return ma
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	print(solve(n, l))


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	n = inp()
	l = li()
	ans = -INF
	for i in range(n - 1):
		ans = max(ans, l[i] * l[i + 1])
	pr(ans)
for _ in range(inp()):
	solve()


import os
import sys
import math
from io import BytesIO, IOBase
from operator import itemgetter

def solve():
	n = int(input())
	a = [int(x) for x in input().split()]
	Max = -99999999999999999999999
	for i in range(n - 1):
		Max = max(Max, a[i] * a[i + 1])
	print(Max)

def upperbound(arr, val):
	start = 0
	end = len(arr) - 1
	ans = -1
	while start <= end:
		mid = (start + end) // 2
		if arr[mid] <= val:
			start = mid + 1
		else:
			ans = mid
			end = mid - 1
	return ans

def lowerbound(arr, val):
	length = len(arr)
	answer = -1
	start = 0
	end = length - 1
	while start <= end:
		middle = (start + end) // 2
		if arr[middle] == val:
			answer = middle
			end = middle - 1
		elif arr[middle] > val:
			end = middle - 1
		else:
			start = middle + 1
	return answer

def D2B(n):
	arr = []
	while n > 0:
		temp = n
		m = 0
		p = 1
		while temp:
			rem = temp % 10
			temp = int(temp / 10)
			if rem != 0:
				m += p
			p *= 10
		arr.append(m)
		n = n - m
	return arr

def sort2D(arr, axis):
	arr = sorted(arr, key=itemgetter(axis))
	return arr

def DD(rows, cols):
	arr = [[0 for i in range(cols)] for j in range(rows)]
	return arr
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
f = 1
if f == 1:
	t = int(input())
	while t:
		solve()
		t -= 1
else:
	solve()


def test_case():
	n = int(input())
	arr = [int(i) for i in input().split(' ')]
	currMax = 0
	for i in range(1, n):
		currMax = max(currMax, arr[i] * arr[i - 1])
	print(currMax)

def main():
	T = int(input())
	for _ in range(T):
		test_case()
main()


def better(mult, c, d):
	nult_new = c * d
	if mult >= nult_new:
		return mult
	else:
		return nult_new

def solve():
	n = int(input())
	nums = input().split()
	l = [int(i) for i in nums]
	mult = 0
	for i in range(n - 1):
		mult = better(mult, l[i], l[i + 1])
	return mult
for _ in range(int(input())):
	print(solve())


t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split()))
	mx = a[0]
	for i in range(1, n):
		mx = max(mx, a[i - 1] * a[i])
	print(mx)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	m = []
	for j in range(n - 1):
		m.append(l[j] * l[j + 1])
	print(max(m))


for _ in range(int(input())):
	x = int(input())
	lis = list(map(int, input().split()))
	fin = 0
	for i in range(1, x):
		if lis[i - 1] * lis[i] > fin:
			fin = lis[i - 1] * lis[i]
	print(fin)


from collections import defaultdict
from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	r = max(arr[0], arr[1])
	m = min(arr[0], arr[1])
	r = r * m
	for i in range(1, n):
		if r < arr[i] * arr[i - 1]:
			r = arr[i] * arr[i - 1]
	print(r)


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		print(max((a[i - 1] * a[i] for i in range(1, n))))
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = 0
	for i in range(len(l) - 1):
		temp = l[i] * l[i + 1]
		if temp > m:
			m = temp
	print(m)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = []
	for i in range(n - 1):
		a.append(l[i] * l[i + 1])
	print(max(a))


for i in range(int(input())):
	n = int(input())
	ans = 0
	t = list(map(int, input().split()))
	for i in range(1, n):
		ans = max(ans, t[i] * t[i - 1])
	print(ans)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		if ans < a[i] * a[i + 1]:
			ans = a[i] * a[i + 1]
	print(ans)
	t -= 1


t = int(input())

def maxPro():
	n = int(input())
	l = list(map(int, input().strip().split()))
	max = 0
	for i in range(n - 1):
		m = l[i] * l[i + 1]
		if max < m:
			max = m
	print(max)
for i in range(t):
	maxPro()


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	T = inp()
	while T > 0:
		n = inp()
		arr = inlt()
		ans = -1
		for i in range(0, n - 1):
			ans = max(ans, arr[i] * arr[i + 1])
		print(ans)
		T -= 1
main()


t = int(input())
for i in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	arr = []
	if n == 2:
		print(lis[0] * lis[1])
	else:
		for j in range(n - 1):
			arr.append(lis[j] * lis[j + 1])
		print(max(arr))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(max((arr[i] * arr[i + 1] for i in range(n - 1))))


def main():
	T = int(input())
	j = 0
	while j < T:
		n = int(input())
		array = list(map(int, input().split(' ')))
		max_prod = 0
		for i in range(1, n):
			max_prod = max(max_prod, array[i] * array[i - 1])
		print(max_prod)
		j += 1
main()


import collections
import random
import math
from collections import defaultdict
import itertools
from sys import stdin, stdout
import sys
import operator
from decimal import Decimal
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()

def li():
	return [int(i) for i in input().split()]

def lli(rows):
	return [li() for _ in range(rows)]

def si():
	return input()

def ii():
	return int(input())

def ins():
	return input().split()

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		m = 0
		for i in range(1, n):
			if a[i - 1] * a[i] > m:
				m = a[i - 1] * a[i]
		print(m)
main()


t = int(input())
answers = []
for _t in range(t):
	n = int(input())
	a = input()
	a = [int(i) for i in a.split()]
	max_prod = 0
	for i in range(n - 1):
		if a[i] * a[i + 1] > max_prod:
			max_prod = a[i] * a[i + 1]
	answers.append(max_prod)
for answer in answers:
	print(answer)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans = max(ans, l[i] * l[i + 1])
	print(ans)


my_value = []
for i in range(int(input())):
	num = int(input())
	lis = list(map(int, input().split()))
	max_ = 0
	for i in range(num - 1):
		max_ = max(max_, lis[i] * lis[i + 1])
	my_value.append(max_)
for i in my_value:
	print(i)


n = int(input())
ans = []
oval = []
val = []
odd = 0
for i in range(n * 2):
	sub_ans = 0
	if odd == 0:
		a = int(input())
		oval.append(a)
		odd = 1
	else:
		a = list(map(int, input().split()))
		for j in range(0, len(a) - 1):
			wa = a[j] * a[j + 1]
			if wa > sub_ans:
				sub_ans = wa
		odd = 0
		ans.append(sub_ans)
for i in range(len(ans)):
	print(ans[i])


m = int(input())
l = []
for _ in range(m):
	t = int(input())
	a = list(map(int, input().split()))
	max = -44543
	for i in range(t - 1):
		if max < a[i] * a[i + 1]:
			max = a[i] * a[i + 1]
	l.append(max)
for i in l:
	print(i)


test = int(input())
for _ in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = arr[0] * arr[1]
	for i in range(1, n - 1):
		ans = max(arr[i] * arr[i + 1], ans)
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	l = [int(x) for x in input().split()]
	max = l[0] * l[1]
	for i in range(1, n - 1):
		if l[i] * l[i + 1] > max:
			max = l[i] * l[i + 1]
	print(max)
	t -= 1


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans = max(ans, a[i] * a[i + 1])
	print(ans)


tcase = int(input().strip())
for _ in range(tcase):
	n = int(input().strip())
	nums = list(map(int, input().strip().split()))
	(maxpos, minpos) = (0, 0)
	if nums[1] > nums[0]:
		maxpos = 1
	else:
		minpos = 1
	prodmax = nums[0] * nums[1]
	for i in range(2, n):
		if maxpos is None:
			if nums[i] > nums[minpos]:
				maxpos = i
			else:
				(minpos, maxpos) = (i, minpos)
			prodmax = max(prodmax, nums[minpos] * nums[maxpos])
			continue
		if nums[i] >= nums[maxpos]:
			if maxpos > minpos:
				(maxpos, minpos) = (i, maxpos)
			else:
				maxpos = i
			prodmax = max(prodmax, nums[minpos] * nums[maxpos])
		elif nums[i] > nums[minpos]:
			if maxpos > minpos:
				minpos = i
				prodmax = max(prodmax, nums[minpos] * nums[maxpos])
			else:
				(minpos, maxpos) = (i, None)
		else:
			(minpos, maxpos) = (i, None)
	print(prodmax)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_string():
	return list(map(str, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def get_int():
	return int(sys.stdin.readline().strip())

def get_print_int(x):
	sys.stdout.write(str(x) + '\n')

def get_print(x):
	sys.stdout.write(x + '\n')

def get_print_int_same(x):
	sys.stdout.write(str(x) + ' ')

def get_print_same(x):
	sys.stdout.write(x + ' ')
from sys import maxsize

def solve():
	for _ in range(get_int()):
		n = get_int()
		arr = get_list()
		ans = arr[0] * arr[1]
		for i in range(1, n - 1, 1):
			ans = max(ans, arr[i] * arr[i + 1])
		get_print_int(ans)
solve()


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	value = []
	for i in range(len(li) - 1):
		value.append(li[i] * li[i + 1])
	print(max(value))


n = int(input())
for i in range(n):
	m = int(input())
	list_a = list(map(int, input().split()))
	output = 0
	for i in range(m - 1):
		output = max(output, list_a[i] * list_a[i + 1])
	print(output)


from sys import stdin, stdout, setrecursionlimit as srl
from threading import stack_size
from collections import deque, defaultdict as dd
from math import gcd, ceil
from bisect import bisect_left as lb
from bisect import bisect_right as rb
input = stdin.readline
flush = stdout.flush
tc = 1
tc = int(input())
for _ in range(tc):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans = max(ans, a[i] * a[i + 1])
	print(ans)


from sys import stdin, stdout
print = stdout.write
input = stdin.readline

class Node:

	def __init__(self, start, end, min, max):
		(self.start, self.end) = (start, end)
		(self.min, self.max) = (min, max)

	def __repr__(self):
		return f'{self.start}-{self.end} (min:{self.min}, max: {self.max})\n'

class BinaryTree:

	def __init__(self, array, length):
		self.array = [None for _ in range(self.get_msb(length) - 1)] + [Node(i, i, array[i], array[i]) for i in range(length)] + [None for _ in range(self.get_msb(length) - length)]
		for i in range(len(self.array) // 2 - 1, -1, -1):
			left = (i << 1) + 1
			right = left + 1
			(left, right) = (self.array[left], self.array[right])
			if left is None:
				continue
			else:
				(start, end) = (left.start, left.end)
				(_min, _max) = (left.min, left.max)
				if right is not None:
					end = right.end
					(_min, _max) = (min(_min, right.min), max(_max, right.max))
				node = Node(start, end, _min, _max)
				self.array[i] = node
		print(str(self.array))

	def get_msb(self, n):
		if not n:
			return 0
		msb = 1
		while n > 1:
			n = n >> 1
			msb += 1
		return 1 << msb

def solve_test():
	n = int(input())
	a = [int(x) for x in input().split()]
	_max = 0
	for i in range(n - 1):
		_max = max(_max, a[i] * a[i + 1])
	return _max

def main(args=None):
	tests = int(input())
	for _ in range(tests):
		print(f'{solve_test()}\n')
main()


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	m = 0
	for i in range(n - 1):
		t = arr[i] * arr[i + 1]
		if t > m:
			m = t
	print(m)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = -1 * float('inf')
	for i in range(n - 1):
		ans = max(ans, a[i] * a[i + 1])
	print(ans)


def bestMaxMin(a):
	res = 0
	for i in range(1, len(a)):
		if a[i] * a[i - 1] > res:
			res = a[i] * a[i - 1]
	return res
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	print(bestMaxMin(a))


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	res = 0
	for i in range(n):
		last = 0
		end = 0
		if i - 1 >= 0:
			last = l[i - 1]
		if i + 1 < n:
			end = l[i + 1]
		res = max(res, l[i] * max(last, end))
	print(res)


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
INT_MAX = 10 ** 13
from bisect import bisect_left
import sys
MOD = 10 ** 9 + 7
inf = MOD ** 2

def func(n, A):
	ans = -1
	for i in range(n - 1):
		ans = max(ans, A[i] * A[i + 1])
	return ans
for _ in range(int(input())):
	n = int(input())
	A = INPUT()
	print(func(n, A))


n = int(input())
for i in range(n):
	c = 1
	x = []
	k = int(input())
	p = list(map(int, input().split()))
	for j in range(len(p) - 1):
		c = p[j] * p[j + 1]
		x.append(c)
	print(max(x))


T = int(input())
for _ in range(T):
	N = int(input())
	arr = list(map(int, input().split()))
	maXX = 0
	for i in range(1, len(arr)):
		maXX = max(arr[i] * arr[i - 1], maXX)
	print(maXX)


for _ in range(int(input())):
	x = int(input())
	arr = list(map(int, input().split()))
	l = [max(arr) * min(arr)]
	for i in range(x - 1):
		l.append(arr[i] * arr[i + 1])
	print(max(l))


m = int(input())
for d in range(m):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for i in range(n - 1):
		l.append(a[i] * a[i + 1])
	print(max(l))


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	n = int(input())
	data = list(map(int, input().split()))
	for i in range(n - 1):
		data[i] = data[i] * data[i + 1]
	print(max(data))


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	mx = -1
	for i in range(n - 1):
		if a[i] * a[i + 1] > mx:
			mx = a[i] * a[i + 1]
	print(mx)
T = int(input())
for i in range(T):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = max([x * y for (x, y) in zip(a[:-1], a[1:])])
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	k = 0
	g = k + 1
	l = s[g] * s[k]
	while g + 1 < n:
		k = k + 1
		g = g + 1
		j = s[g] * s[k]
		if j >= l:
			l = j
	print(l)


cases = int(input())
for _ in range(cases):
	num = int(input())
	arr = list(map(int, input().split()))
	best = -10 ** 10
	for i in range(1, num):
		best = max(best, arr[i - 1] * arr[i])
	print(best)


for _ in range(int(input())):
	n = int(input())
	v = [int(x) for x in input().split(' ')]
	s = []
	for i in range(n - 1):
		s.append(v[i] * v[i + 1])
	print(max(s))


for _ in range(int(input())):
	input()
	a = list(map(int, input().split()))
	print(max((a[i] * a[i + 1] for i in range(len(a) - 1))))


import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline().rstrip()
inf = 10 ** 16
md = 10 ** 9 + 7

def solve():
	n = II()
	aa = LI()
	ans = max((a0 * a1 for (a0, a1) in zip(aa, aa[1:])))
	print(ans)
for testcase in range(II()):
	solve()


from sys import *
input = lambda : stdin.readline()
int_arr = lambda : list(map(int, stdin.readline().strip().split()))
str_arr = lambda : list(map(str, stdin.readline().split()))
get_str = lambda : map(str, stdin.readline().strip().split())
get_int = lambda : map(int, stdin.readline().strip().split())
get_float = lambda : map(float, stdin.readline().strip().split())
mod = 1000000007
setrecursionlimit(1000)
for _ in range(int(input())):
	n = int(input())
	arr = int_arr()
	mx = float('-inf')
	for i in range(1, n):
		mx = max(mx, arr[i] * arr[i - 1])
	print(mx)


t = int(input())
for inh in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	(l, r) = (0, 1)
	k = a[r] * a[l]
	r += 1
	while r < n:
		k = max(k, a[r] * a[r - 1])
		r += 1
	print(k)


for g in [*open(0)][2::2]:
	a = list(map(int, g.split()))
	print(max([a[i] * a[i + 1] for i in range(len(a) - 1)]))


for sss in [*open(0)][2::2]:
	aaa = (*map(int, sss.split()),)
	print(max((xxx * yyy for (xxx, yyy) in zip(aaa, aaa[1:]))))


t = int(input())
for _ in range(t):
	n = int(input())
	ans = 0
	a = list(map(int, input().split()))
	for i in range(1, len(a)):
		ans = max(ans, a[i] * a[i - 1])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if n == 2:
		print(arr[0] * arr[1])
	else:
		res = -1
		for i in range(n - 1):
			if max(arr[i + 1], arr[i]) * min(arr[i + 1], arr[i]) > res:
				res = max(arr[i + 1], arr[i]) * min(arr[i + 1], arr[i])
		print(res)


for t in range(int(input())):
	n = int(input())
	L = [int(X) for X in input().split()]
	max = L[0] * L[1]
	for i in range(1, n - 1):
		if L[i] * L[i + 1] > max:
			max = L[i] * L[i + 1]
	print(max)


import math
debug = True

def pprint(*args, delimiter='#', amount=10):
	if debug:
		print('{0} DEBUG {0}'.format(delimiter * amount))
		print(*args)
		print('{0} ----- {0}'.format('-' * amount))

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	maximal = 1
	for i in range(n - 1):
		if a[i] * a[i + 1] >= maximal:
			maximal = a[i] * a[i + 1]
	return maximal
t = int(input())
while t > 0:
	t -= 1
	print(solve())


import sys, os, time
from math import log, sqrt, floor
from os import path
import math
oj = True
if path.exists('inp.txt'):
	print('YES')
	sys.stdin = open('inp.txt', 'r')
	sys.stdout = open('out.txt', 'w')
	oj = False
mod = 1000000007
INF = float('inf')

def readint():
	return int(sys.stdin.readline())

def readlst():
	return list(map(int, sys.stdin.readline().strip().split()))

def readmul():
	return map(int, sys.stdin.readline().strip().split())

def is_power_two(x):
	return x ^ x - 1 & x == x

def lcm(a, b):
	return a * b // gcd(a, b)

def seive():
	(primes[0], primes[1]) = (False, False)
	for i in range(2, maxN + 1):
		for j in range(i * i, maxN + 1, i):
			if primes[j]:
				primes[j] = False

def power_2(n):
	return 1 << n

def ceil(a, b):
	return int((a + b - 1) / b)

def isPerfectSquare(x):
	if x >= 0:
		sr = sqrt(x)
		return sr * sr == x
	return false

def omkar():
	n = readint()
	l = readlst()
	mx = max(l)
	ans = 0
	ind = []
	for i in range(0, n):
		if i - 1 >= 0:
			ans = max(ans, l[i] * l[i - 1])
		if i + 1 < n:
			ans = max(ans, l[i] * l[i + 1])
	print(ans)
	return

def main():
	tc = readint()
	start = time.time()
	while tc:
		omkar()
		tc -= 1
	if not oj:
		total = time.time() - start
		print(str(total * 1000) + 'ms')
main()


for s in [*open(0)][2::2]:
	l = [*map(int, s.split())]
	print(max((x * y for (x, y) in zip(l, l[1:]))))


cases = int(input())
for z in range(cases):
	num = int(input())
	mylist = [int(i) for i in input().split()]
	ans = -1
	for i in range(1, num):
		if mylist[i] * mylist[i - 1] > ans:
			ans = mylist[i] * mylist[i - 1]
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	products = []
	for i in range(n - 1):
		products.append(nums[i] * nums[i + 1])
	print(max(products))


DEBUG = 0
if DEBUG == 1:
	data = open('test1.in', 'r')

def readline():
	if DEBUG == 1:
		return data.readline().strip('\r\n')
	else:
		try:
			return input().strip('\r\n')
		except EOFError:
			return ''

def readi():
	return [int(t) for t in readline().split()]
(t,) = readi()
for _ in range(t):
	(n,) = readi()
	a = readi()
	ans = 0
	for i in range(n - 1):
		if a[i] * a[i + 1] > ans:
			ans = a[i] * a[i + 1]
	print(ans)
if DEBUG == 1:
	data.close()


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	m = max(a)
	idx = a.index(m)
	if idx == 0:
		ans = m * a[1]
	elif idx == n - 1:
		ans = m * a[-2]
	else:
		ans = m * max(a[idx - 1], a[idx + 1])
	for i in range(n - 1):
		if a[i] * a[i + 1] > ans:
			ans = a[i] * a[i + 1]
	print(ans)


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mx = 0
	for i in range(n - 1):
		mx = max(mx, arr[i] * arr[i + 1])
	print(mx)


from math import *
from sys import *
from bisect import *
from collections import *
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	ans = 0
	for i in range(n - 1):
		ans = max(ans, a[i] * a[i + 1])
	print(ans)


def solve():
	n = int(input().strip())
	a = list(map(int, input().strip().split()))
	ans = 0
	for l in range(n - 1):
		ans = max(ans, a[l] * a[l + 1])
	return ans
t = int(input().strip())
for _ in range(t):
	print(solve())


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	p = 1
	for i in range(1, n):
		if l1[i] * l1[i - 1] > p:
			p = l1[i] * l1[i - 1]
	print(p)


for i in range(int(input())):
	x = int(input())
	arr = list(map(int, input().split(' ')))
	maxx = arr[0] * arr[1]
	for i in range(1, len(arr) - 1):
		loc = arr[i] * arr[i + 1]
		if loc > maxx:
			maxx = loc
	print(maxx)


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	ans = 0
	maxi = 0
	for i in range(n - 1):
		maxi = lst[i] * lst[i + 1]
		if maxi > ans:
			ans = maxi
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	ans = 1
	for i in range(1, len(l)):
		ans = max(ans, l[i] * l[i - 1])
	print(ans)


for _ in range(int(input())):
	a = int(input())
	s = [int(i) for i in input().split()]
	d = [s[i] * s[i + 1] for i in range(len(s) - 1)]
	print(max(d))


n = int(input())
for _ in range(n):
	k = int(input())
	a = list(map(int, input().split()))
	b = [a[i] * a[i + 1] for i in range(k - 1)]
	print(max(b))


bigres = []
t = int(input())
for m in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	res = a[0] * a[1]
	for q in range(len(a) - 1):
		res = max(res, a[q] * a[q + 1])
	bigres += [res]
for i in range(len(bigres)):
	print(bigres[i])


import sys
from math import cos, pi, ceil, pi, tan, floor, gcd, sqrt, log2, factorial, log10
from collections import Counter
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase
from statistics import mean, median, mode
alpha = ascii_lowercase
beta = ascii_uppercase

def nextPowerOf2(n):
	p = 1
	if n and (not n & n - 1):
		return n
	while p < n:
		p <<= 1
	return p

def get_Divisors(n):
	arr = []
	i = 1
	while i <= sqrt(n):
		if n % i == 0:
			if n / i == i:
				arr.append(i)
			else:
				arr.append(i)
				arr.append(n // i)
		i = i + 1
	return arr

def isprime(n):
	if n == 1:
		return 0
	i = 2
	while i * i <= n:
		if n % i == 0:
			return 0
		i += 1
	return 1

def Sieve(n):
	prime = [True for i in range(n + 1)]
	prime[0] = False
	prime[1] = False
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def create_matrix(n, m):
	mat = [[] for i in range(n)]
	for i in range(n):
		for j in range(m):
			mat[i].append(0)
	return mat

def main():
	for ttt in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		ans = 0
		for i in range(n - 1):
			ans = max(ans, arr[i] * arr[i + 1])
		print(ans)
main()


T = int(input())
for case in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = [0] * (n - 1)
	for i in range(n - 1):
		ans[i] = arr[i] * arr[i + 1]
	print(max(ans))


import os
import sys
from collections import Counter
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		l = list(map(int, input().split()))
		idx = l.index(max(l))
		i = idx - 1
		maxp = 0
		minx = max(l)
		while i >= 0:
			minx = min(minx, l[i])
			maxp = max(maxp, l[idx] * minx, l[i] * l[i + 1])
			i -= 1
		i = idx + 1
		minx = l[idx]
		while i < n:
			minx = min(minx, l[i])
			maxp = max(maxp, l[idx] * minx, l[i] * l[i - 1])
			i += 1
		print(maxp)
main()


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	curr = -1
	for i in range(n - 1):
		curr = max(curr, a[i] * a[i + 1])
	print(curr)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split(' ')))
	max = 0
	for i in range(n - 1):
		x = l[i] * l[i + 1]
		if x > max:
			max = x
	print(max)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	if n == 2:
		print(arr[0] * arr[1])
	elif n == 1:
		print(arr[0])
	else:
		j = 1
		i = 2
		while j < n - 1:
			ans.append(arr[j] * max(arr[j - 1], arr[j + 1]))
			j += 1
		print(max(ans))


def findCherry():
	t = int(input())
	for i in range(t):
		n = int(input())
		nums = list(map(int, input().split()))
		ans = 0
		for i in range(n - 1):
			ans = max(nums[i] * nums[i + 1], ans)
		print(ans)
findCherry()


from sys import stdin

def main():
	cases = int(stdin.readline().strip())
	for i in range(cases):
		n = int(stdin.readline().strip())
		A = [int(x) for x in stdin.readline().split()]
		ans = 0
		for j in range(n - 1):
			ans = max(ans, A[j] * A[j + 1])
		print(ans)
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	q = list(map(int, input().split()))
	m = 0
	for i in range(len(q) - 1):
		m = max(m, q[i] * q[i + 1])
	print(m)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mx = 0
	for x in range(n - 1):
		mx = max(a[x] * a[x + 1], mx)
	print(mx)


def cherry(n, num):
	ans = max(num) * min(num)
	for i in range(1, n):
		ans = max(ans, num[i - 1] * num[i])
	return ans
t = int(input())
res = []
for _ in range(t):
	n = int(input())
	num = list(map(int, input().split()))
	res.append(cherry(n, num))
for i in res:
	print(i)


n = int(input())
arr = []
for x in range(n):
	_ = input()
	arr.append([int(k) for k in input().split()])
for current in arr:
	current_max = 0
	for x in range(1, len(current)):
		if current_max < current[x] * current[x - 1]:
			current_max = current[x] * current[x - 1]
	print(current_max)


def solve(length, nums):
	maxvalue = 0
	for i in range(length - 1):
		res = nums[i] * nums[i + 1]
		maxvalue = max(res, maxvalue)
	return maxvalue
t = int(input())
output = []
for i in range(t):
	n = int(input())
	nums = [int(i) for i in input().split()]
	output.append(solve(n, nums))
print(*output, sep='\n')


def read_ints():
	return [int(x) for x in input().split()]
outs = []

def prnt(s):
	outs.append(str(s))

def flush():
	print('\n'.join(outs))
t = read_ints()[0]
while t:
	t -= 1
	n = read_ints()[0]
	x = read_ints()
	jwb = 0
	for i in range(n - 1):
		jwb = max(jwb, x[i] * x[i + 1])
	prnt(jwb)
flush()


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))[:n]
	b = []
	for i in range(1, n - 1):
		b.append(ar[i] * ar[i - 1])
		b.append(ar[i] * ar[i + 1])
	b.append(ar[0] * ar[1])
	print(max(b))


a = int(input())
for i in range(0, a):
	K = int(input())
	P = list(map(int, input().split()))
	max = -1
	for i in range(K - 1):
		if P[i] * P[i + 1] > max:
			max = P[i] * P[i + 1]
	print(max)


T = int(input())
for t in range(T):
	N = int(input())
	arr = list(map(int, input().split()))
	ans = 0
	for i in range(N - 1):
		ans = max(ans, arr[i] * arr[i + 1])
	print(ans)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	R = []
	for i in range(len(arr) - 1):
		R.append(arr[i] * arr[i + 1])
	print(max(R))


def find():
	n = int(input())
	A = list(map(int, input().split()))
	ans = 0
	stack = []
	for a in A:
		while stack and stack[-1] > a:
			b = stack.pop()
			ans = max(ans, a * b)
		if stack:
			ans = max(ans, stack[-1] * a)
		stack.append(a)
	stack.reverse()
	while len(stack) > 1:
		ans = max(ans, stack[0] * stack.pop())
	print(ans)
t = int(input())
for _ in range(t):
	find()


t = int(input())
for i in range(t):
	n = int(input())
	mayor = 0
	a = [int(x) for x in input().split()]
	for i in range(n - 1):
		if mayor < a[i] * a[i + 1]:
			mayor = a[i] * a[i + 1]
	print(mayor)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	for (k, v) in enumerate(a):
		if k > 0:
			ans = max(ans, v * a[k - 1])
		if k < n - 1:
			ans = max(ans, v * a[k + 1])
	print(ans)


def solve(n, arr):
	ans = 0
	for i in range(n - 1):
		ans = max(ans, arr[i] * arr[i + 1])
	return ans
import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(n, arr))


t = int(input())
l = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))[:n]
	x = zip(a, a[1:])
	for (i, j) in x:
		l.append(i * j)
	print(max(l))
	l.clear()


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def max_product(arr):
	ans = 0
	for i in range(len(arr) - 1):
		ans = max(ans, arr[i] * arr[i + 1])
	return ans
t = inp()
for i in range(t):
	n = inp()
	arr = inlt()
	print(max_product(arr))


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, arr):
	ans = float('-inf')
	for i in range(1, n):
		ans = max(arr[i - 1] * arr[i], ans)
	print(ans)
for _ in range(int(input())):
	n = int(input())
	arr = int_arr()
	solve(n, arr)


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	print(max((x * y for (x, y) in zip(l, l[1:]))))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	maxi = 0
	if len(a) == 2:
		maxi = a[0] * a[1]
	else:
		for l in range(1, len(a)):
			temp_max = a[l] * a[l - 1]
			if temp_max > maxi:
				maxi = temp_max
	print(maxi)


def readint():
	return int(input())
t = readint()
for _ in range(t):
	n = readint()
	arr = [int(x) for x in input().split()]
	arr.append(1)
	arr.insert(0, 1)
	ans = 0
	for i in range(1, n + 1):
		if arr[i - 1] <= arr[i] >= arr[i + 1]:
			cans = max(arr[i - 1] * arr[i], arr[i] * arr[i + 1])
			ans = max(cans, ans)
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	maxVal = 1
	if n == 2:
		print(arr[0] * arr[1])
	else:
		for i in range(1, n - 1):
			maxVal = max(maxVal, max(arr[i] * arr[i - 1], arr[i] * arr[i + 1]))
		print(maxVal)


import sys
import bisect
from bisect import bisect_left as lb
from bisect import bisect_right as rb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs2(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
b = []
vis = []
tot = 0
time = []
time1 = []
adj = []
mx = -1
eps = 1e-07

def dfs(a, b, p, c):
	if a == b:
		return c
	for (i, j) in adj[a]:
		if i == p:
			continue
		temp = dfs(i, b, a, c + j)
		if dfs(i, b, a):
			mx = max(i, mx)
			return 1
adj = []
ans = []

def dfs(root, par, v):
	global adj, ans, abe
	tot = v
	for (child, val) in adj[root]:
		if par == child:
			continue
		tot |= dfs(child, root, val)
	ans[root] = tot
	return tot
abe = 0

def traverse(root, par):
	global adj, ans, abe
	for (child, val) in adj[root]:
		if par == child:
			continue
		if ans[child] == 0:
			abe += 1
		else:
			traverse(child, root)

def hnbhai(tc):
	n = sb()
	a = sd()
	ans = 0
	for i in range(1, n):
		if a[i - 1] <= a[i]:
			ans = max(ans, a[i] * a[i - 1])
	for i in range(n - 2, -1, -1):
		if a[i + 1] <= a[i]:
			ans = max(ans, a[i] * a[i + 1])
	print(ans)
for _ in range(sb()):
	hnbhai(_ + 1)


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	a = min(l[0], l[1]) * max(l[0], l[1])
	for i in range(n - 1):
		a = max(min(l[i], l[i + 1]) * max(l[i], l[i + 1]), a)
	print(a)


from typing import Counter
import sys
from collections import defaultdict as dd
from math import *

def vinp():
	return map(int, input().split())

def linp():
	return list(map(int, input().split()))

def sinp():
	return input()

def inp():
	return int(input())

def mod(f):
	return f % 1000000007

def pr(*x):
	print(*x)

def finp():
	f = open('input.txt', 'r')
	f = f.read().split('\n')
	return f

def finp():
	f = open('input.txt', 'r')
	f = f.read().split('\n')
	return f

def fout():
	return open('output.txt', 'w')

def fpr(f, x):
	f.write(x + '\n')

def csort(c):
	sorted(c.items(), key=lambda pair: pair[1], reverse=True)

def indc(l, n):
	c = {}
	for i in range(n):
		c[l[i]] = c.get(l[i], []) + [i + 1]
	return c
cou = inp()
for i in range(cou):
	n = inp()
	l = linp()
	ans = 0
	for i in range(n - 1):
		a = min(l[i], l[i + 1])
		b = max(l[i], l[i + 1])
		ans = max(ans, a * b)
	pr(ans)


t = int(input())
otv = list()
for i in range(t):
	n = int(input())
	sp = list(map(int, input().split()))
	it = -100000000000000000
	for j in range(1, n):
		if sp[j] * sp[j - 1] > it:
			it = sp[j] * sp[j - 1]
	otv.append(it)
for i in otv:
	print(i)


nt = int(input())
ans = []

def solve(arr):
	maxe = 1
	prod = 1
	maxprod = 1
	for x in range(len(arr) - 1):
		prod = arr[x] * arr[x + 1]
		if maxprod <= prod:
			maxprod = prod
	return maxprod
for x in range(nt):
	n = int(input())
	arr = list(map(int, input().split()))
	if n == 2:
		ans.append(arr[0] * arr[1])
		continue
	ans.append(solve(arr))
for x in range(nt):
	print(ans[x])


import sys
input = sys.stdin.readline

def I():
	return input().strip()

def II():
	return int(input().strip())

def LI():
	return [*map(int, input().strip().split())]
import copy, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter, OrderedDict
from itertools import permutations, combinations, groupby
from operator import itemgetter
for _ in range(II()):
	n = II()
	l = LI()
	z = -1
	for i in range(1, n):
		if l[i] * l[i - 1] > z:
			z = l[i] * l[i - 1]
	print(z)


from sys import stdin

def main():
	t = int(stdin.readline().strip())
	for _ in range(t):
		n = int(stdin.readline().strip())
		a = list(map(int, stdin.readline().split()))
		ans = -1
		i = 0
		while i < n - 1:
			temp = a[i] * a[i + 1]
			if temp > ans:
				ans = temp
			i += 1
		print(ans)
main()


for ss in [*open(0)][2::2]:
	aa = (*map(int, ss.split()),)
	print(max((xx * yy for (xx, yy) in zip(aa, aa[1:]))))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	mx = -10 ** 9
	for i in range(n - 1):
		if l[i] * l[i + 1] > mx:
			mx = l[i] * l[i + 1]
	print(mx)


n = int(input())
for i in range(n):
	a = int(input())
	x = list(map(int, input().split()))
	y = x[1:]
	max = 0
	for (i, j) in zip(x, y):
		if i * j > max:
			max = i * j
	print(max)


t1 = int(input())
for _ in range(t1):
	n = int(input())
	c = 0
	a = list(map(int, input().split()))
	for i in range(n - 1):
		if a[i] * a[i + 1] > c:
			c = a[i] * a[i + 1]
	print(c)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	b = []
	for i in range(1, len(a)):
		b.append(a[i] * a[i - 1])
	print(max(b))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = tuple(map(int, input().split()))
	prod = 0
	for i in range(1, n):
		v1 = arr[i - 1]
		v2 = arr[i]
		maxi = max(v1, v2)
		mini = min(v1, v2)
		prod = max(prod, v1 * v2)
	print(prod)


import sys
import math
import bisect
t = int(input())
for a0 in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	a = max(l)
	cur_max = -1
	for i in range(1, len(l) - 1):
		cur_max = max(cur_max, l[i] * l[i - 1], l[i] * l[i + 1])
	cur_max = max(cur_max, l[0] * l[1])
	cur_max = max(cur_max, l[n - 1] * l[n - 2])
	print(cur_max)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	x = 0
	for i in range(n - 1):
		x = max(x, a[i] * a[i + 1])
	print(x)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	ans = -100000000000000
	for i in range(n - 1):
		ans = max(ans, a[i] * a[i + 1])
	print(ans)


n = int(input())
while n != 0:
	n -= 1
	sum = 0
	m = int(input())
	a = [int(v) for v in input().split()]
	var = a[0]
	res = 0
	for i in range(1, m):
		res = max(res, var * a[i])
		var = a[i]
	print(res)
	print(end=' ')


import os
import sys
import time
import math
import pprint
import itertools as it
import operator as op
import bisect as bs
import functools as fn
from collections import deque, defaultdict, OrderedDict, Counter, ChainMap
(maxx, localsys, mod) = (1 << 60, 0, int(1000000000.0 + 7))

def nCr(n, r):
	return reduce(mul, range(n - r + 1, n + 1), 1) // factorial(r)

def ceil(n, x):
	return (n + x - 1) // x
(osi, oso) = ('/home/priyanshu/Documents/cp/input.txt', '/home/priyanshu/Documents/cp/output.txt')
if os.path.exists(osi):
	sys.stdin = open(osi, 'r')
	sys.stdout = open(oso, 'w')
input = sys.stdin.readline

def maps():
	return map(int, input().split())
for _ in range(*maps()):
	(n,) = maps()
	a = [*maps()]
	ans = 0
	for i in range(n - 1):
		ans = max(ans, a[i] * a[i + 1])
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	n = int(input())
	a = [*map(int, input().split())]
	print(max((a[i] * a[i + 1] for i in range(n - 1))))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = 0
	for i in range(n - 1):
		if p < a[i] * a[i + 1]:
			p = a[i] * a[i + 1]
	print(p)


def gcd(a, b):
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
testcases = 1
testcases = int(input())
for _ in range(testcases):
	n = int(input())
	zoz = [int(x) for x in input().split()]
	res = 0
	for i in range(1, n):
		res = max(res, zoz[i] * zoz[i - 1])
	print(res)


for _ in range(int(input())):
	N = int(input())
	li = list(map(int, input().split()))
	print(max((li[i - 1] * li[i] for i in range(1, N))))


N = int(input())
for i in range(N):
	m = int(input())
	A = list(map(int, input().split()))
	n = len(A)
	c = 0
	for i in range(n - 1):
		f_i = A[i] * A[i + 1]
		if f_i > c:
			c = f_i
	print(c)


from math import ceil
from bisect import bisect_left as bl
from bisect import bisect_right as br
from array import array as arr

def li():
	return list(map(int, input().split()))

def solve():
	for _ in range(int(input())):
		n = int(input())
		a = li()
		mx = 0
		for i in range(n - 1):
			if a[i] * a[i + 1] > mx:
				mx = a[i] * a[i + 1]
		print(mx)
solve()


n = int(input())
values = []
for _ in range(n):
	m = int(input())
	values.append(list(map(int, input().split())))
for v in values:
	result = 0
	for i in range(len(v) - 1):
		result = max(result, v[i] * v[i + 1])
	print(result)


T = int(input())
for x in range(T):
	n = int(input())
	a = [int(y) for y in input().split()]
	num = a[0] * a[1]
	for z in range(1, n):
		if a[z] * a[z - 1] >= num:
			num = a[z] * a[z - 1]
	print(num)


def solve(n, a):
	y = 0
	for i in range(n):
		if i > 0:
			y = max(y, a[i] * a[i - 1])
		if i < n - 1:
			y = max(y, a[i] * a[i + 1])
	return y
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(n, a))


import sys

def readstr():
	return sys.stdin.readline().strip()

def readint():
	return int(readstr())

def readints():
	return map(int, readstr().split())

def solve(n):
	a = list(readints())
	res = 0
	for i in range(n - 1):
		res = max(res, a[i] * a[i + 1])
	print(res)

def main():
	t = readint()
	for _ in range(t):
		n = readint()
		solve(n)
main()


for _ in range(int(input())):
	l2 = []
	m = 0
	n = int(input())
	l = list(map(int, input().strip().split()))[:n]
	for i in range(n - 1):
		l2.append(l[i] * l[i + 1])
	print(max(l2))


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	k = -1
	for i in range(n - 1):
		k = max(k, a[i] * a[i + 1])
	print(k)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	k = []
	for i in range(n - 1):
		k.append(l[i] * l[i + 1])
	print(max(k))


for _ in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	max_product = None
	for i in range(n - 1):
		if max_product is None:
			max_product = nums[i] * nums[i + 1]
		elif max_product < nums[i] * nums[i + 1]:
			max_product = nums[i] * nums[i + 1]
	print(max_product)


import sys
input = sys.stdin.readline
t = int(input())
maxProd = 1
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	for i in range(n - 1):
		if (temp := (a[i] * a[i + 1])) > maxProd:
			maxProd = temp
	sys.stdout.write(str(maxProd) + '\n')
	maxProd = 1


t = int(input())
for test in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	max_here = max(arr[0], arr[1])
	min_here = min(arr[0], arr[1])
	mpe = max_here * min_here
	overall = mpe
	for i in range(1, n - 1):
		temp_max = max(arr[i], arr[i + 1])
		temp_min = min(arr[i], arr[i + 1])
		temp_prod = temp_max * temp_min
		min_here = min(min_here, temp_min)
		max_here = max(max_here, temp_max)
		mpe = max_here * min_here
		if mpe >= temp_prod:
			if overall < mpe:
				overall = mpe
		else:
			if overall < temp_prod:
				overall = temp_prod
			max_here = temp_max
			min_here = temp_min
	print(overall)


import sys
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, sys.stdin.readline().strip().split()))
	max_product = 0
	for pos in range(n):
		if pos == 0:
			if arr[pos] >= arr[pos + 1]:
				max_product = max(max_product, arr[pos] * arr[pos + 1])
		elif pos == n - 1:
			if arr[pos] >= arr[pos - 1]:
				max_product = max(max_product, arr[pos] * arr[pos - 1])
		elif arr[pos] >= arr[pos - 1] and arr[pos] >= arr[pos + 1]:
			max_product = max(max_product, arr[pos] * arr[pos - 1], arr[pos] * arr[pos + 1])
	print(max_product)


for _ in range(int(input())):
	n = int(input())
	nums = input().split()
	nums[0] = int(nums[0])
	maxx = 0
	for i in range(1, n):
		num = int(nums[i])
		nums[i] = num
		maxx = max(maxx, num * nums[i - 1])
	print(maxx)


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	max1 = 0
	for j in range(n - 1):
		if arr[j] * arr[j + 1] > max1:
			max1 = arr[j] * arr[j + 1]
	print(max1)


for u in range(int(input())):
	n = int(input())
	x = [int(w) for w in input().split()]
	idx = x.index(max(x))
	t = max(x)
	if n == 1:
		ans = x[0]
	elif n == 2:
		ans = x[0] * x[1]
	else:
		ans = max(x[0] * x[1], x[-1] * x[-2])
		for i in range(1, n - 1):
			temp = max(x[i - 1] * x[i], x[i] * x[i + 1])
			ans = max(ans, temp)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	que = list(map(int, input().split()))
	max = 0
	for i in range(1, n):
		if max < que[i] * que[i - 1]:
			max = que[i] * que[i - 1]
	print(max)


tests = int(input())
for i in range(tests):
	val_count = int(input())
	vals = list(map(int, input().split(' ')))
	if val_count == 2:
		print(vals[0] * vals[1])
		continue
	maxval = -1
	for i in range(val_count - 1):
		if i == 0:
			maxval = max(vals[i] * vals[i + 1], maxval)
		else:
			maxval = max(max(vals[i] * vals[i + 1], vals[i - 1] * vals[i]), maxval)
	print(maxval)
	maxval = -1


def solve():
	a = input()
	arr = list(map(int, input().split()))
	max_val = 0
	for i in range(len(arr) - 1):
		max_val = max(arr[i] * arr[i + 1], max_val)
	return max_val
for _ in range(int(input())):
	print(solve())


for t in range(1, int(input()) + 1):
	n = int(input())
	ls = list(map(int, input().split()))
	rm = 1
	for j in range(1, n):
		rm = max(max(ls[j - 1], ls[j]) * min(ls[j - 1], ls[j]), rm)
	print(rm)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = 1
	for x in range(n - 1):
		k = l[x] * l[x + 1]
		if k > c:
			c = k
	print(c)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections, itertools, statistics, math
from collections import *
from itertools import *
from statistics import *
from math import *
mod = int(1000000000.0 + 7)
imin = -2147483648
imax = 2147483647

def IO():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def kabraji_ka_totka():
	for i in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		res = 0
		for i in range(1, n):
			res = max(res, arr[i - 1] * arr[i])
		print(res)
kabraji_ka_totka()


t = int(input())

def sp():
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for i in range(n - 1):
		l.append(a[i] * a[i + 1])
	print(max(l))
for i in range(t):
	sp()


T = int(input())
for testcase in range(1, T + 1):
	n = int(input())
	a = list(map(int, input().split()))
	best = -1
	for i in range(n - 1):
		this = a[i] * a[i + 1]
		if this > best:
			best = this
	print(best)


t = int(input())

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans = max(ans, arr[i] * arr[i + 1])
	print(ans)
for i in range(t):
	solve()


from sys import stdin
input = stdin.readline

def findCherry(ln, nums):
	maxProd = 0
	currentMin = 0
	for i in range(1, len(nums)):
		maxProd = max(nums[i] * nums[i - 1], maxProd)
	return maxProd

def processNums():
	n = int(input())
	for _ in range(n):
		ln = int(input())
		nums = list(map(int, input().split()))
		print(findCherry(ln, nums))
processNums()


for _ in range(0, int(input())):
	input()
	v = list(map(int, input().split()))
	x = max(zip(v, v[1:]), key=lambda x: x[0] * x[1])
	print(x[0] * x[1])


def sol(n):
	l = list(map(int, input().split()))
	return max((l[i - 1] * l[i] for i in range(1, n)))
for i in range(int(input())):
	j = int(input())
	print(sol(j))


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		ans = max(ans, max(ar[i], ar[i + 1]) * min(ar[i], ar[i + 1]))
	print(ans)


def Cherry(n, a):
	ans = a[0] * a[1]
	for i in range(1, n - 1):
		ans = max(ans, a[i] * a[i - 1], a[i] * a[i + 1])
	print(ans)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	Cherry(n, a)


for z in range(int(input())):
	n = int(input())
	m = input()
	a = list(map(int, m.split()))
	b = [0] * (n - 1)
	for _ in range(n - 1):
		b[_] = a[_] * a[_ + 1]
	print(max(b))


import math, sys, itertools
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
for t in [wtf[i:i + 2] for i in range(1, len(wtf), 2)]:
	n = int(t[0])
	A = list(map(int, t[1].split()))
	ans = []
	M = max(A)
	for i in range(n - 1):
		ans.append(A[i] * A[i + 1])
	print(max(ans))