#include <iostream>

class Node {
private:
	int data;
	Node* nextLeftNode;
	Node* nextRightNode;

public:
	Node() : data(NULL), nextLeftNode(nullptr), nextRightNode(nullptr) {};
	Node(const int& data) : data(data), nextLeftNode(nullptr), nextRightNode(nullptr) {};
	
	void insertNode(Node& newNode) {
		if (this->data == NULL) {
			this->data = newNode.data;
			return;
		}

		if (newNode.data <= data) {
			if (this->nextLeftNode == nullptr) {
				this->nextLeftNode = &newNode;
				return;
			}
			this->nextLeftNode->insertNode(newNode);
		}
		else {
			if (this->nextRightNode == nullptr) {
				this->nextRightNode = &newNode;
				return;
			}
			this->nextRightNode->insertNode(newNode);
		}
	}

	int findMinVal() {
		Node* tempNode = this;
		while (true) {
			if (nextLeftNode == NULL) {
				break;
			}
			else {
				tempNode = this->nextLeftNode;
			}
		}
		return this->data;
	}
};

int main() {
	int testCase, numberOfInput, val;
	std::cin >> testCase;
	for (int i = 0; i < testCase; ++i) {
		std::cin >> numberOfInput;
		Node node;
		for (int j = 0; j < numberOfInput; ++j) {
			std::cin >> val;
			Node newNode(val);
			node.insertNode(newNode);
		}
		std::cout << node.findMinVal() << '\n';
	}
}