Let $a$ and $b$ be two arrays of lengths $n$ and $m$, respectively, with no elements in common. We can define a new array $\mathrm{merge}(a,b)$ of length $n+m$ recursively as follows:  If one of the arrays is empty, the result is the other array. That is, $\mathrm{merge}(\emptyset,b)=b$ and $\mathrm{merge}(a,\emptyset)=a$. In particular, $\mathrm{merge}(\emptyset,\emptyset)=\emptyset$.  If both arrays are non-empty, and $a_1<b_1$, then $\mathrm{merge}(a,b)=[a_1]+\mathrm{merge}([a_2,\ldots,a_n],b)$. That is, we delete the first element $a_1$ of $a$, merge the remaining arrays, then add $a_1$ to the beginning of the result.  If both arrays are non-empty, and $a_1>b_1$, then $\mathrm{merge}(a,b)=[b_1]+\mathrm{merge}(a,[b_2,\ldots,b_m])$. That is, we delete the first element $b_1$ of $b$, merge the remaining arrays, then add $b_1$ to the beginning of the result. 

This algorithm has the nice property that if $a$ and $b$ are sorted, then $\mathrm{merge}(a,b)$ will also be sorted. For example, it is used as a subroutine in merge-sort. For this problem, however, we will consider the same procedure acting on non-sorted arrays as well. For example, if $a=[3,1]$ and $b=[2,4]$, then $\mathrm{merge}(a,b)=[2,3,1,4]$.

A permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the array) and $[1,3,4]$ is also not a permutation ($n=3$ but there is $4$ in the array).

There is a permutation $p$ of length $2n$. Determine if there exist two arrays $a$ and $b$, each of length $n$ and with no elements in common, so that $p=\mathrm{merge}(a,b)$.


-----Input-----

The first line contains a single integer $t$ ($1\le t\le 1000$)  — the number of test cases. Next $2t$ lines contain descriptions of test cases. 

The first line of each test case contains a single integer $n$ ($1\le n\le 2000$).

The second line of each test case contains $2n$ integers $p_1,\ldots,p_{2n}$ ($1\le p_i\le 2n$). It is guaranteed that $p$ is a permutation.

It is guaranteed that the sum of $n$ across all test cases does not exceed $2000$.


-----Output-----

For each test case, output "YES" if there exist arrays $a$, $b$, each of length $n$ and with no common elements, so that $p=\mathrm{merge}(a,b)$. Otherwise, output "NO".


-----Example-----
Input
6
2
2 3 1 4
2
3 1 2 4
4
3 2 6 1 5 7 8 4
3
1 2 3 4 5 6
4
6 1 3 7 4 5 8 2
6
4 3 2 5 1 11 9 12 8 6 10 7

Output
YES
NO
YES
YES
NO
NO



-----Note-----

In the first test case, $[2,3,1,4]=\mathrm{merge}([3,1],[2,4])$.

In the second test case, we can show that $[3,1,2,4]$ is not the merge of two arrays of length $2$.

In the third test case, $[3,2,6,1,5,7,8,4]=\mathrm{merge}([3,2,8,4],[6,1,5,7])$.

In the fourth test case, $[1,2,3,4,5,6]=\mathrm{merge}([1,3,6],[2,4,5])$, for example.

Difficulty: MEDIUM_HARD

Solutions:
T = int(input())
for t in range(T):
	n = 2 * int(input())
	a = reversed([int(x) for x in input().split()])
	f = [False] * (n + 1)
	v = []
	c = n
	l = 0
	for x in a:
		l = l + 1
		f[x] = True
		if x == c:
			v.append(l)
			l = 0
			while f[c] and c > 0:
				c = c - 1
	v.append(l)
	dp = [[]] * (n + 1)
	dp[0] = dp[v[0]] = True
	for x in v[1:]:
		for y in reversed(range(x, n + 1)):
			dp[y] = dp[y] or dp[y - x]
	print('YES' if dp[n // 2] else 'NO')


import time, math as mt, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

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

def IO():
	return stdin.readline()

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

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

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

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

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

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return
mod = 10 ** 9 + 7

def solve():
	n = II()
	cpy = n
	n = 2 * n
	p = L()
	i = n - 1
	(la, lb) = (0, 0)
	subset = []
	while i >= 0:
		mx = max(p[:i + 1])
		fnd = p.index(mx)
		if la < lb:
			la += n - fnd
			subset.append(n - fnd)
		else:
			lb += n - fnd
			subset.append(n - fnd)
		i = fnd - 1
		n = fnd
	ss = len(subset)
	n = cpy
	for ele in subset:
		if ele > n:
			print('NO')
			return
	dp = [[0 for i in range(2 * n + 1)] for i in range(ss)]
	dp[ss - 1][subset[ss - 1]] = 1
	for j in range(ss - 2, -1, -1):
		dp[j][subset[j]] = 1
		for k in range(2 * n + 1):
			if dp[j + 1][k] == 1:
				dp[j][subset[j] + k] = 1
				dp[j][k] = 1
	if dp[0][n] == 1:
		P('YES')
		return
	P('NO')
	return
t = II()
for i in range(t):
	solve()


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
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
avl = AvlTree()

class SegmentTree1:

	def __init__(self, data, default='z', 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 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

def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
for ik in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	cou = 1
	ans = []
	ma = l[0]
	for i in range(1, len(l)):
		if l[i] < ma:
			cou += 1
		else:
			ma = l[i]
			ans.append(cou)
			cou = 1
	ans.append(cou)
	if isSubsetSum(ans, len(ans), n) == True:
		print('YES')
	else:
		print('NO')


(c, r, t) = (input, range, int)
for _ in r(t(c())):
	(n, p, b) = (t(c()), [t(x) for x in c().split()], 1)
	f = r(1, n + n)
	for i in f:
		p[i] = max(p[i], p[i - 1])
	p = [0] + [i for i in f if p[i - 1] != p[i]] + [n + n]
	for i in r(1, len(p)):
		b |= b << p[i] - p[i - 1]
	print('YES' if b & 1 << n else 'NO')


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def output(*args):
	sys.stdout.buffer.write(('\n'.join(map(str, args)) + '\n').encode('utf-8'))

def main():
	t = int(input())
	ans_a = [''] * t
	for ti in range(t):
		n = int(input())
		a = tuple(map(int, input().split()))
		dp = [array('b', [0]) * (n + 1) for _ in range(2)]
		dp_next = [array('b', [0]) * (n + 1) for _ in range(2)]
		dp[0][0] = 1
		max_num = -1
		for i in range(2 * n):
			updated_max = max_num < a[i]
			max_num = max(max_num, a[i])
			for j in range(2):
				if j == 0 or updated_max:
					for k in range(n):
						dp_next[0][k + 1] |= dp[j][k]
				if j == 1 or updated_max:
					for k in range(n + 1):
						dp_next[1][k] |= dp[j][k]
			for j in range(2):
				for k in range(n + 1):
					dp[j][k] = dp_next[j][k]
					dp_next[j][k] = 0
		ans_a[ti] = 'YES' if dp[0][n] or dp[1][n] else 'NO'
	output(*ans_a)
main()


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def output(*args):
	sys.stdout.buffer.write(('\n'.join(map(str, args)) + '\n').encode('utf-8'))

def main():
	t = int(input())
	ans_a = ['NO'] * t
	for ti in range(t):
		n = int(input())
		a = tuple(map(int, input().split()))
		subset = []
		max_num = -1
		for x in a:
			if x > max_num:
				max_num = x
				subset.append(1)
			else:
				subset[-1] += 1
		dp = array('b', [0]) * (n + 1)
		dp[0] = 1
		for x in subset:
			for i in range(n, -1, -1):
				if dp[i] and i + x <= n:
					dp[i + x] = 1
		if dp[n]:
			ans_a[ti] = 'YES'
	output(*ans_a)
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	index = {e: i for (i, e) in enumerate(p)}
	m = 2 * n
	data = []
	for i in range(2 * n, 0, -1):
		temp = index[i]
		if temp < m:
			data.append(m - temp)
			m = temp
	m = len(data)
	dp = [[False for i in range(2 * n + 1)] for j in range(m + 1)]
	dp[0][0] = True
	for i in range(1, m + 1):
		for j in range(2 * n + 1):
			dp[i][j] = dp[i - 1][j] | dp[i - 1][j - data[i - 1]] & (j >= data[i - 1])
	if dp[m][n]:
		print('YES')
	else:
		print('NO')


t = int(input())
cnt = 0
while cnt < t:
	cnt += 1
	n = int(input())
	p = [int(i) for i in input().split()]
	lens = []
	mx = -1
	local_max = []
	for i in range(2 * n):
		if p[i] > mx:
			mx = p[i]
			local_max.append(i + 1)
	local_max.append(2 * n + 1)
	for i in range(1, len(local_max)):
		lens.append(local_max[i] - local_max[i - 1])
	lens.sort()
	m = len(lens)
	dp = [[0] * (n + 1) for i in range(m + 1)]
	for i in range(m + 1):
		dp[i][0] = 1
	for i in range(len(lens)):
		for j in range(1, n + 1):
			if j < lens[i]:
				dp[i + 1][j] = dp[i][j]
			else:
				dp[i + 1][j] = dp[i][j] | dp[i][j - lens[i]]
	print('YES' if dp[m][n] else 'NO')


def unmerge(arr):
	cnt = 1
	mx = arr[0]
	ls = []
	for i in range(1, len(arr)):
		if arr[i] > mx:
			ls.append(cnt)
			mx = arr[i]
			cnt = 1
		else:
			cnt += 1
	if cnt:
		ls.append(cnt)
	dp = 1
	for i in ls:
		dp |= dp << i
	if dp & 1 << len(arr) // 2:
		return 'YES'
	return 'NO'
for i in range(int(input())):
	a = input()
	lst = list(map(int, input().strip().split()))
	print(unmerge(lst))


t = int(input())
cases = []
for i in range(t):
	n = int(input())
	cases.append(input().strip().split())

def solve(case):
	case = case + [len(case) + 1]
	contigs = []
	L = 0
	m = int(case[0])
	for i in range(len(case)):
		pi = int(case[i])
		if pi > m:
			contigs.append(L)
			L = 0
			m = pi
		L += 1
	if isSubsetSum(contigs, len(contigs), (len(case) - 1) // 2):
		print('YES')
	else:
		print('NO')

def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
for case in cases:
	solve(case)


t = int(input())
for _ in range(t):
	l = int(input())
	m = list(map(int, input().split()))
	v = []
	while len(m) > 0:
		mx = 0
		ind = 0
		for i in range(len(m)):
			if m[i] > mx:
				mx = m[i]
				ind = i
		v.append(len(m) - ind)
		m = m[:ind]
	T = [[0 for _ in range(l + 1)] for _ in range(len(v) + 1)]
	T[0][0] = 1
	ok = 0
	for i in range(len(v)):
		for j in range(1, l + 1):
			if v[i] > j:
				T[i + 1][j] = T[i][j]
			elif T[i][j - v[i]] == 1 or T[i][j] == 1:
				T[i + 1][j] = 1
				if j == l:
					ok = 1
	if ok:
		print('YES')
	else:
		print('NO')


entrada = int(input())
for i in range(entrada):
	n = int(input())
	aux = list(map(int, input().split()))
	l = []
	contador = 1
	rmax = aux[0]
	for i in range(1, 2 * n):
		if aux[i] > rmax:
			rmax = aux[i]
			l.append(contador)
			contador = 1
		else:
			contador += 1
	if contador:
		l.append(contador)
	r = 1
	for i in l:
		r |= r << i
	if r & 1 << n:
		print('YES')
	else:
		print('NO')


import sys

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s)
	sys.stdout.write('\n')

def wi(n):
	sys.stdout.write(str(n))
	sys.stdout.write('\n')

def wia(a, sep=' '):
	sys.stdout.write(sep.join([str(x) for x in a]))
	sys.stdout.write('\n')

def solve(n, p):
	m = 2 * n
	a = []
	best = p[0]
	cnt = 1
	for i in range(1, m):
		if p[i] > best:
			a.append(cnt)
			best = p[i]
			cnt = 1
		else:
			cnt += 1
	if cnt > 0:
		a.append(cnt)
	dp = 1
	for ai in a:
		dp |= dp << ai
	return dp & 1 << n

def main():
	for _ in range(ri()):
		n = ri()
		p = ria()
		ws('YES' if solve(n, p) else 'NO')
main()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	lens = []
	prev = 0
	head = arr[0]
	for i in range(1, 2 * n):
		if arr[i] > head:
			lens.append(i - prev)
			prev = i
			head = arr[i]
	lens.append(2 * n - prev)
	dp = [[0] * (n + 1) for _ in range(len(lens) + 1)]
	dp[0][0] = 1
	for i in range(1, len(lens) + 1):
		for j in range(n - lens[i - 1], -1, -1):
			dp[i][j + lens[i - 1]] = dp[i - 1][j]
		for j in range(n):
			dp[i][j] = max(dp[i][j], dp[i - 1][j])
	if dp[-1][-1] == 1:
		print('YES')
	else:
		print('NO')


def solve(L):
	count = [0] * len(L)
	for i in range(len(L)):
		count[L[i] - 1] = i
	pL = []
	pt = len(L)
	for i in range(len(L) - 1, -1, -1):
		if pt > count[i]:
			pL.append(pt - count[i])
			pt = count[i]
	countL = [0] * 2001
	countL[0] = 1
	for i in pL:
		permL = []
		for j in range(len(countL)):
			if countL[j] and j + i < 2001:
				permL.append(i + j)
		for j in permL:
			countL[j] = 1
	return countL[len(L) // 2]
for i in ' ' * int(input()):
	n = input()
	print(['NO', 'YES'][solve(list(map(int, input().split())))])


t = int(input())
for tt in range(0, t):
	n = int(input())
	p = map(int, input().split())
	blocks = []
	mx = -1
	block = 0
	for x in p:
		if x > mx:
			if block > 0:
				blocks.append(block)
			block = 0
			mx = x
		block += 1
	if block > 0:
		blocks.append(block)
	can = [0] * (n + 1)
	can[0] = 1
	for x in blocks:
		if n - x >= 0:
			for i in range(n - x, -1, -1):
				if can[i]:
					can[i + x] = 1
	if can[n] == 1:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
from collections import *
for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	p.reverse()
	cnt = 0
	s = set()
	target = 2 * n
	l = []
	for i in range(2 * n):
		cnt += 1
		s.add(p[i])
		if p[i] == target:
			l.append(cnt)
			cnt = 0
			while target in s:
				target -= 1
	dp = [[False] * (n + 1) for _ in range(len(l) + 1)]
	dp[0][0] = True
	for i in range(len(l)):
		for j in range(n + 1):
			dp[i + 1][j] |= dp[i][j]
			if j + l[i] <= n:
				dp[i + 1][j + l[i]] |= dp[i][j]
	if dp[-1][n]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	b = []
	mx = 0
	for i in range(2 * n):
		if a[i] > mx:
			mx = a[i]
			b.append(i + 1)
	b.append(2 * n + 1)
	b = [j - i for (i, j) in zip(b[:-1], b[1:])]
	ans = [[0] * (n + 1) for _ in range(len(b))]
	b.sort()
	for i in range(len(b)):
		ans[i][0] = 1
	for i in range(1, n + 1):
		if i == b[0]:
			ans[0][i] = 1
	for i in range(1, len(b)):
		for j in range(1, n + 1):
			if b[i] <= j:
				if ans[i - 1][j - b[i]]:
					ans[i][j] = 1
			ans[i][j] = max(ans[i][j], ans[i - 1][j])
	print(['NO', 'YES'][ans[-1][-1]])


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	a = []
	end = 2 * n - 1
	while end >= 0:
		i = arr.index(max(arr[:end + 1]))
		a.append(end - i + 1)
		end = i - 1
	pos = [0] * (n + 1)
	pos[0] = 1
	for i in a:
		for j in range(n - i, -1, -1):
			if pos[j]:
				pos[i + j] = 1
	if pos[n]:
		print('YES')
	else:
		print('NO')
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')
for _ in range(int(input())):
	main()


from math import *
from collections import *
from random import *
from bisect import *
import sys
input = sys.stdin.readline
d = {'1': '0', '0': '1'}

def isSub(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	r = []
	c = 0
	ref = 2 * n
	fl = [0 for i in range(2 * n + 1)]
	for i in range(2 * n - 1, -1, -1):
		if a[i] == ref:
			c += 1
			fl[a[i]] = 1
			r.append(c)
			c = 0
			for j in range(2 * n, 0, -1):
				if fl[j] == 0:
					ref = j
					break
		else:
			fl[a[i]] = 1
			c += 1
	if c:
		r.append(c)
	if isSub(r, len(r), n) == True:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	arrayy = []
	curr = 1
	maax = a[0]
	for k in range(1, 2 * n):
		if a[k] < maax:
			curr += 1
		else:
			arrayy.append(curr)
			curr = 1
			maax = a[k]
	if curr != 1:
		arrayy.append(curr)
	dp = [[False for k in range(2 * n + 1)] for i in range(len(arrayy))]
	dp[-1][arrayy[-1]] = True
	dp[-1][0] = True
	for k in reversed(range(len(arrayy) - 1)):
		for kk in range(2 * n + 1):
			if kk:
				dp[k][kk] = dp[k + 1][kk] or (False if arrayy[k] > kk else dp[k + 1][kk - arrayy[k]])
			else:
				dp[k][kk] = True
	if dp[0][n]:
		print('YES')
	else:
		print('NO')


def psum(arr, t):
	poss = [0 for i in range(t + 1)]
	poss[0] = 1
	for i in arr:
		for j in range(t, -1, -1):
			if poss[j] == 1 and j + i <= t:
				poss[j + i] = 1
	return poss[t] == 1
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	posts = [0]
	mc = l[0]
	for j in range(1, 2 * n):
		if l[j] > mc:
			posts.append(j)
			mc = l[j]
	posts.append(2 * n)
	lengths = []
	for j in range(len(posts) - 1):
		lengths.append(posts[j + 1] - posts[j])
	if psum(lengths, n):
		print('YES')
	else:
		print('NO')


import sys
import math

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

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

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

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	n = II()
	a = LI()
	l = []
	count = 0
	temp = -1
	for i in range(2 * n):
		if a[i] > temp:
			l.append(count)
			count = 1
			temp = a[i]
		else:
			count += 1
	l.append(count)
	l.sort(reverse=True)
	dp = [0] * 4001
	dp[0] = 1
	for i in l:
		for j in range(2000, -1, -1):
			if dp[j] == 1:
				dp[i + j] = 1
	print('YES' if dp[n] == 1 else 'NO')


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')

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

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

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	for _ in range(N()):
		n = N()
		arr = RLL()
		rec = []
		for i in range(len(arr)):
			if i > 0 and rec[-1][0] > arr[i]:
				rec[-1][1] += 1
			else:
				rec.append([arr[i], 1])
		dp = [-1] * (n + 1)
		dp[0] = 0
		for (i, (_, v)) in enumerate(rec):
			for j in range(n, -1, -1):
				if j < v:
					break
				if dp[j - v] != -1:
					dp[j] = 1
		print('YES' if dp[-1] == 1 else 'NO')
main()


from math import inf, log2

class SegmentTree:

	def __init__(self, array, func=max):
		self.n = len(array)
		self.size = 2 ** (int(log2(self.n - 1)) + 1) if self.n != 1 else 1
		self.func = func
		self.default = 0 if self.func != min else inf
		self.data = [self.default] * (2 * self.size)
		self.process(array)

	def process(self, array):
		self.data[self.size:self.size + self.n] = array
		for i in range(self.size - 1, -1, -1):
			self.data[i] = self.func(self.data[2 * i], self.data[2 * i + 1])

	def query(self, alpha, omega):
		if alpha == omega:
			return self.data[alpha + self.size]
		res = self.default
		alpha += self.size
		omega += self.size + 1
		while alpha < omega:
			if alpha & 1:
				res = self.func(res, self.data[alpha])
				alpha += 1
			if omega & 1:
				omega -= 1
				res = self.func(res, self.data[omega])
			alpha >>= 1
			omega >>= 1
		return res

	def update(self, index, value):
		index += self.size
		self.data[index] = value
		index >>= 1
		while index:
			self.data[index] = self.func(self.data[2 * index], self.data[2 * index + 1])
			index >>= 1
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')
from math import gcd, ceil

def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

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

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

def invert(x):
	r = len(x)
	ans = ['0'] * r
	for i in range(r):
		if x[i] == '0':
			ans[i] = '1'
	return ''.join(ans)
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	st = SegmentTree(a, func=max)
	co = 0
	ans = []
	for i in range(len(a) - 1, -1, -1):
		co += 1
		if a[i] == st.query(0, i):
			ans += [co]
			co = 0
	print('YES' if isSubsetSum(ans, len(ans), n) else 'NO')


q = int(input())
for _ in range(q):
	n = int(input())
	dat = list(map(int, input().split()))
	buf = []
	prev = dat[0]
	cnt = 1
	for i in range(1, n * 2):
		if prev > dat[i]:
			cnt += 1
		else:
			buf.append(cnt)
			cnt = 1
			prev = dat[i]
	buf.append(cnt)
	dp = [None] * 20100
	for i in range(len(buf)):
		for j in range(2005, -1, -1):
			if dp[j] is None:
				continue
			dp[j + buf[i]] = True
		dp[buf[i]] = True
	if dp[n] is True:
		print('YES')
	else:
		print('NO')


def examA():
	T = I()
	for _ in range(T):
		(N, M) = LI()
		A = LI()
		B = LI()
		B = set(B)
		cur = -1
		for a in A:
			if a in B:
				cur = a
				break
		if cur == -1:
			print('NO')
			continue
		print('YES')
		print('1', cur)
	return

def examB():
	T = I()
	ans = []
	for _ in range(T):
		N = I()
		A = LI()
		cur = -1
		for i in range(N):
			if A[i] > 1:
				if i % 2 == 0:
					cur = 1
				else:
					cur = 0
				break
		if cur == -1:
			if N % 2 == 1:
				cur = 1
			else:
				cur = 0
		if cur == 0:
			print('Second')
		else:
			print('First')
	return

def examC():
	T = I()
	for _ in range(T):
		N = I()
		a = SI()
		b = SI()
		A = []
		B = []
		for i in a:
			A.append(int(i))
		for i in b:
			B.append(int(i))
		cur = []
		for l in range(N - 1, -1, -1):
			if A[l] == B[l]:
				continue
			if A[0] == B[l]:
				A[0] = 1 ^ A[0]
				cur.append(1)
			ne_A = []
			for i in A[:l + 1]:
				ne_A.append(1 ^ i)
			A = ne_A[::-1] + A[l + 1:]
			cur.append(l + 1)
		print(len(cur), ' '.join(map(str, cur)))
	return

def examD():
	T = I()
	for t in range(T):
		N = I() * 2
		P = LI()
		G = []
		now = 0
		now_max = P[0]
		for (i, p) in enumerate(P):
			if p > now_max:
				G.append(i - now)
				now = i
				now_max = p
		G.append(N - now)
		n = len(G)
		dp = [0 for _ in range(n + 1)]
		dp[0] = 1
		for i in range(n):
			cur = G[i]
			dp[i + 1] = dp[i] | dp[i] << cur
		if dp[-1] & 1 << N // 2:
			print('YES')
		else:
			print('NO')
	return

def examE():
	T = I()
	for t in range(T):
		(n, x, y) = LI()
		B = LI()
		print('YES')
	ans = 0
	print(ans)
	return

def examC2():
	T = I()
	for _ in range(T):
		N = I()
		a = SI()
		b = SI()
		A = []
		B = []
		for i in a:
			A.append(int(i))
		for i in b:
			B.append(int(i))
		cur = []
		rev = 0
		L = 0
		R = N - 1
		for l in range(N - 1, -1, -1):
			if rev == 0:
				if A[R] == B[l]:
					R -= 1
					continue
				if A[L] == B[l]:
					A[L] = 1 ^ A[L]
					cur.append(1)
				cur.append(l + 1)
				L += 1
			else:
				if A[L] != B[l]:
					L += 1
					continue
				if A[R] != B[l]:
					A[R] = 1 ^ A[R]
					cur.append(1)
				cur.append(l + 1)
				R -= 1
			rev ^= 1
		print(len(cur), ' '.join(map(str, cur)))
	return
from decimal import getcontext, Decimal as dec
import sys, bisect, heapq
from copy import deepcopy
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def I():
	return int(input())

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

def DI():
	return dec(input())

def LDI():
	return list(map(dec, sys.stdin.readline().split()))

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

def LS():
	return sys.stdin.readline().split()

def SI():
	return sys.stdin.readline().strip()
global mod, mod2, inf, alphabet, _ep
mod = 10 ** 9 + 7
mod2 = 998244353
inf = 10 ** 18
_ep = dec('0.000000000001')
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}
getcontext().prec = 28
sys.setrecursionlimit(2 * 10 ** 5)
examD()


from sys import stdin
from bisect import bisect_left as bl
from bisect import bisect_right as br
from itertools import islice

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

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

def intsput():
	return map(int, sinput())

class RangedList:

	def __init__(self, start, stop, val=0):
		self.shift = 0 - start
		self.start = start
		self.stop = stop
		self.list = [val] * (stop - start)

	def __setitem__(self, key, value):
		self.list[key + self.shift] = value

	def __getitem__(self, key):
		return self.list[key + self.shift]

	def __repr__(self):
		return str(self.list)

	def __iter__(self):
		return iter(self.list)

def dprint(*args, **kwargs):
	if debugging:
		print(*args, **kwargs)
debugging = 1
t = intput()
for _ in range(t):
	n = intput()
	m = 2 * n
	p = list(intsput())
	prefix = [p[0]]
	for i in range(1, m):
		prefix.append(prefix[-1])
		if p[i] > prefix[-1]:
			prefix[-1] = p[i]
	indexes = [0]
	for i in range(1, m):
		if p[i] > prefix[i - 1]:
			indexes.append(i)
	gaps = []
	for i in range(1, len(indexes)):
		gaps.append(indexes[i] - indexes[i - 1])
	gaps.append(m - indexes[-1])
	dp = set([0])
	gaps.sort()
	for gap in gaps:
		toadd = []
		for elem in dp:
			toadd.append(elem + gap)
		for elem in toadd:
			dp.add(elem)
	possible = n in dp
	if possible:
		print('YES')
	else:
		print('NO')


def main():
	n = int(input())
	p = [int(e) for e in input().split()]
	prev = 0
	items = []
	for i in range(1, 2 * n):
		if p[i] > p[prev]:
			items.append(i - prev)
			prev = i
	weights = {0}
	for item in items:
		new_weights = [weight + item for weight in weights if weight + item <= n]
		weights = weights.union(new_weights)
		if n in weights:
			print('YES')
			return
	print('NO')
for _ in range(int(input())):
	main()


import sys
input = sys.stdin.readline
t = int(input())
for ii in range(t):
	n = int(input())
	p = [int(i) for i in input().split() if i != '\n']
	prefmax = [1]
	maxa = p[0]
	for i in range(1, 2 * n):
		if p[i] > maxa:
			prefmax.append(1)
			maxa = p[i]
		else:
			prefmax[-1] += 1
	dp = [[False] * (n + 1) for _ in range(len(prefmax) + 1)]
	dp[0][0] = True
	for i in range(1, len(prefmax) + 1):
		for j in range(1, n + 1):
			if prefmax[i - 1] > j:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - prefmax[i - 1]]
	if dp[-1][-1]:
		print('YES')
	else:
		print('NO')


def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ind = []
	lens = []
	maxx = 0
	for i in range(2 * n):
		if a[i] > maxx:
			ind.append(i + 1)
			maxx = a[i]
	ind.append(2 * n + 1)
	for i in range(1, len(ind)):
		lens.append(ind[i] - ind[i - 1])
	flag = isSubsetSum(lens, len(lens), n)
	if flag == True:
		print('YES')
	else:
		print('NO')


import sys
import math
from decimal import *

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

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

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

def check(idx, k, l, n, dp):
	if idx >= len(l):
		return k == n
	if (idx, k) in dp:
		return dp[idx, k]
	ans = check(idx + 1, k, l, n, dp)
	if ans:
		dp[idx, k] = ans
		return ans
	ans = check(idx + 1, k + l[idx], l, n, dp)
	dp[idx, k] = ans
	return ans

def solve():
	tt = I()
	for ii in range(tt):
		n = I()
		l = IL()
		cnt = 0
		last = None
		ls = []
		for ll in l:
			if last == None:
				last = ll
				cnt = 1
			elif ll > last:
				ls.append((last, cnt))
				last = ll
				cnt = 1
			else:
				cnt += 1
		ls.append((last, cnt))
		c = [x for (_, x) in ls]
		dp = {}
		if check(0, 0, c, n, dp):
			print('YES')
		else:
			print('NO')
		pass
solve()


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque
import math

def main():
	for t in range(int(input())):
		n = int(input())
		p = list(map(int, input().split()))
		a = []
		ma = p[0]
		c = 0
		for i in range(2 * n):
			if p[i] > ma:
				a.append(c)
				ma = p[i]
				c = 0
			c += 1
		if c != 0:
			a.append(c)
		dp = [0] * (n + 1)
		dp[0] = 1
		for i in range(len(a)):
			for j in range(n, a[i] - 1, -1):
				dp[j] += dp[j - a[i]] != 0
			if dp[n]:
				break
		if dp[n]:
			print('YES')
		else:
			print('NO')
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')
main()


def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
a = int(input())
for i in range(a):
	s = int(input())
	z = list(map(int, input().split()))
	ans = []
	while len(z) >= 1:
		r = z.index(max(z))
		ans.append(len(z) - r)
		z = z[:r]
	if isSubsetSum(ans, len(ans), s):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	ma = 0
	l = []
	for i in range(n * 2):
		if ma < p[i]:
			l.append(i)
			ma = p[i]
	l.append(n * 2)
	m = len(l) - 1
	a = [0] * m
	for i in range(m):
		a[i] = l[i + 1] - l[i]
	dp = [0] * (m + 1)
	dp[0] = 1
	for i in range(m):
		dp[i + 1] = dp[i] | dp[i] << a[i]
	if dp[m] >> n & 1:
		print('YES')
	else:
		print('NO')


t = int(input())
dp = [False] * 2010
for _ in range(t):
	nh = int(input())
	xs = [int(x) for x in input().split(' ')]
	n = nh * 2
	ns = []
	valid = [True] * n
	cnt = 0
	while cnt < n:
		mx = 0
		for i in range(n):
			if valid[i] and xs[i] > mx:
				mx = xs[i]
		i = 0
		while True:
			if xs[i] == mx:
				break
			i += 1
		acc = 0
		while i < n:
			if valid[i]:
				valid[i] = False
				cnt += 1
				acc += 1
			i += 1
		ns.append(acc)
	ns.sort()
	for i in range(nh + 1):
		dp[i] = False
	dp[0] = True
	for x in ns:
		for j in range(nh - x, -1, -1):
			if dp[j]:
				dp[j + x] = True
	print('YES' if dp[nh] else 'NO')


t = int(input())
for s in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	add = 0
	(maxi, plus) = (0, 0)
	for i in range(2 * n):
		if a[i] < maxi:
			add += 1
		else:
			b.append(add)
			maxi = a[i]
			add = 1
			plus += 1
	if add > 1:
		b.append(add)
	visited1 = [1 for i in range(n + 1)]
	visited2 = [1 for i in range(n + 1)]
	temp = visited2[:]
	visited1[0] = 0
	for i in range(1, plus):
		for j in range(n + 1):
			if visited1[j] == 0:
				visited2[j] = 0
				if j + b[i] <= n:
					visited2[j + b[i]] = 0
		visited1 = visited2[:]
		visited2 = temp[:]
	if visited1[-1] == 0:
		print('YES')
	else:
		print('NO')


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

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

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

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

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

def SI():
	return sys.stdin.readline()[:-1]
for _ in range(II()):
	n = II()
	aa = LI()
	mx = aa[0]
	cnt = 1
	ln = []
	for a in aa[1:]:
		if a > mx:
			ln.append(cnt)
			cnt = 1
			mx = a
		else:
			cnt += 1
	ln.append(cnt)
	mask = (1 << n + 1) - 1
	cur = 1
	for l in ln:
		cur = (cur | cur << l) & mask
		if cur.bit_length() == n + 1:
			print('YES')
			break
	else:
		print('NO')


import collections
t1 = int(input())
for _ in range(t1):
	n = int(input())
	p = list(map(int, input().split()))
	desc = []
	counter = 1
	mx = p[0]
	for i in range(2 * n - 1):
		if mx > p[i + 1]:
			counter += 1
		else:
			desc.append(counter)
			counter = 1
			mx = p[i + 1]
	desc.append(counter)
	m = len(desc)
	dp = []
	for i in range(m + 1):
		dp.append([])
		for j in range(n + 1):
			dp[-1].append(0)
	dp[0][0] = 1
	for i in range(m):
		for j in range(n + 1):
			if dp[i][j] > 0:
				dp[i + 1][j] = 1
			if j + desc[i] > n:
				continue
			if dp[i][j] > 0:
				dp[i + 1][j + desc[i]] = 1
	if dp[m][n] == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	segments = []
	max_so_far = 0
	segment_len = 0
	for x in p:
		if x > max_so_far:
			if segment_len > 0:
				segments.append(segment_len)
			segment_len = 1
			max_so_far = x
		else:
			segment_len += 1
	if segment_len > 0:
		segments.append(segment_len)
	dp = [False] * (n + 1)
	dp[0] = True
	for segment_len in segments:
		for i in range(n, segment_len - 1, -1):
			if dp[i - segment_len]:
				dp[i] = True
	if dp[n]:
		print('YES')
	else:
		print('NO')


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')
for j in range(int(input())):
	n = int(input())
	vals = list(map(int, input().split()))
	maxsofar = vals[0]
	nums = 1
	numbers = []
	for s in range(1, 2 * n):
		if vals[s] < maxsofar:
			nums += 1
		else:
			numbers.append(nums)
			maxsofar = vals[s]
			nums = 1
	numbers.append(nums)
	possible = set([])
	for s in range(len(numbers)):
		numb = numbers[s]
		adds = [numb]
		for i in possible:
			adds.append(numb + i)
		for i in adds:
			possible.add(i)
	if n in possible:
		print('YES')
	else:
		print('NO')


import sys
import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

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

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

def print_list(l):
	print(' '.join(map(str, l)))
N = int(input())
for _ in range(N):
	n = int(input())
	p = read_list()
	ls = []
	las = 0
	for i in range(1, 2 * n):
		if p[i] > p[las]:
			ls.append(i - las)
			las = i
	now = 1
	for l in ls:
		now |= now << l
	if now & 1 << n:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def unmerge(arr, n):
	maximum = arr[0]
	clusters = {}
	for ele in arr:
		clusters[ele] = 0
	clusters[maximum] = 1
	for i in range(1, len(arr)):
		if arr[i] < maximum:
			clusters[maximum] += 1
		else:
			maximum = arr[i]
			clusters[maximum] += 1
	temp = list(clusters.values())
	val = []
	for ele in temp:
		if ele != 0:
			val.append(ele)
	if len(val) == 1:
		return 'NO'
	sumAr = [0 for i in range(n + 2)]
	if val[0] >= len(sumAr):
		return 'NO'
	sumAr[val[0]] = val[0]
	for i in range(1, len(val)):
		temp = sumAr[:]
		for j in range(len(sumAr)):
			if j - val[i] >= 0:
				if val[i] + sumAr[j - val[i]] == j:
					temp[j] = val[i] + sumAr[j - val[i]]
			else:
				temp[j] = sumAr[j]
		sumAr = temp[:]
		if n in sumAr:
			return 'YES'
	return 'NO'

def solution():
	n = int(input())
	arr = list(map(lambda x: int(x), input().split()))
	print(unmerge(arr, n))
t = int(input())
for i in range(0, t):
	solution()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ls = []
	cnt = 1
	mx = a[0]
	for i in range(1, 2 * n):
		if a[i] > mx:
			mx = a[i]
			ls.append(cnt)
			cnt = 1
		else:
			cnt += 1
	if cnt:
		ls.append(cnt)
	dp = 1
	for i in ls:
		dp |= dp << i
	if dp & 1 << n:
		print('YES')
	else:
		print('NO')


inp = int(input())
for i in range(inp):
	n = int(input())
	aux = list(map(int, input().split()))
	lista = []
	count = 1
	result_max = aux[0]
	for i in range(1, 2 * n):
		if aux[i] > result_max:
			result_max = aux[i]
			lista.append(count)
			count = 1
		else:
			count += 1
	if count:
		lista.append(count)
	resultado = 1
	for i in lista:
		resultado |= resultado << i
	if resultado & 1 << n:
		print('YES')
	else:
		print('NO')


size = int(input())
for _ in range(size):
	aux_1 = int(input())
	testes = list(map(int, input().split()))
	aux_2 = 1
	lista = []
	max_value = testes[0]
	for i in range(1, 2 * aux_1):
		if max_value < testes[i]:
			max_value = testes[i]
			lista.append(aux_2)
			aux_2 = 1
		else:
			aux_2 += 1
	saida = 1
	for i in lista:
		saida |= saida << i
	if saida & 1 << aux_1:
		print('YES')
	else:
		print('NO')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())

def solve(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
t = ip()
for _ in range(t):
	n = ip()
	nc = n
	n = n << 1
	arr = list(inp())
	idx = n - 1
	check = []
	while idx != 0:
		val = max(arr)
		c = 0
		for i in arr[::-1]:
			if i == val:
				c += 1
				break
			else:
				c += 1
		check.append(c)
		idx = arr.index(val)
		arr = arr[:idx]
	length = len(check)
	flag = solve(check, length, nc)
	if flag:
		print('YES')
	else:
		print('NO')


def twoPartsExistsDyn(arr, n):
	totalSum = 0
	for i in range(n):
		totalSum += arr[i]
	if totalSum % 2 != 0:
		return -1
	partsum = totalSum // 2
	partArr = [[-1] * (n + 1) for i in range(partsum + 1)]
	for i in range(n + 1):
		partArr[0][i] = 0
	for i in range(1, partsum + 1):
		for j in range(1, n + 1):
			partArr[i][j] = partArr[i][j - 1]
			if i >= arr[j - 1]:
				if partArr[i][j] == partArr[i - arr[j - 1]][j - 1] and partArr[i][j] == -1:
					pass
				else:
					partArr[i][j] = 0
	return partArr[partsum][n]
t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	j = 2 * n - 1
	currmax = 2 * n
	d = dict()
	a = 0
	b = 0
	f = 0
	prev = 2 * n
	c = []
	while j >= 0:
		if p[j] == currmax:
			c.append(prev - j)
			d[currmax] = 1
			q = currmax - 1
			while q >= 1:
				if q not in d.keys():
					currmax = q
					break
				q += -1
			prev = j
		else:
			d[p[j]] = 1
		j += -1
	f = twoPartsExistsDyn(c, len(c))
	if f == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	list_temp = []
	count = 1
	max_num = arr[0]
	for i in range(1, 2 * n):
		if arr[i] > max_num:
			max_num = arr[i]
			list_temp.append(count)
			count = 1
		else:
			count += 1
	if count:
		list_temp.append(count)
	dp = 1
	for i in list_temp:
		dp |= dp << i
	if dp & 1 << n:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def subsum(arr, s):
	n = len(arr)
	dp = [[False for _ in range(s + 1)] for _ in range(n + 1)]
	for i in range(n + 1):
		dp[i][0] = True
	for i in range(1, n + 1):
		for j in range(1, s + 1):
			if arr[i - 1] <= j:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - arr[i - 1]]
			else:
				dp[i][j] = dp[i - 1][j]
	return dp[n][s]
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	idx = 2 * n
	lens = []
	while idx:
		m = 0
		for i in range(idx):
			if a[i] > a[m]:
				m = i
		lens.append(idx - m)
		idx = m
	if subsum(lens, n):
		print('YES')
	else:
		print('NO')


def summ(a, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < a[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= a[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - a[i - 1]]
	return subset[n][sum]
t = int(input())
for _ in range(t):
	n = int(input())
	out = []
	a = [int(i) for i in input().split()]
	l = 1
	maxi = a[0]
	for i in range(1, 2 * n):
		if maxi > a[i]:
			l += 1
		else:
			out.append(l)
			maxi = a[i]
			l = 1
	out.append(l)
	if summ(out, len(out), n):
		print('YES')
	else:
		print('NO')


from copy import copy

class Solution:

	@staticmethod
	def input():
		n = int(input())
		arr = input()
		return (n, arr)

	def __init__(self, n=None, arr=None):
		if n is None:
			(n, arr) = Solution.input()
		self.n = n
		self.arr = [int(x) for x in arr.split()]
		self.blocks = []

	def split_to_blocks(self):
		blocks = []
		curr_block_len = 1
		lbound = self.arr[0]
		for x in self.arr[1:]:
			if x <= lbound:
				curr_block_len += 1
			if x > lbound:
				blocks.append(curr_block_len)
				curr_block_len = 1
			lbound = max(x, lbound)
		self.blocks = blocks

	def knapsack(self):
		achievable_arr_lens = {0}
		for block_len in self.blocks:
			new_arr_lens = copy(achievable_arr_lens)
			for prev_len in achievable_arr_lens:
				new_arr_lens.add(block_len + prev_len)
			achievable_arr_lens = new_arr_lens
			if self.n in achievable_arr_lens:
				return True
		return False

	def solve(self):
		self.split_to_blocks()
		if self.knapsack():
			print('YES')
			return True
		else:
			print('NO')
			return False
for _ in range(int(input())):
	Solution().solve()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input()) * 2
	p = list(map(int, input().split()))
	li = []
	mx = n
	seen = set()
	cnt = 1
	for i in range(n - 1, -1, -1):
		seen.add(p[i])
		if p[i] == mx:
			li.append(cnt)
			while mx in seen:
				mx -= 1
			cnt = 1
		else:
			cnt += 1
	dp = set([0])
	for i in li:
		newdp = dp.copy()
		for j in dp:
			newdp.add(i + j)
		dp = newdp
	if n // 2 in dp:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	que = []
	while a:
		maxindex = 0
		for i in range(len(a)):
			if a[i] > a[maxindex]:
				maxindex = i
		poped = len(a) - maxindex
		que.append(poped)
		for i in range(poped):
			a.pop()
	assert sum(que) == 2 * n
	L = len(que)
	dp = [[0] * (2 * n + 1) for i in range(L + 1)]
	dp[0][0] = 1
	for (i, v) in enumerate(que):
		for j in range(2 * n + 1):
			if j < v:
				dp[i + 1][j] = dp[i][j]
			else:
				dp[i + 1][j] = max(dp[i][j], dp[i][j - v])
	result = dp[L][n]
	if result == 1:
		print('YES')
	else:
		print('NO')
	return

def main():
	t = int(input())
	for i in range(t):
		solve()
	return
main()


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')

def printDistSum(arr, n):
	Sum = sum(arr)
	dp = [[False for i in range(Sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		dp[i][0] = True
	for i in range(1, n + 1):
		dp[i][arr[i - 1]] = True
		for j in range(1, Sum + 1):
			if dp[i - 1][j] == True:
				dp[i][j] = True
				dp[i][j + arr[i - 1]] = True
	for j in range(Sum + 1):
		if dp[n][j] == True:
			sumlist.append(j)

def bs(A, key):
	left = 0
	right = len(A) - 1
	while left <= right:
		mid = (left + right) // 2
		if A[mid] == key:
			return 1
		elif A[mid] > key:
			right = mid - 1
		else:
			left = mid + 1
	return 0
for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	Q = A.copy()
	maxa = A[0]
	countlist = []
	count = 1
	for i in range(1, len(A)):
		if A[i] < maxa:
			count += 1
		else:
			maxa = A[i]
			countlist.append(count)
			count = 1
	countlist.append(count)
	sumlist = []
	printDistSum(countlist, len(countlist))
	if bs(sumlist, N):
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
T = int(input())

def subset_sum(blocks, n, target):
	subset = [[False for i in range(target + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, target + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, target + 1):
			if j < blocks[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= blocks[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - blocks[i - 1]]
	return subset[n][target]
for t in range(T):
	N = int(input())
	A = [int(_) for _ in input().split()]
	cm = -1
	c = 0
	blocks = []
	for el in A:
		if el > cm:
			if c:
				blocks.append(c)
				c = 0
			cm = el
		c += 1
	if c:
		blocks.append(c)
	if subset_sum(blocks, len(blocks), N):
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	p = list(map(int, input().split()))
	l = []
	j = 0
	for i in range(1, 2 * n):
		if j == i or p[j] > p[i]:
			if i != 2 * n - 1:
				continue
		else:
			l.append(i - j)
			j = i
		if i == 2 * n - 1:
			l.append(2 * n - j)
	m = [0] * n
	ln = len(l)
	for i in range(ln):
		for j in range(n - 1, -1, -1):
			if j + l[i] + 1 <= n and m[j]:
				m[j + l[i]] = 1
		if l[i] <= n:
			m[l[i] - 1] = 1
	if m[-1] == 1:
		print('YES')
	else:
		print('NO')


from sys import stdin
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
(t,) = gil()
for _ in range(t):
	(n,) = gil()
	arr = gil()
	getMaxIdx = [0] * n * 2
	prev = 0
	for i in range(1, 2 * n):
		if arr[i] > arr[prev]:
			prev = i
		getMaxIdx[i] = prev
	coins = []
	i = 2 * n - 1
	while i > 0:
		coins.append(i - getMaxIdx[i] + 1)
		i = getMaxIdx[i] - 1
	sums = [0] * (n + 1)
	sums[0] = 1
	temp = []
	for coin in coins:
		for i in range(n + 1):
			if sums[i] and i + coin <= n and (not sums[i + coin]):
				temp.append(i + coin)
		while len(temp):
			sums[temp.pop()] = 1
		if sums[-1]:
			break
	print('YES' if sums[-1] else 'NO')


import sys
import os, io
input = sys.stdin.readline

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

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

def print_list(l):
	print(' '.join(map(str, l)))
N = int(input())
for _ in range(N):
	n = int(input())
	p = read_list()
	ls = []
	las = 0
	for i in range(1, 2 * n):
		if p[i] > p[las]:
			ls.append(i - las)
			las = i
	now = {0}
	flag = False
	for l in ls:
		now = now.union([l + a for a in now if l + a <= n])
		if n in now:
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	d = {}
	for i in range(2 * n):
		d[arr[i]] = i
	P = sorted(list(d.keys()), reverse=True)
	ans = []
	pre = 2 * n
	for i in range(2 * n):
		if d[P[i]] <= pre:
			ans.append(pre - d[P[i]])
			pre = d[P[i]]
	s = sum(ans)
	if s % 2 != 0:
		print('NO')
	else:
		k = s // 2
		n = len(ans)
		part = [[True for i in range(n + 1)] for j in range(k + 1)]
		for i in range(1, k + 1):
			part[i][0] = False
		for i in range(1, k + 1):
			for j in range(1, n + 1):
				part[i][j] = part[i][j - 1]
				if i >= ans[j - 1]:
					part[i][j] = part[i][j] or part[i - ans[j - 1]][j - 1]
		if part[k][n] == True:
			print('YES')
		else:
			print('NO')


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

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

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

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

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

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

def nextGreaterEl(hm, el, n):
	for i in range(el + 1, n + 1):
		if not i in hm:
			return i

def Solution(arr, n):
	subsets = []
	i = 0
	n1 = 2 * n
	while i < n1:
		el = arr[i]
		length = 1
		i += 1
		while i < n1 and el > arr[i]:
			length += 1
			i += 1
		subsets.append(length)
	dp = [[0 for _ in range(n + 1)] for _ in range(len(subsets) + 1)]
	dp[0][0] = 1
	for i in range(1, len(subsets) + 1):
		dp[i][0] = 1
		for j in range(1, n + 1):
			dp[i][j] = dp[i - 1][j]
			if j >= subsets[i - 1]:
				dp[i][j] |= dp[i - 1][j - subsets[i - 1]]
	if dp[len(subsets)][n]:
		print('YES')
	else:
		print('NO')

def main():
	for _ in range(get_int()):
		n = get_int()
		arr = get_ints_in_list()
		Solution(arr, n)
main()


import sys
input = sys.stdin.readline
for nt in range(int(input())):
	n = int(input()) * 2
	a = list(map(int, input().split()))
	sub = []
	i = n - 1
	while i >= 0:
		m = max(a[0:i + 1])
		j = i
		sub.append([m])
		while a[j] != m:
			sub[-1].append(a[j])
			j -= 1
		i = j - 1
	new = []
	for i in sub:
		new.append(len(i))
	dp = [[0 for i in range(n + 1)] for j in range(len(new))]
	dp[0][new[0]] = 1
	for i in range(1, len(new)):
		dp[i][new[i]] = 1
		for j in range(n):
			if dp[i - 1][j - new[i]] or dp[i - 1][j]:
				dp[i][j] = 1
	if dp[-1][n // 2]:
		print('YES')
	else:
		print('NO')


import sys
from collections import defaultdict
mod = 10 ** 9 + 7
INF = float('inf')

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

def inpl():
	return list(map(int, sys.stdin.readline().split()))
t = inp()
for _ in range(t):
	n = inp()
	a = inpl()
	seen = set()
	b = []
	mx = 2 * n
	cnt = 0
	for i in range(2 * n)[::-1]:
		cnt += 1
		seen.add(a[i])
		if a[i] == mx:
			b.append(cnt)
			cnt = 0
			while True:
				mx -= 1
				if not mx in seen:
					break
	now = [False] * (2 * n + 1)
	now[0] = True
	for x in b:
		pre = now[:]
		now = [False] * (2 * n + 1)
		now[0] = True
		for i in range(n):
			if pre[i]:
				now[i] = True
				ind = min(x + i, 2 * n)
				now[ind] = True
	print('YES' if now[n] else 'NO')


from sys import stdin
input = stdin.readline
t = int(input())

def check(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split(' ')))
	lengths = []
	current = arr[0]
	length = 1
	for i in range(1, 2 * n):
		if arr[i] > current:
			lengths.append(length)
			current = arr[i]
			length = 1
		else:
			length += 1
	lengths.append(length)
	lengths = sorted(lengths)
	if check(lengths, len(lengths), n):
		print('YES')
	else:
		print('NO')


from collections import Counter
from itertools import combinations
import random

def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
		for i in range(1, sum + 1):
			subset[0][i] = False
		for i in range(1, n + 1):
			for j in range(1, sum + 1):
				if j < set[i - 1]:
					subset[i][j] = subset[i - 1][j]
				if j >= set[i - 1]:
					subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]

def func(n):
	n = list(map(int, n.split()))
	l = len(n)
	n2 = (max(n[:i]) for i in range(1, l + 1))
	group = list(Counter(n2).values())
	if max(group) > l // 2:
		return 'NO'
	n = l // 2
	m = len(group)
	dp = [[False for i in range(n + 1)] for j in range(m + 1)]
	for i in range(1, m + 1):
		dp[i][0] = True
	for i in range(1, m + 1):
		for j in range(1, n + 1):
			if group[i - 1] > j:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - group[i - 1]]
	if dp[m][n]:
		return 'YES'
	else:
		return 'NO'

def main():
	t = int(input())
	t_input = []
	for i in range(t):
		input()
		t_input.append(input())
	for i in list(map(func, t_input)):
		print(i)
main()


import heapq
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	h = []
	for x in s:
		h.append(-x)
	h.sort()
	dead = set()
	num = []
	count = 0
	for x in s[::-1]:
		count += 1
		if x == -h[0]:
			num.append(count)
			count = 0
		dead.add(x)
		while h != [] and -h[0] in dead:
			heapq.heappop(h)
	dp = [0] * (n + 1)
	dp[0] = 1
	for x in num:
		for i in range(n, -1, -1):
			if dp[i] == 1 and i + x <= n:
				dp[i + x] = 1
	if dp[n] == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = []
	i = 0
	while i < 2 * n:
		j = i
		while j + 1 < 2 * n and a[j + 1] < a[i]:
			j += 1
		c.append(j - i + 1)
		i = j + 1
	w = {0}
	for i in c:
		ws = set([i + j for j in w if i + j <= n])
		w = w.union(ws)
	if n in w:
		print('YES')
	else:
		print('NO')


def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	L = []
	base = arr[0]
	length = 1
	for i in range(1, 2 * n):
		if base > arr[i]:
			length += 1
		else:
			L.append(length)
			length = 1
			base = arr[i]
	L.append(length)
	print('YES' if isSubsetSum(L, len(L), n) else 'NO')


from sys import stdin
input = lambda : stdin.readline().strip()
lin = lambda : list(map(int, input().split()))
iin = lambda : int(input())
main = lambda : map(int, input().split())
from math import ceil, sqrt, factorial, log
from collections import deque
from bisect import bisect_left

def gcd(a, b):
	(a, b) = (max(a, b), min(a, b))
	while a % b != 0:
		(a, b) = (b, a % b)
	return b
mod = 998244353

def solve():
	n = iin()
	l = lin()
	z = []
	while l:
		t = l.index(max(l))
		z.append(len(l[t:]))
		l = l[:t]
	ans = 1
	for i in z:
		ans = ans | ans << i
	if ans & 1 << n:
		print('YES')
	else:
		print('NO')
qwe = 1
qwe = int(input())
for _ in range(qwe):
	solve()


from sys import stdin
input = stdin.readline

def getint():
	return int(input())

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

def getint1():
	return list(map(lambda x: int(x) - 1, input().split()))

def getstr():
	return input()[:-1]

def solve():
	n = getint()
	a = getints()
	ind = 0
	mx = a[0]
	lens = []
	for i in range(1, n * 2):
		if a[i] > mx:
			mx = a[i]
			lens.append(i - ind)
			ind = i
	lens.append(2 * n - ind)
	dp = [0] * (n + 1)
	dp[0] = 2
	for it in sorted(lens):
		dp = [2 if x == 1 else x for x in dp]
		for i in range(it, n + 1):
			if dp[i - it] == 2 and dp[i] == 0:
				dp[i] = 1
	print('YES' if dp[n] else 'NO')
for _ in range(getint()):
	solve()


import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def get_input(a=str):
	return a(input())

def get_int_input():
	return get_input(int)

def get_input_arr(a):
	return list(map(a, input().split()))

def get_int_input_arr():
	return get_input_arr(int)

def solve():
	t = get_int_input()
	for _ in range(t):
		n = get_int_input()
		arr = get_int_input_arr()
		subsets = []
		ptr = 2 * n - 1
		found = set()
		curr_mx = 2 * n
		while ptr > -1:
			this_sub = 0
			if curr_mx == 0:
				break
			while ptr > -1:
				found.add(arr[ptr])
				this_sub += 1
				ptr -= 1
				if arr[ptr + 1] == curr_mx:
					break
			found.add(curr_mx)
			if this_sub:
				subsets.append(this_sub)
			this_sub = 0
			while curr_mx:
				if curr_mx in found:
					curr_mx -= 1
				else:
					break
		subsets.sort()
		dp = [[False] * (2 * n + 1) for _ in range(len(subsets))]
		for i in range(len(subsets)):
			for j in range(2 * n + 1):
				if j == 0:
					dp[i][0] = True
				elif j < subsets[i]:
					dp[i][j] = dp[i - 1][j]
				elif j == subsets[i]:
					dp[i][j] = True
				else:
					dp[i][j] = dp[i - 1][j] or dp[i - 1][j - subsets[i]]
		if dp[len(subsets) - 1][n]:
			cout << 'YES' << endl
		else:
			cout << 'NO' << endl

def main():
	solve()
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [a[0]]
	c = [1]
	for i in range(1, 2 * n):
		if a[i] > b[-1]:
			b.append(a[i])
			c.append(1)
		else:
			c[-1] += 1
	m = len(c)
	dp = [[0 for _ in range(n + 1)] for _ in range(m + 1)]
	dp[0][0] = 1
	for i in range(1, m + 1):
		dp[i][0] = 1
	for i in range(1, m + 1):
		for j in range(1, n + 1):
			if j >= c[i - 1]:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - c[i - 1]]
			else:
				dp[i][j] = dp[i - 1][j]
	if dp[m][n]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [[a[0]]]
	x = a[0]
	c = []
	check = False
	for i in range(1, 2 * n):
		if not check:
			if a[i] < x:
				b[-1].append(a[i])
			else:
				c.append([a[i]])
				y = a[i]
				check = True
		elif a[i] < y:
			c[-1].append(a[i])
		else:
			b.append([a[i]])
			x = a[i]
			check = False
	d = [0] * (len(b) + len(c))
	for i in range(0, len(b) + len(c), 2):
		d[i] = len(b[i // 2])
	for i in range(1, len(b) + len(c), 2):
		d[i] = len(c[i // 2])
	d.sort()
	dp = [False] * (n + 1)
	dp[0] = True
	for i in d:
		for j in range(n, 0, -1):
			if j >= i and dp[j - i]:
				dp[j] = dp[j - i]
	if not dp[n]:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	ch1 = [s[0]]
	ch2 = [1]
	am = 1
	for i in range(1, 2 * n):
		if s[i] > ch1[-1]:
			ch1.append(s[i])
			ch2.append(1)
			am += 1
		else:
			ch2[-1] += 1
	dp = [[False for b in range(n + 1)] for j in range(am + 1)]
	dp[0][0] = True
	for i in range(1, am + 1):
		dp[i][0] = True
	for i in range(1, am + 1):
		for j in range(1, n + 1):
			if j >= ch2[i - 1]:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - ch2[i - 1]]
			else:
				dp[i][j] = dp[i - 1][j]
	if dp[am][n]:
		print('YES')
	else:
		print('NO')


t = int(input())
from collections import defaultdict

def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = 1
	y = l[0]
	l1 = []
	d = defaultdict(int)
	for j in range(1, 2 * n):
		if l[j] > y:
			l1.append(x)
			x = 1
			y = l[j]
		else:
			x += 1
	l1.append(2 * n - l.index(2 * n))
	if isSubsetSum(l1, len(l1), n):
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	d = []
	k = -1
	for i in range(len(a)):
		if len(d) == 0:
			k = a[i]
			d.append(k)
		else:
			if a[i] >= k:
				b.append(len(d))
				d = [a[i]]
				k = a[i]
			else:
				d.append(a[i])
			if i == len(a) - 1:
				b.append(len(d))
	d = []
	e = [0] * (n + 1)
	for i in range(len(b)):
		d.append(e[:])
	b.sort()
	for i in range(len(b)):
		for j in range(1, n + 1):
			if j < b[i]:
				d[i][j] = d[i - 1][j]
			else:
				d[i][j] = max(d[i - 1][j], b[i] + d[i - 1][j - b[i]])
	if d[len(b) - 1][n] == n:
		print('YES')
	else:
		print('NO')
	t -= 1


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
l = []
n = 0
l1 = []

def subsetfuckingsum():
	global l, n, l1
	s = [0] * (n + 5)
	s[0] = 1
	for j in l1:
		for i in range(n - j, -1, -1):
			if s[i]:
				s[i + j] = 1
	return 1 if s[n] else 0
for _ in range(val()):
	n = val()
	l = li()
	l1 = []
	visited = {}
	for i in range(2 * n):
		if i in visited:
			continue
		count = 0
		for j in range(i, 2 * n):
			if l[j] <= l[i] and j not in visited:
				count += 1
				visited[j] = 1
			elif l[j] > l[i]:
				break
		l1.append(count)
	print('YES' if subsetfuckingsum() else 'NO')


from sys import stdin

def subset_sum(A, n):
	DP = [[True] * (n + 1) for _ in range(len(A) + 1)]
	for i in range(1, n + 1):
		DP[0][i] = False
	for i in range(1, len(A) + 1):
		for j in range(1, n + 1):
			if A[i - 1] > j:
				DP[i][j] = DP[i - 1][j]
			else:
				DP[i][j] = DP[i - 1][j] or DP[i - 1][j - A[i - 1]]
	return DP[-1][-1]
t = int(stdin.readline().strip())
for _ in range(t):
	n = int(stdin.readline().strip())
	P = list(map(int, stdin.readline().strip().split(' ')))
	maximum = P[0]
	count = 1
	A = []
	for i in range(1, 2 * n):
		if P[i] > maximum:
			A.append(count)
			count = 1
			maximum = P[i]
		else:
			count += 1
	if count != 0:
		A.append(count)
	print('YES' if subset_sum(A, n) else 'NO')


import os
import sys
from io import BytesIO, IOBase
mod = 10 ** 9 + 7

def solve(arr, s):
	n = len(arr)
	dp = [[0 for _ in range(n + 1)] for _ in range(s + 1)]
	dp[0] = [1] * (n + 1)
	for r in range(1, s + 1):
		for c in range(1, n + 1):
			if arr[c - 1] <= r:
				dp[r][c] = dp[r][c - 1] or dp[r - arr[c - 1]][c - 1]
			else:
				dp[r][c] = dp[r][c - 1]
	return dp[s][n]

def main():
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		z = []
		l = 0
		r = 1
		while r < 2 * n:
			if arr[l] > arr[r]:
				r += 1
			else:
				z.append(r - l)
				l = r
				r += 1
		if solve(z, n):
			print('YES')
		else:
			print('NO')
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')
main()


T = int(input())
for _ in range(T):
	(n, p) = (int(input()), list(map(int, input().split())))
	(nm, cv, cc) = ([], 0, 0)
	for i in range(2 * n):
		if cv == 0:
			cv = p[i]
		cc += 1
		if i == 2 * n - 1 or p[i + 1] > cv:
			nm.append(cc)
			(cv, cc) = (0, 0)
	mem = [0] * (2 * n + 1)
	mem[0] = 1
	for u in nm:
		for i in range(2 * n, u - 1, -1):
			if mem[i - u]:
				mem[i] = 1
	print('YES' if mem[n] else 'NO')


def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
t = int(input())
for q in range(t):
	n = int(input())
	ch = input()
	L = [int(i) for i in ch.split()]
	A = []
	j = 2 * n
	for i in range(2 * n - 1, -1, -1):
		if L[i] == max(L[:j]):
			A.append(j - i)
			j = i
	l = len(A)
	if isSubsetSum(A, l, n) == True:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
import bisect
import math

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

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

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

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

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

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def gcd(a, b):
	while b:
		a = a % b
		(b, a) = (a, b)
	return a

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	n = inp()
	l = li()
	k = []
	x = l[0]
	cur = 1
	for i in range(1, 2 * n):
		if x < l[i]:
			k.append(cur)
			cur = 1
			x = l[i]
		else:
			cur += 1
	k.append(cur)
	dp = [[False for i in range(n + 1)] for i in range(len(k) + 1)]
	for i in range(len(k) + 1):
		dp[i][0] = True
	for i in range(1, len(k) + 1):
		for j in range(1, n + 1):
			if j < k[i - 1]:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - k[i - 1]]
	if dp[len(k)][n]:
		print('YES')
	else:
		print('NO')
for _ in range(inp()):
	solve()


for _ in range(int(input())):
	cut = int(input())
	l1 = list(map(int, input().split()))
	su = cut
	dp = []
	l = []
	cc = 1
	kk = 0
	for i in range(1, 2 * cut):
		if l1[i] < l1[kk]:
			cc += 1
		else:
			l.append(cc)
			kk = i
			cc = 1
	if sum(l) != 2 * cut:
		l.append(cc)
	n = len(l)
	for i in range(n + 1):
		l1 = []
		for j in range(su + 1):
			if i == 0 or j == 0:
				if i == 0 and j == 0:
					l1.append('T')
				elif i == 0:
					l1.append('F')
				else:
					l1.append('T')
			else:
				l1.append(0)
		dp.append(l1)
	for i in range(1, n + 1):
		for j in range(1, su + 1):
			if l[i - 1] <= j:
				if dp[i - 1][j - l[i - 1]] == 'T' or dp[i - 1][j] == 'T':
					dp[i][j] = 'T'
				else:
					dp[i][j] = 'F'
			elif dp[i - 1][j] == 'T':
				dp[i][j] = 'T'
			else:
				dp[i][j] = 'F'
	if dp[n][su] == 'T':
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.buffer.readline

def print(val):
	sys.stdout.write(val + '\n')

def prog():
	for _ in range(int(input())):
		n = int(input())
		p = list(map(int, input().split()))
		used = [0] * (2 * n + 1)
		blocks = []
		curr = 2 * n
		last = 2 * n - 1
		inblock = True
		for i in range(2 * n - 1, -1, -1):
			while used[curr]:
				curr -= 1
			if p[i] != curr:
				if inblock == False:
					last = i
					inblock = True
			elif inblock:
				inblock = False
				blocks.append(last - i + 1)
			else:
				blocks.append(1)
			used[p[i]] = True
		blocks = blocks[::-1]
		dp = [0] * (n + 1)
		dp[0] = 1
		for block in blocks:
			dpnew = [0] * (n + 1)
			for i in range(n + 1):
				if dp[i] == 1:
					dpnew[i] = 1
					if i + block <= n:
						dpnew[i + block] = 1
			dp = dpnew
		if dp[n]:
			print('YES')
		else:
			print('NO')
prog()


import io, os
from collections import deque
RL = lambda : list(map(int, input().split(' ')))

def isSubSetsum(arr, req):
	n = len(arr)
	dp = [[False for i in range(req + 1)] for j in range(n + 1)]
	for i in range(n + 1):
		dp[i][0] = True
	for i in range(1, n + 1):
		for j in range(1, req + 1):
			if arr[i - 1] > j:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - arr[i - 1]]
	return dp[n][req]
T = int(input())
for _ in range(T):
	n = int(input())
	l = RL()
	ind = []
	ma = l[0]
	cnt = 1
	for i in range(1, 2 * n):
		if l[i] > ma:
			ind.append(cnt)
			ma = l[i]
			cnt = 1
		else:
			cnt += 1
	ind.append(cnt)
	flag = 0
	if isSubSetsum(ind, n):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	(ind1, ind) = (2 * n, 2 * n)
	l1 = []
	while ind > 0:
		maxi = max(l[:ind])
		ind = l.index(maxi)
		l1.append(ind1 - ind)
		ind1 = ind
	dp = [[False for j in range(n + 1)] for i in range(len(l1))]
	for i in range(len(l1)):
		dp[i][0] = True
	for j in range(1, n + 1):
		dp[0][j] = False
	for i in range(len(l1)):
		for j in range(1, n + 1):
			if l1[i] > j:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] | dp[i - 1][j - l1[i]]
	if dp[len(l1) - 1][n]:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	si = []
	l = 0
	r = n * 2
	while r:
		ma = -1
		for i in range(r):
			ma = max(ma, ar[i])
		for j in range(r):
			if ar[j] == ma:
				break
		si.append(r - j)
		r = j
	su = {0}
	for i in si:
		tem = set({})
		for j in su:
			tem.add(j + i)
		su = su.union(tem)
	if n in su:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	cnt = 0
	max_ = 0
	ans = []
	for val in p:
		if max_ < val:
			if cnt == 0:
				pass
			else:
				ans.append(cnt)
			max_ = val
			cnt = 1
		else:
			cnt += 1
	ans.append(cnt)
	len_ans = len(ans)
	dp = [False] * (n + 1)
	dp[0] = True
	for i in range(len_ans):
		val = ans[i]
		for j in range(n)[::-1]:
			if j + 1 - val < 0:
				break
			dp[j + 1] |= dp[j + 1 - val]
	if dp[-1]:
		print('YES')
	else:
		print('NO')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		n = int(input())
		d = list(map(int, input().split()))
		interval = []
		end = 2 * n
		while end > 0:
			maxn = 0
			maxi = -1
			for i in range(0, end):
				if maxn < d[i]:
					maxn = d[i]
					maxi = i
			interval.append(end - maxi)
			end = maxi
		dp = [0 for i in range(n + 1)]
		dp[0] = 1
		for i in interval:
			for j in range(n - 1, -1, -1):
				if dp[j] == 1 and i + j <= n:
					dp[j + i] = 1
		if dp[n] == 1:
			yield 'YES'
		else:
			yield 'NO'
t = int(input())
ans = gift()
print(*ans, sep='\n')


import io
import os
from collections import deque
from functools import lru_cache
import sys
sys.setrecursionlimit(10 ** 5)
inf = float('inf')
DEBUG = False

def solve(N, P):
	chunks = []
	for x in P:
		if chunks and chunks[-1][0] > x:
			chunks[-1].append(x)
		else:
			chunks.append([x])
	A = [len(chunk) for chunk in chunks]
	possible = set([0])
	for x in A:
		nextPossible = set(possible)
		for y in possible:
			if x + y == N:
				return 'YES'
			if x + y < N:
				nextPossible.add(x + y)
		possible = nextPossible
	return 'NO'

def solveDP(N, P):
	assert len(P) == 2 * N

	@lru_cache(maxsize=None)
	def possible(a, b, aLen, bLen):
		if aLen > N or bLen > N:
			return False
		if aLen == N and bLen == N:
			return True
		i = 2 * N - 1 - aLen - bLen
		c = P[i]
		if c < a:
			if possible(a, c, aLen, bLen + 1):
				return True
		if c < b:
			if possible(c, b, aLen + 1, bLen):
				return True
		return False
	if possible(inf, inf, 0, 0):
		return 'YES'
	return 'NO'

def solveBFS(N, P):
	assert len(P) == 2 * N
	assert max(P) == 2 * N
	INF = 2 * N + 1

	def getNbr(node):
		(b, aLen, bLen) = node
		i = 2 * N - 1 - aLen - bLen
		a = P[i + 1] if aLen else INF
		c = P[i]
		if c < a and bLen < N:
			yield (a, bLen + 1, aLen)
		if c < b and aLen < N:
			yield (b, aLen + 1, bLen)
	source = (INF, 0, 0)
	q = deque([source])
	dist = {source: 0}
	while q:
		node = q.popleft()
		d = dist[node]
		for (b, aLen, bLen) in getNbr(node):
			if aLen == bLen == N:
				return 'YES'
			nbr = (b, aLen, bLen)
			if nbr not in dist:
				q.append(nbr)
				dist[nbr] = d + 1
	return 'NO'
if DEBUG:
	import random
	random.seed(0)
	T = 100
	for _ in range(T):
		N = 2000 // T
		P = list(range(1, 2 * N + 1))
		random.shuffle(P)
		assert solve(N, P) == solveBFS(N, P) == solveDP(N, P)
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N,) = [int(x) for x in input().split()]
	P = [int(x) for x in input().split()]
	ans = solve(N, P)
	print(ans)


import sys
input = lambda : sys.stdin.readline().rstrip('\n\r')
for _ in range(int(input())):
	n = int(input())
	P = list(map(int, input().split()))
	pos = {v: i for (i, v) in enumerate(P)}
	prev = 2 * n
	maxx = list(P)
	for i in range(1, 2 * n):
		maxx[i] = max(maxx[i - 1], P[i])
	lens = []
	for i in range(2 * n - 1, -1, -1):
		if P[i] == maxx[i]:
			lens.append(prev - i)
			prev = i
	DP = [False] * (n + 1)
	DP[0] = True
	for l in lens:
		for i in range(n - l, -1, -1):
			if DP[i]:
				DP[i + l] = True
	print('YES' if DP[n] else 'NO')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	lst1 = [[]] * (2 * n)
	lst = []
	c = 0
	k = 1
	for j in range(2 * n):
		if j == 0:
			c = a[j]
		elif a[j] < c:
			k += 1
		else:
			lst.append(k)
			k = 1
			c = a[j]
	lst.append(k)
	ar = [0] * (n + 1)
	for j in lst:
		for k in range(n, -1, -1):
			if (ar[k] == 1) & (j + k <= n):
				ar[j + k] = 1
		if j <= n:
			ar[j] = 1
	if ar[n] == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
l = []
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	a = []
	index = 0
	c = 0
	for i in range(2 * n - 1):
		if s[index] < s[i + 1]:
			a.append(i + 1 - index)
			index = i + 1
	m = {0}
	for item in a:
		nm = [w + item for w in m if w + item <= n]
		m = m.union(nm)
		if n in m:
			c = 1
			l.append('YES')
			break
	if c == 0:
		l.append('NO')
for i in l:
	print(i)


tests = int(input())
for t in range(tests):
	n = int(input())
	ls = list(map(int, input().split()))
	curr = ls[0]
	groups = []
	group_len = 1
	for item in ls[1:]:
		if curr > item:
			group_len += 1
		else:
			groups.append(group_len)
			group_len = 1
			curr = item
	groups.append(group_len)
	group_len = len(groups)
	dp = [None for i in range(group_len)]
	if groups[0] < n:
		dp[0] = [0, groups[0]]
	else:
		dp[0] = [0]
	for i in range(1, group_len):
		curr = groups[i]
		previous_ls = dp[i - 1]
		new = set(previous_ls)
		for prev in previous_ls:
			if prev + curr <= n:
				new.add(prev + curr)
		dp[i] = list(new)
	check = False
	for item in dp[group_len - 1]:
		if item == n:
			print('YES')
			check = True
			break
	if not check:
		print('NO')


import math
from sys import stdin, stdout

def isSubsetSum(arr, n, sum):
	subset = [[False for j in range(sum + 1)] for i in range(3)]
	for i in range(n + 1):
		for j in range(sum + 1):
			if j == 0:
				subset[i % 2][j] = True
			elif i == 0:
				subset[i % 2][j] = False
			elif arr[i - 1] <= j:
				subset[i % 2][j] = subset[(i + 1) % 2][j - arr[i - 1]] or subset[(i + 1) % 2][j]
			else:
				subset[i % 2][j] = subset[(i + 1) % 2][j]
	return subset[n % 2][sum]
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	j = 1
	c = 1
	i = 0
	while i < 2 * n and j < 2 * n:
		if l[i] > l[j]:
			j += 1
			c += 1
		else:
			ans.append(c)
			c = 1
			i = j
			j += 1
	ans.append(j - i)
	if isSubsetSum(ans, len(ans), n) == True:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(item) for item in input().split()]
	count = []
	while a:
		idx = a.index(max(a))
		count.append(len(a[idx:]))
		a = a[:idx]
	dp = 1
	for item in count:
		dp = dp | dp << item
	if dp & 1 << n:
		print('YES')
	else:
		print('NO')


w = int(input())
for o in range(w):
	n = int(input())
	A = list(map(int, input().split()))
	n += n
	dic = {}
	for i in range(n):
		dic[A[i]] = i
	dp = [A[0]] * n
	for i in range(1, n):
		if A[i] >= dp[i - 1]:
			dp[i] = A[i]
		else:
			dp[i] = dp[i - 1]
	dr = {n - 1: [(n // 2, n // 2)]}
	pt = n - 1
	result = False
	while pt >= 0:
		MAX = dp[pt]
		i = dic[MAX]
		length = pt - i + 1
		existing = dr[pt]
		temp = set()
		for (x, y) in existing:
			if x == 0 or y == 0:
				result = True
				break
			if x - length >= 0:
				temp.add(tuple(sorted((x - length, y))))
			if y - length >= 0:
				temp.add(tuple(sorted((y - length, x))))
		dr[i - 1] = temp
		pt = i - 1
		if result:
			break
	if result:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	ls = list(map(int, stdin.readline().split()))
	ar = [False] * (2 * n + 1)
	curr = 2 * n
	blocks = []
	f = 1
	for i in range(2 * n - 1, -1, -1):
		if ls[i] == curr:
			blocks.append(f)
			f = 1
			for j in range(curr - 1, -1, -1):
				if not ar[j]:
					curr = j
					break
		else:
			f += 1
		ar[ls[i]] = True
	dp = [False] * (n + 1)
	dp[0] = True
	for i in blocks:
		for j in range(n, 0, -1):
			if j - i >= 0:
				if dp[j - i]:
					dp[j] = True
	if dp[n]:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

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

def rl():
	return list(map(int, input().split()))
for _ in range(r()):
	n = r()
	a = rl()
	lens = []
	b = []
	maxi = -math.inf
	for i in range(2 * n):
		maxi = max(maxi, a[i])
		b.append(maxi)
	already = 0
	for j in range(2 * n - 1, -1, -1):
		if b[j] == a[j]:
			temp = 2 * n - j - already
			lens.append(temp)
			already += temp
	lens.sort()
	dp = [[False for j in range(n + 1)] for i in range(len(lens) + 1)]
	for i in range(len(lens) + 1):
		dp[i][0] = True
	for i in range(1, n + 1):
		dp[0][j] = False
	for i in range(1, len(lens) + 1):
		for j in range(1, n + 1):
			if lens[i - 1] > j:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - lens[i - 1]]
	if dp[len(lens)][n]:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	lista = list(map(int, input().split()))
	ls = []
	cnt = 1
	nmax = lista[0]
	for i in range(1, 2 * n):
		if lista[i] > nmax:
			nmax = lista[i]
			ls.append(cnt)
			cnt = 1
		else:
			cnt += 1
	if cnt:
		ls.append(cnt)
	dp = 1
	for i in ls:
		dp |= dp << i
	if dp & 1 << n:
		print('YES')
	else:
		print('NO')


def valid_sum(blocks, n):
	dp = [[False for x in range(n + 1)] for y in range(len(blocks) + 1)]
	dp[0][0] = True
	for i in range(len(blocks)):
		for j in range(n + 1):
			if j >= blocks[i]:
				dp[i + 1][j] = dp[i][j] or dp[i][j - blocks[i]]
			else:
				dp[i + 1][j] = dp[i][j]
	return dp[len(blocks)][n]
t = int(input().split()[0])
for case in range(t):
	n = int(input().split()[0])
	arr = list(map(int, input().split()))
	arr.reverse()
	maxes = set(arr)
	blocks = []
	curr = 0
	pt = 0
	while pt < 2 * n:
		if arr[pt] == max(maxes):
			blocks.append(pt - curr)
			curr = pt
		maxes.remove(arr[pt])
		pt += 1
	blocks[0] += 1
	if valid_sum(blocks, n) == True:
		print('YES')
	else:
		print('NO')


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = len(li) - 1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def mex(li):
	check = [0] * 1001
	for i in li:
		check[i] += 1
	for i in range(len(check)):
		if check[i] == 0:
			return i

def sumdigits(n):
	ans = 0
	while n != 0:
		ans += n % 10
		n //= 10
	return ans

def product(li):
	ans = 1
	for i in li:
		ans *= i
	return ans

def maxpower(n, k):
	cnt = 0
	while n > 1:
		cnt += 1
		n //= k
	return cnt
from math import *
from collections import deque
max_steps = 100005

def knapsack(li, sumi, s, n, dp):
	if s == sumi // 2:
		return 1
	elif n == 0:
		return 0
	elif dp[n][s] != -1:
		return dp[n][s]
	else:
		if li[n - 1] <= s:
			dp[n][s] = knapsack(li, sumi, s - li[n - 1], n - 1, dp) or knapsack(li, sumi, s, n - 1, dp)
		else:
			dp[n][s] = knapsack(li, sumi, s, n - 1, dp)
		return dp[n][s]
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = a[:]
	b.sort(reverse=True)
	last = 2 * n
	li = []
	for i in b:
		for j in range(2 * n):
			if a[j] == i:
				if last - j > 0:
					li.append(last - j)
					last = j
				break
	sumi = sum(li)
	n = len(li)
	dp = [[-1 for j in range(sumi + 1)] for i in range(n + 1)]
	if knapsack(li, sumi, sumi, n, dp):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	if arr == sorted(arr):
		print('YES')
		continue
	dl = []
	r = len(arr) - 1
	dp = [0] * (2 * n)
	dp[0] = arr[0]
	for j in range(1, 2 * n):
		dp[j] = max(dp[j - 1], arr[j])
	d = {}
	for j in range(2 * n - 1, -1, -1):
		d[dp[j]] = j
	max_inds = []
	for j in d:
		max_inds.append(d[j])
	for j in reversed(sorted(max_inds)):
		dl.append(r - j + 1)
		r = j - 1
	ans = 1
	groupSize = 12
	x = 10 ** groupSize
	A = sorted(dl)
	val = 1 + x ** A[0]
	ptr = 0
	for j in range(1, len(A)):
		if A[j] == A[ptr]:
			val += x ** (A[j] * (j - ptr + 1))
		else:
			ans *= val
			ptr = j
			val = 1 + x ** A[j]
	ans *= val
	for j in range(0, n):
		ans //= x
	if ans % x:
		print('YES')
	else:
		print('NO')


from collections import defaultdict

def arrinp():
	return [*map(int, input().split(' '))]

def intinp():
	return int(input())

def solution():
	n = intinp()
	p = arrinp()
	prev = 0
	items = [0]
	for i in range(1, 2 * n):
		if p[i] > p[prev]:
			items.append(i - prev)
			prev = i
	weights = {0}
	for item in items:
		new_weights = [weight + item for weight in weights if weight + item <= n]
		weights = weights.union(new_weights)
		if n in weights:
			print('YES')
			return
	print('NO')
testcases = 1
testcases = int(input())
for _ in range(testcases):
	solution()


for _ in range(int(input())):
	N = int(input())
	P = list(map(int, input().split()))
	blocks = []
	prev = P[0]
	prev_top = prev
	length = 0
	for x in P:
		if x > prev and x > prev_top:
			blocks.append(length)
			length = 1
			prev = prev_top = x
		else:
			length += 1
		prev = x
	blocks.append(length)
	can = [False] * (N * 2 + 1)
	can[0] = True
	for delta in blocks:
		for i in range(N - 1, -1, -1):
			if can[i]:
				can[i + delta] = True
	print('YES' if can[N] else 'NO')


from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	p = list(map(int, stdin.readline().split()))
	dp = [False] * (n + 1)
	dp[0] = True
	nmax = p[0]
	tmp = 0
	for i in range(2 * n):
		if p[i] <= nmax:
			tmp += 1
		else:
			for x in range(n, -1, -1):
				if dp[x] and x + tmp <= n:
					dp[x + tmp] = True
			nmax = p[i]
			tmp = 1
	for x in range(n, -1, -1):
		if dp[x] and x + tmp <= n:
			dp[x + tmp] = True
	if dp[n]:
		print('YES')
	else:
		print('NO')


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

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

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from fractions import Fraction
INF = float('inf')
mod = int(1000000000.0) + 7

def knapSack(W, wt, val, n):
	K = [[0 for x in range(W + 1)] for x in range(n + 1)]
	for i in range(n):
		if wt[i] <= W:
			K[i + 1][wt[i]] = 1
	for i in range(n + 1):
		for w in range(W + 1):
			if i == 0 or w == 0:
				K[i][w] = 0
			elif wt[i - 1] <= w:
				K[i][w] = max(K[i - 1][w - wt[i - 1]], K[i - 1][w], K[i][w])
			else:
				K[i][w] = max(K[i - 1][w], K[i][w])
	return K[n][W]
for t in range(int(data())):
	n = int(data())
	p = mdata()
	wt = []
	cnt = 1
	m = p[0]
	for i in range(1, 2 * n):
		if m > p[i]:
			cnt += 1
		else:
			wt.append(cnt)
			cnt = 1
			m = p[i]
	wt.append(cnt)
	val = [1] * len(wt)
	k = knapSack(n, wt, val, len(wt))
	if k:
		out('YES')
	else:
		out('NO')


from collections import deque
t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	u = [x + 1 for x in range(2 * n - 1)]
	if a == u:
		print('YES')
		t -= 1
		continue
	(count, m) = (1, a[0])
	b = deque()
	for x in range(1, 2 * n):
		if a[x] > m:
			m = a[x]
			b.append(count)
			count = 1
		else:
			count += 1
	b.append(count)
	b = list(b)
	f = 0
	weights = {0}
	for item in b:
		new_weights = [weight + item for weight in weights if weight + item <= n]
		weights = weights.union(new_weights)
		if n in weights:
			print('YES')
			t -= 1
			f = 1
			break
	if f:
		continue
	print('NO')
	t -= 1


import sys
import math
input = sys.stdin.readline
from functools import cmp_to_key

def pi():
	return int(input())

def pl():
	return int(input(), 16)

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

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

def invr():
	return map(int, input().split())
mod = 1000000007
f = []

def fact(n, m):
	global f
	f = [1 for i in range(n + 1)]
	f[0] = 1
	for i in range(1, n + 1):
		f[i] = f[i - 1] * i % m

def fast_mod_exp(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b = b >> 1
	return res

def inverseMod(n, m):
	return fast_mod_exp(n, m - 2, m)

def ncr(n, r, m):
	if r == 0:
		return 1
	return f[n] * inverseMod(f[n - r], m) % m * inverseMod(f[r], m) % m

def main():
	B()

def dfs(root, v, sub, parent):
	st = [root]
	while len(st) > 0:
		node = st.pop()
		for i in range(len(v[node])):
			if v[node][i] != node:
				st.append(v[node][i])

def D():
	try:
		t = pi()
		while t:
			t -= 1
			n = pi()
			v = [[] for i in range(n)]
			for i in range(n - 1):
				[x, y] = ti()
				v[x - 1].append(y - 1)
				v[y - 1].append(x - 1)
			m = pi()
			p = ti()
			e = [0 for i in range(n - 1)]
			sub = [0 for i in range(n)]
			dfs(0, v, sub, -1)
			for i in range(1, n):
				e[i - 1] = sub[i] * (n - sub[i])
			if len(p) < n - 1:
				while len(p) < n - 1:
					p.append(1)
			p = sorted(p)
			if len(p) > n - 1:
				x = 1
				for i in range(n - 2, len(p)):
					x = x * p[i]
				while len(p) > n - 2:
					p.pop()
				p.append(x)
			e = sorted(e)
			res = 0
			for i in range(n - 1):
				res = (res + p[i] * e[i]) % mod
			print(res)
	except:
		print(sys.exc_info())

def B():
	t = pi()
	while t:
		t -= 1
		(n, a) = (pi(), ti())
		idx = [0 for i in range(2 * n + 1)]
		for i in range(2 * n):
			idx[a[i]] = i
		p = 2 * n - 1
		s = []
		for i in range(2 * n, -1, -1):
			if idx[i] <= p:
				s.append(p - idx[i] + 1)
				p = idx[i] - 1
		dp = [[0 for j in range(len(s) + 1)] for i in range(n + 1)]
		dp[0][0] = 1
		for i in range(1, n + 1):
			for j in range(1, len(s) + 1):
				if i - s[j - 1] >= 0:
					dp[i][j] = 1 if dp[i][j - 1] or dp[i - s[j - 1]][j - 1] else 0
				else:
					dp[i][j] = dp[i][j - 1]
		print('YES' if dp[n][len(s)] == 1 else 'NO')
main()


from sys import stdin, stdout
import heapq
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	p = list(map(int, stdin.readline().split()))
	hp = []
	for i in range(2 * n):
		heapq.heappush(hp, (-p[i], i))
	s = set()
	s.add(0)
	idx = 2 * n
	yes = False
	while hp:
		(v, i) = heapq.heappop(hp)
		if i > idx:
			continue
		cnt = idx - i
		if n - cnt in s:
			yes = True
			break
		for l in list(s):
			s.add(l + cnt)
		idx = i
	if yes:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	cur = l[0]
	cll = 1
	blocks = []
	for x in l[1:]:
		if x > cur:
			blocks.append(cll)
			cur = x
			cll = 1
		else:
			cll += 1
	blocks.append(cll)
	poss = [[False] * (n + 1) for _ in range(len(blocks) + 1)]
	poss[0][0] = True
	for (i, b) in enumerate(blocks):
		for j in range(n + 1):
			poss[i + 1][j] = poss[i][j]
			if b <= j:
				poss[i + 1][j] |= poss[i][j - b]
	print('YES' if poss[len(blocks)][n] else 'NO')


import sys
import collections

def input():
	return sys.stdin.readline().rstrip()

def split_input():
	return [int(i) for i in input().split()]
tests = int(input())
for _ in range(tests):
	n = int(input())
	p = split_input()
	s = set()
	nextmax = 2 * n
	num = 0
	l = []
	for i in range(2 * n - 1, -1, -1):
		num += 1
		if p[i] == nextmax:
			l.append(num)
			num = 0
			s.add(p[i])
			nextmax -= 1
			while nextmax in s:
				nextmax -= 1
		else:
			s.add(p[i])
	dp = [[False for i in range(2 * n + 1)] for i in range(len(l))]
	dp[0][l[0]] = True
	for i in range(1, len(l)):
		for j in range(2 * n + 1):
			if l[i] > j:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - l[i]]
	if dp[len(l) - 1][n] == True:
		print('YES')
	else:
		print('NO')


from collections import *
from sys import *
input = stdin.readline

def findPartition(arr, n):
	sum = 0
	(i, j) = (0, 0)
	for i in range(n):
		sum += arr[i]
	if sum % 2 != 0:
		return false
	part = [[True for i in range(n + 1)] for j in range(sum // 2 + 1)]
	for i in range(0, n + 1):
		part[0][i] = True
	for i in range(1, sum // 2 + 1):
		part[i][0] = False
	for i in range(1, sum // 2 + 1):
		for j in range(1, n + 1):
			part[i][j] = part[i][j - 1]
			if i >= arr[j - 1]:
				part[i][j] = part[i][j] or part[i - arr[j - 1]][j - 1]
	return part[sum // 2][n]
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0]
	mx = a[0]
	for i in range(1, 2 * n):
		if a[i] > mx:
			mx = a[i]
			b.append(0)
		else:
			b.append(b[i - 1] + 1)
	arr = []
	ind = 0
	i = 1
	while i < 2 * n:
		if b[i] == 0:
			arr.append(i - ind)
			ind = i
		i += 1
	arr.append(i - ind)
	ch = findPartition(arr, len(arr))
	if ch != False:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')


def solution(sums, n):
	sums.sort()
	sum_check = [True] + [False] * n
	for sum in sums:
		old_sum_check = sum_check.copy()
		for (i, check) in enumerate(sum_check):
			if i >= sum and (not sum_check[i]):
				sum_check[i] = old_sum_check[i - sum]
		if sum_check[n]:
			return True
	return False

def main():
	n = int(input())
	c = list(map(int, input().split()))
	(l, r) = (0, 2 * n)
	sums = []
	while r != 0:
		sub_arr = c[l:r]
		id_max = max(range(len(sub_arr)), key=sub_arr.__getitem__)
		sums.append(r - id_max)
		r = id_max
	if solution(sums, n):
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	main()


from sys import stdin, setrecursionlimit, stdout
setrecursionlimit(100)
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
from heapq import heapify, heappop, heappush, heapreplace, heappushpop
from bisect import bisect_right, bisect_left

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

def fi():
	return float(stdin.readline())

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

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline().rstrip()

def lsi():
	return list(si())
mod = 1000000007
res = ['NO', 'YES']
test = 1
test_case = ii()
while test <= test_case:
	test += 1
	n = ii()
	nmbr = []
	mx = [0] * (n + n + 1)
	a = li()
	x = 1
	j = n + n
	for i in a[::-1]:
		mx[i] = 1
		if i == j:
			nmbr.append(x)
			x = 0
			while mx[j]:
				j -= 1
		x += 1
	nmbr.sort(reverse=True)
	for j in range(n + n):
		x = n
		for i in nmbr[j:]:
			if i <= x:
				x -= i
		if not x:
			break
	print(res[x == 0])


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	curm = p[0]
	cur = 1
	myparts = []
	for ele in p[1:]:
		if ele < curm:
			cur += 1
		else:
			curm = ele
			myparts.append(cur)
			cur = 1
	myparts.append(cur)
	poss = [0 for i in range(n + 1)]
	poss[0] = 1
	for ele in myparts:
		nextposs = list(poss)
		for i in range(n + 1 - ele):
			if poss[i]:
				nextposs[i + ele] = 1
		poss = nextposs
	if poss[n]:
		print('YES')
	else:
		print('NO')


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
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')

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

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

def N():
	return int(input())
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d

def GP(it):
	return [(ch, len(list(g))) for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

class Trie:

	def __init__(self, d):
		if d >= 0:
			self.left = Trie(d - 1)
		else:
			self.right = Trie(d - 1)
		self.c = 0

	def put(self, x, i):
		if i == -1:
			self.c = 1
			return
		if x & 1 << i:
			self.left.put(x, i - 1)
		else:
			self.right.put(x, i - 1)
t = N()
for i in range(t):
	n = N()
	p = RLL()
	cur = p[0]
	c = 1
	res = []
	for i in range(1, n * 2):
		if cur > p[i]:
			c += 1
		else:
			res.append(c)
			cur = p[i]
			c = 1
	res.append(c)
	k = len(res)
	dp = [0] * (n + 1)
	if res[0] <= n:
		dp[res[0]] = 1
	dp[0] = 1
	for i in range(1, k):
		for j in range(n, res[i] - 1, -1):
			dp[j] = dp[j] | dp[j - res[i]]
	ans = 'YES' if dp[n] else 'NO'
	print(ans)


entrada = int(input())
for i in range(entrada):
	num = int(input())
	aux = list(map(int, input().split()))
	lista = []
	cont = 1
	vmax = aux[0]
	for i in range(1, 2 * num):
		if aux[i] > vmax:
			vmax = aux[i]
			lista.append(cont)
			cont = 1
		else:
			cont += 1
	if cont:
		lista.append(cont)
	ret = 1
	for elem in lista:
		ret |= ret << elem
	if ret & 1 << num:
		print('YES')
	else:
		print('NO')


import sys

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	P = LIST()
	A = []
	j = 0
	for i in range(1, N * 2):
		if P[i] > P[j]:
			A.append(i - j)
			j = i
	A.append(N * 2 - j)
	M = len(A)
	dp = list2d(M + 1, N + 1, 0)
	dp[0][0] = 1
	for (i, a) in enumerate(A):
		for j in range(N + 1):
			if dp[i][j]:
				dp[i + 1][j] |= dp[i][j]
				if j + a <= N:
					dp[i + 1][j + a] |= dp[i][j]
	if dp[M][N]:
		YES()
	else:
		NO()


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n // i
	if n > 2:
		l.append(n)
	return l

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 sieve(n):
	prime = [True for i in range(n + 1)]
	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 digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
yn = ['NO', 'YES']
for _ in range(t):
	n = int(input())
	n += n
	vis = [0] * n
	l = [int(x) for x in input().split()]
	dpp = []
	curr = 0
	for ii in range(n):
		i = n - ii - 1
		if l[i] == max(l[0:i + 1]):
			curr += 1
			dpp.append(curr)
			curr = 0
		else:
			curr += 1
	l = dpp
	sum = n // 2
	n = len(dpp)
	dp = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		dp[i][0] = True
	for i in range(1, sum + 1):
		dp[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < l[i - 1]:
				dp[i][j] = dp[i - 1][j]
			if j >= l[i - 1]:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - l[i - 1]]
	if dp[n][sum]:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	mas = list(map(int, input().split()))
	ans = []
	et = mas[0]
	cnt = 0
	for num in mas:
		if num <= et:
			cnt += 1
		else:
			ans.append(cnt)
			cnt = 1
			et = num
	ans.append(cnt)
	dp = [0] * (n + 2)
	dp[0] = 1
	for num in ans:
		for i in range(n + 2):
			if dp[i] == 1 and i + num < n + 2:
				if dp[i + num] == 0:
					dp[i + num] = 2
		for i in range(n + 2):
			if dp[i] == 2:
				dp[i] = 1
	if dp[n] == 1:
		print('YES')
	else:
		print('NO')

def main():
	t = int(input())
	for i in range(t):
		solve()
main()


from sys import stdin, stdout
import math
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	s = set(a)
	segs = []
	while a:
		m = max(s)
		for i in range(len(a) - 1, -1, -1):
			s.remove(a[i])
			if a[i] == m:
				segs.append(len(a) - i)
				a = a[:i]
				break
	segs = sorted(segs, reverse=True)
	dp = {}

	def do(i, s):
		if (i, s) in dp:
			return dp[i, s]
		if i == len(segs):
			dp[i, s] = False
			return False
		if s == n:
			dp[i, s] = True
			return True
		if s > n:
			dp[i, s] = False
			return False
		dp[i, s] = do(i + 1, s + segs[i]) or do(i + 1, s)
		return dp[i, s]
	if do(0, 0):
		print('YES')
	else:
		print('NO')


import sys, os.path
from collections import deque
from fractions import Fraction as f

def IO():
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
		print = sys.stdout.write

def nextInt():
	return int(input())

def nextTuple():
	return [int(a) for a in input().split()]

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

def nextLine():
	return input()

def nextStringArray():
	return list(input().split())
IO()
t = nextInt()
for _ in range(t):
	sb = []
	n = nextInt()
	n = 2 * n
	p = nextArray()
	a = []
	b = []
	prev = 0
	peak = []
	for i in range(0, n):
		peak.append(i)
	count = 0
	prev = 0
	arr = []
	for i in range(1, len(peak)):
		if p[peak[i]] > p[prev]:
			arr.append(peak[i] - prev)
			prev = peak[i]
	arr.append(n - prev)
	dict = {0: 1}
	for i in range(len(arr)):
		l = list(dict.keys())
		for j in l:
			dict[j + arr[i]] = 1
	if dict.get(n // 2) is None:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	p = [int(x) for x in input().split()]
	segmentBreaks = []
	currMax = 0
	for i in range(2 * n):
		if p[i] > currMax:
			segmentBreaks.append(i)
			currMax = p[i]
	segmentBreaks.append(2 * n)
	segmentSizes = []
	for i in range(1, len(segmentBreaks)):
		segmentSizes.append(segmentBreaks[i] - segmentBreaks[i - 1])
	dp = [[False for _ in range(n + 1)] for __ in range(len(segmentSizes))]
	for j in range(len(segmentSizes)):
		for sz in range(n + 1):
			if sz == 0:
				dp[j][sz] = True
			if j == 0:
				if sz == segmentSizes[0]:
					dp[j][sz] = True
			else:
				if dp[j - 1][sz] == True:
					dp[j][sz] = True
				if sz - segmentSizes[j] >= 0 and dp[j - 1][sz - segmentSizes[j]] == True:
					dp[j][sz] = True
	if dp[len(segmentSizes) - 1][n]:
		print('YES')
	else:
		print('NO')


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
for __ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = 2 * n - 1
	s = []
	while x >= 0:
		m = max(a[:x + 1])
		index = a.index(m)
		s.append(x - index + 1)
		x = index - 1
	s.sort()
	dp = []
	for i in range(len(s) + 1):
		dp.append([0] * (n + 1))
	for i in range(1, len(s) + 1):
		for j in range(1, n + 1):
			if s[i - 1] == j:
				dp[i][j] = 1
			elif s[i - 1] > j:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] | dp[i - 1][j - s[i - 1]]
	if dp[-1][-1] == 1:
		print('YES')
	else:
		print('NO')


def dp(arr, n):
	sub = [[False for i in range(n + 1)] for i in range(len(arr) + 1)]
	for i in range(len(arr) + 1):
		sub[i][0] = True
	for i in range(1, len(arr) + 1):
		for j in range(1, n + 1):
			if j < arr[i - 1]:
				sub[i][j] = sub[i - 1][j]
			else:
				sub[i][j] = sub[i - 1][j] or sub[i - 1][j - arr[i - 1]]
	return sub[len(arr)][n]

def func(n, arr):
	s = set()
	l = n * 2
	end = n * 2
	sub = []
	for i in range(2 * n - 1, -1, -1):
		if arr[i] == l:
			sub.append(end - i)
			end = i
			l -= 1
			while True:
				if l not in s:
					break
				l -= 1
		else:
			s.add(arr[i])
	return dp(sub, n)
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if func(n, arr):
		print('YES')
	else:
		print('NO')


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

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

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(i) for i in st()]
l = []
n = 0
l1 = []

def subsetfuckingsum():
	global l, n, l1
	s = [0] * (n + 5)
	s[0] = 1
	for j in l1:
		for i in range(n - j, -1, -1):
			if s[i]:
				s[i + j] = 1
	return 1 if s[n] else 0
for _ in range(val()):
	n = val()
	l = li()
	l1 = []
	visited = {}
	for i in range(2 * n):
		if i in visited:
			continue
		count = 0
		for j in range(i, 2 * n):
			if l[j] <= l[i] and j not in visited:
				count += 1
				visited[j] = 1
			elif l[j] > l[i]:
				break
		l1.append(count)
	print('YES' if subsetfuckingsum() else 'NO')


from sys import stdin, stdout, setrecursionlimit
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log, log2
from random import seed, randint
from datetime import datetime
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
from collections import defaultdict as dd
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

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

def def_value():
	return 0

def def_inf():
	return inf
for _ in range(iinp()):
	n = 2 * iinp()
	c = lmp()
	c.append(inf)
	yy = []
	x = []
	mx = -1
	for i in range(n + 1):
		if mx < c[i]:
			yy.append(i + 1)
			mx = c[i]
	for i in range(len(yy) - 1, 0, -1):
		x.append(yy[i] - yy[i - 1])
	x.sort()
	xx = set()
	xx.add(x[0])
	ans = -1
	for i in range(1, len(x)):
		y = set()
		for j in xx:
			jj = j + x[i]
			y.add(j)
			y.add(jj)
			if j == n // 2 or jj == n // 2:
				ans = i + 1
				break
		if ans != -1:
			break
		else:
			xx = y
	if ans > 0:
		print('YES')
	else:
		print('NO')


def subset_sum(arr, n, sum):
	memo = [[False for _ in range(sum + 1)] for _ in range(n + 1)]
	for i in range(n + 1):
		memo[i][0] = True
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			memo[i][j] = memo[i - 1][j]
			if j >= arr[i - 1]:
				memo[i][j] = memo[i][j] or memo[i - 1][j - arr[i - 1]]
	return memo[n][sum]
T = int(input())
for _ in range(T):
	n = int(input())
	p = list(map(int, input().strip().split()))
	pieces = []
	curr_start = 0
	i = 1
	while i < 2 * n:
		if p[i] > p[curr_start]:
			pieces.append(i - curr_start)
			curr_start = i
		i += 1
	pieces.append(i - curr_start)
	if subset_sum(pieces, len(pieces), n):
		print('YES')
	else:
		print('NO')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
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 isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
for ik in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	cou = 1
	ans = []
	ma = l[0]
	for i in range(1, len(l)):
		if l[i] < ma:
			cou += 1
		else:
			ma = l[i]
			ans.append(cou)
			cou = 1
	ans.append(cou)
	if isSubsetSum(ans, len(ans), n) == True:
		print('YES')
	else:
		print('NO')


production = True
import sys, math, collections

def input(input_format=0, multi=0):
	if multi > 0:
		return [input(input_format) for i in range(multi)]
	else:
		next_line = sys.stdin.readline()[:-1]
		if input_format >= 10:
			use_list = False
			input_format = int(str(input_format)[-1])
		else:
			use_list = True
		if input_format == 0:
			formatted_input = [next_line]
		elif input_format == 1:
			formatted_input = list(map(int, next_line.split()))
		elif input_format == 2:
			formatted_input = list(map(float, next_line.split()))
		elif input_format == 3:
			formatted_input = list(next_line)
		elif input_format == 4:
			formatted_input = list(map(int, list(next_line)))
		elif input_format == 5:
			formatted_input = next_line.split()
		else:
			formatted_input = [next_line]
		return formatted_input if use_list else formatted_input[0]

def out(output_line, output_format=0, newline=True):
	formatted_output = ''
	if output_format == 0:
		formatted_output = str(output_line)
	elif output_format == 1:
		formatted_output = ' '.join(map(str, output_line))
	elif output_format == 2:
		formatted_output = '\n'.join(map(str, output_line))
	elif output_format == 3:
		formatted_output = ''.join(map(str, output_line))
	print(formatted_output, end='\n' if newline else '')

def log(*args):
	if not production:
		print('$$$', end='')
		print(*args)
enu = enumerate
ter = lambda a, b, c: b if a else c
ceil = lambda a, b: -(-a // b)
flip = lambda a: a + 1 & 1

def mapl(iterable, format=0):
	if format == 0:
		return list(map(int, iterable))
	elif format == 1:
		return list(map(str, iterable))
	elif format == 2:
		return list(map(list, iterable))

def solve():
	n = input(11)
	p = input(1)
	f = []
	s = []
	for i in p:
		if s:
			if i >= s[0]:
				f.append(len(s))
				s = [i]
				continue
		s.append(i)
	if s:
		f.append(len(s))
	dp = [[0] * (n + 1) for i in range(n + 1)]
	q = [(0, 0)]
	for i in f:
		y = iter(q.copy())
		q = []
		r = next(y, None)
		while r:
			k1 = (r[0], r[1] + i)
			k2 = (r[0] + i, r[1])
			for k in (k1, k2):
				if k[0] <= n and k[1] <= n:
					if not dp[k[0]][k[1]]:
						dp[k[0]][k[1]] = 1
						q.append(k)
			r = next(y, None)
		log(i, q)
	out(ter(dp[n][n], 'YES', 'NO'))
	return
for i in range(input(11)):
	solve()


import sys
import heapq
from collections import deque
from collections import defaultdict
I = lambda : list(map(int, input().split(' ')))

def subsetSum(arr, s):
	n = len(arr)
	dp = [[None for j in range(n + 1)] for i in range(s + 1)]
	for i in range(s + 1):
		dp[i][0] = False
	for j in range(n + 1):
		dp[0][j] = True
	for sum_ in range(1, s + 1):
		for num_ele in range(1, n + 1):
			dp[sum_][num_ele] = (dp[sum_ - arr[num_ele - 1]][num_ele - 1] if sum_ - arr[num_ele - 1] >= 0 else False) | dp[sum_][num_ele - 1]
	return dp[-1][-1]

def get_ind_max(lst):
	mm = max(lst)
	for i in range(len(lst)):
		if mm == lst[i]:
			return (len(lst) - i, lst[:i])
for _ in range(int(input())):
	n = int(input())
	lst = I()
	arr = []
	s = n
	while len(lst):
		(ll, lst) = get_ind_max(lst)
		arr.append(ll)
	s = n
	if subsetSum(arr, s):
		print('YES')
	else:
		print('NO')


import sys
import math
input = sys.stdin.readline

def sum_on_n(parts, n):
	can = set([0])
	for part in parts:
		to_add = set()
		for c in can:
			if c + part <= n and c + part not in can:
				to_add.add(c + part)
		can |= to_add
	return n in can
T = int(input())
for t in range(T):
	N = int(input())
	A = list(map(int, input().split(' ')))
	position = [None for i in range(2 * N)]
	for i in range(2 * N):
		A[i] -= 1
		position[A[i]] = i
	parts = []
	x = 2 * N - 1
	i = 2 * N - 1
	while i >= 0:
		while position[x] is None:
			x -= 1
		parts.append(i - position[x] + 1)
		new_i = position[x] - 1
		for j in range(position[x], i + 1):
			position[A[j]] = None
		i = new_i
		x -= 1
	can = sum_on_n(parts, N)
	print('YES' if can else 'NO')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(var, end='\n'):
	sys.stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]

def isSubsetSum(a, length, s):
	subset = [[False for i in range(s + 1)] for i in range(length + 1)]
	for i in range(length + 1):
		subset[i][0] = True
	for i in range(1, s + 1):
		subset[0][i] = False
	for i in range(1, length + 1):
		for j in range(1, s + 1):
			if j < a[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= a[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - a[i - 1]]
	return subset[length][s]
for _ in range(int(data())):
	n = int(data())
	arr = l()
	new = []
	cnt = 1
	high = arr[0]
	for i in range(1, 2 * n):
		if arr[i] > high:
			new.append(cnt)
			cnt = 1
			high = arr[i]
			continue
		cnt += 1
	new.append(cnt)
	out(('YES', 'NO')[not isSubsetSum(new, len(new), n)])


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	size = []
	cur = arr[0]
	temp = [cur]
	block = []
	for i in range(1, 2 * n):
		if cur > arr[i]:
			temp.append(arr[i])
		else:
			cur = arr[i]
			block.append(temp)
			temp = [cur]
	if temp != []:
		block.append(temp)
	for i in block:
		size.append(len(i))
	dp = [[False for i in range(n + 1)] for j in range(len(size) + 1)]
	for i in range(len(size) + 1):
		dp[i][0] = True
	for i in range(1, len(size) + 1):
		val = size[i - 1]
		for j in range(1, n + 1):
			if j < val:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] | dp[i - 1][j - val]
	if dp[len(size)][n] == True:
		print('YES')
	else:
		print('NO')


def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
import sys
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	counter = 2 * n
	subsets = []
	count = 0
	temp = []
	dict = {}
	for i in range(1, 2 * n + 1):
		dict[i] = 0
	for i in arr[::-1]:
		if i == counter:
			temp.append(i)
			dict[i] = 1
			for k in range(counter - 1, 0, -1):
				if dict[k] == 0:
					counter = k
					break
			temp = []
			subsets.append(count + 1)
			count = 0
		else:
			dict[i] = 1
			temp.append(i)
			count += 1
	if count:
		subsets.append(count)
	if isSubsetSum(subsets, len(subsets), n):
		print('YES')
	else:
		print('NO')


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	c = 1
	l = []
	prev = p[0]
	for j in range(1, 2 * n):
		if p[j] > prev:
			l.append(c)
			c = 1
			prev = p[j]
		else:
			c += 1
	l.append(c)
	dp = [[0] * (n + 1) for j in range(len(l) + 1)]
	dp[0][0] = 1
	flag = 0
	for k in range(1, len(l) + 1):
		for j in range(1, n + 1):
			dp[k][j] = dp[k - 1][j]
			if j - l[k - 1] >= 0:
				dp[k][j] += dp[k - 1][j - l[k - 1]]
			if dp[k][n]:
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	P = list(map(int, input().split()))
	MAX = -1
	L = []
	count = 0
	for p in P:
		if p > MAX:
			L.append(count)
			MAX = p
			count = 1
		else:
			count += 1
	L.append(count)
	DP = 1
	MAX = (1 << n + 1) - 1
	for i in L:
		DP = (DP | DP << i) & MAX
	if DP & 1 << n != 0:
		print('YES')
	else:
		print('NO')


def isSubsetSum(seet, n, sum):
	siz = sum
	dp = [[0 for i in range(siz + 1)] for i in range(n)]
	dp[0][0] = 1
	for i in range(len(seet)):
		if i == 0:
			dp[0][seet[i]] = 1
		else:
			m = dp[i - 1]
			for j in range(len(m)):
				if m[j] == 1:
					dp[i][j] = 1
					dp[i][j + seet[i]] = 1
	if dp[-1][siz // 2]:
		return 1
	else:
		return 0
a = int(input())
for i in range(a):
	s = int(input())
	z = list(map(int, input().split()))
	ans = []
	while len(z) >= 1:
		r = z.index(max(z))
		ans.append(len(z) - r)
		z = z[:r]
	if isSubsetSum(ans, len(ans), 2 * s):
		print('YES')
	else:
		print('NO')


import sys

def input():
	return sys.stdin.readline().rstrip()

def input_split():
	return [int(i) for i in input().split()]
testCases = int(input())
answers = []
for _ in range(testCases):
	n = int(input())
	perm = input_split()
	sets = []
	max_till_now = perm[0]
	current = [perm[0]]
	for i in range(1, 2 * n):
		if perm[i] < max_till_now:
			current.append(perm[i])
		else:
			sets.append(current)
			current = [perm[i]]
			max_till_now = perm[i]
	sets.append(current)
	groups = sets.copy()
	sets = [len(i) for i in sets]
	X = [[0 for j in range(n + 1)] for i in range(len(sets) + 1)]
	for i in range(len(sets) + 1):
		X[i][0] = 1
	for i in range(1, len(sets) + 1):
		for j in range(1, n + 1):
			if X[i - 1][j] == 1:
				X[i][j] = 1
			if j >= sets[i - 1]:
				if X[i - 1][j - sets[i - 1]] == 1:
					X[i][j] = 1
	if X[len(sets)][n] == 1:
		ans = 'YES'
	else:
		ans = 'NO'
	answers.append(ans)
print(*answers, sep='\n')


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
import time
from types import GeneratorType
BUFSIZE = 8192

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')
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	A = getInts()
	blocks = []
	ref = A[0]
	for i in range(2 * N):
		if i == 0:
			curr = 1
			continue
		if A[i] > ref:
			blocks.append(curr)
			ref = A[i]
			curr = 1
		else:
			curr += 1
		if i == 2 * N - 1:
			blocks.append(curr)
	possible_sums = set([0])
	for b in blocks:
		tmp = set()
		for p in possible_sums:
			tmp.add(b + p)
		for t in tmp:
			possible_sums.add(t)
	return 'YES' if N in possible_sums else 'NO'
for _ in range(getInt()):
	print(solve())


inp = lambda : map(int, input().split())
(t,) = inp()
for _ in range(t):
	(n,) = inp()
	a = list(inp())
	count = []
	temp = 1
	current = a[0]
	for i in range(1, 2 * n):
		if a[i] < current:
			temp += 1
			continue
		current = a[i]
		count.append(temp)
		temp = 1
	count.append(temp)
	dp = [[False] * (n + 1) for _ in range(len(count))]
	for i in range(len(count)):
		for j in range(n + 1):
			if j == count[i]:
				dp[i][j] = True
				continue
			if i != 0:
				dp[i][j] = dp[i - 1][j]
				if j >= count[i]:
					dp[i][j] |= dp[i - 1][j - count[i]]
	print(['NO', 'YES'][dp[len(count) - 1][n]])


def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	p = a[0]
	x = []
	q = 1
	for j in range(1, 2 * n):
		if a[j] > p:
			p = a[j]
			x.append(q)
			q = 1
		else:
			q += 1
	x.append(q)
	m = len(x)
	if isSubsetSum(x, m, n):
		print('YES')
	else:
		print('NO')


def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]

def find(ind):
	m = 0
	ans = -1
	for i in range(ind):
		if arr[i] > m:
			m = arr[i]
			ans = i
	return ans + 1
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ls = []
	t = find(2 * n)
	ls.append(len(arr) - t + 1)
	arr = arr[:t - 1]
	while t != 1:
		t = find(len(arr))
		ls.append(len(arr) - t + 1)
		arr = arr[:t - 1]
	if isSubsetSum(ls, len(ls), n) == True:
		print('YES')
	else:
		print('NO')


test = int(input())
k = 1
while k <= test:
	k += 1
	n = int(input())
	p = list(map(int, input().split()))
	a = []
	for i in p:
		a.append(i)
	a.sort(reverse=True)
	elem = []
	count = 0
	mark = 2 * n - 1
	flag = 0
	visit = [0 for i in range(2 * n + 1)]
	for j in range(2 * n - 1, -1, -1):
		if p[j] == a[count]:
			if j == 0:
				flag = 1
			elem.append(mark + 1 - j)
			mark = j - 1
			count += 1
			while count < len(a) and visit[a[count]] == 1:
				count += 1
		else:
			visit[p[j]] = 1
	if flag == 0:
		elem.append(mark + 1)
	dp = [[0 for i in range(n + 1)] for j in range(len(elem) + 1)]
	for i in range(len(elem) + 1):
		for j in range(n + 1):
			if j == 0:
				dp[i][j] = 1
			elif i == 0:
				dp[i][j] = 0
			elif elem[i - 1] <= j:
				if dp[i - 1][j] == 1 or dp[i - 1][j - elem[i - 1]] == 1:
					dp[i][j] = 1
			else:
				dp[i][j] = dp[i - 1][j]
	if dp[len(elem)][n] == 1:
		print('YES')
	else:
		print('NO')


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
from itertools import permutations

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

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

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for x in input().split()]

def fi():
	return int(input())

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

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

def gh():
	sys.stdout.flush()

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)

def bo(i):
	return ord(i) - ord('a')
t = fi()

def merge(a, b):
	i = ai = bi = 0
	g = []
	while i < 2 * n:
		if ai >= n:
			g.append(b[bi])
			bi += 1
		elif bi >= n:
			g.append(a[ai])
			ai += 1
		elif a[ai] < b[bi]:
			g.append(a[ai])
			ai += 1
		else:
			g.append(b[bi])
			bi += 1
		i += 1
	return g == ori

def check(a):
	m = len(a)
	dp = [[int(i == 0) for i in range(2 * n + 1)] for j in range(m + 1)]
	for i in range(m):
		if i == 0:
			dp[i][a[i]] = 1
		else:
			for j in range(2 * n):
				if j + a[i] > 2 * n:
					break
				dp[i][j + a[i]] |= dp[i - 1][j]
			for j in range(2 * n):
				dp[i][j] |= dp[i - 1][j]
	for i in range(m):
		if dp[i][n] == 1:
			return True
	return False

def rec(p, a, b, z):
	if p == 0:
		if merge(a, b):
			print(a, b)
			return 1
		return 0
	if len(a) < n:
		rec(p - 1, a + [ori[z]], b, z + 1)
	if len(b) < n:
		rec(p - 1, a, b + [ori[z]], z + 1)
	return False
while t > 0:
	t -= 1
	n = fi()
	a = li()
	ori = a
	flag = 0
	if len(set(a)) != 2 * n:
		print('NO')
		continue
	b = []
	i = 0
	while i < 2 * n:
		j = i + 1
		while j < 2 * n and a[i] > a[j]:
			j += 1
		b.append(j - i)
		i = j
	print('YES' if check(b) else 'NO')


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	ans = []
	i = 2 * n - 1
	while i >= 0:
		if p[i] == 2 * n:
			ans.append(2 * n - i)
			break
		i -= 1
	i -= 1
	while i >= 0:
		ind = i - p.index(max(p[:i + 1])) + 1
		ans.append(ind)
		i -= ind
	ans_len = len(ans)
	dp = [[False] * (n + 1) for i in range(ans_len + 1)]
	for i in range(ans_len + 1):
		dp[i][0] = True
	for i in range(n + 1):
		dp[0][i] = False
	for i in range(1, ans_len + 1):
		for j in range(1, n + 1):
			if ans[i - 1] > j:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - ans[i - 1]]
	if dp[-1][-1]:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	lst = []
	count = 1
	max = arr[0]
	for i in range(1, 2 * n):
		if arr[i] > max:
			max = arr[i]
			lst.append(count)
			count = 1
		else:
			count += 1
	if count:
		lst.append(count)
	dp = 1
	for i in lst:
		dp |= dp << i
	if dp & 1 << n:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	p = [int(i) for i in input().split()]
	blocks = []
	max = p[0]
	count = 1
	for i in range(1, 2 * n):
		if p[i] > max:
			max = p[i]
			blocks.append(count)
			count = 1
		else:
			count += 1
	if count:
		blocks.append(count)
	resultado = 1
	for i in blocks:
		resultado |= resultado << i
	if resultado & 1 << n:
		print('YES')
	else:
		print('NO')


from sys import *
input = stdin.readline
for _ in range(int(input())):
	n = 2 * int(input())
	target = n // 2
	l = list(map(int, input().split()))
	idxs = [-1 for i in range(2 * n + 1)]
	for i in range(n):
		idxs[l[i]] = i
	mAx = n
	discLen = []
	while n:
		curr = n - idxs[mAx]
		discLen.append(curr)
		n -= curr
		for i in range(mAx - 1, 0, -1):
			if idxs[i] < n:
				mAx = i
				break
	n = len(discLen)
	dp = [[False for i in range(target + 1)] for j in range(n + 1)]
	dp[0][0] = True
	for i in range(1, n + 1):
		for j in range(1, target + 1):
			if discLen[i - 1] > j:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - discLen[i - 1]]
	print('YES' if dp[-1][-1] else 'NO')


t = int(input())
for i in range(t):
	n = int(input())
	array1 = list(map(int, input().split()))
	lst = []
	cont = 1
	mx = array1[0]
	for j in range(1, 2 * n):
		if array1[j] > mx:
			mx = array1[j]
			lst.append(cont)
			cont = 1
		else:
			cont += 1
	if cont:
		lst.append(cont)
	dp = 1
	for k in lst:
		dp |= dp << k
	if dp & 1 << n:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	N = int(input())
	a = [int(x) for x in input().split(' ')]
	groups = []
	(i, j) = (0, 0)
	while i < len(a):
		while j < len(a) and a[j] <= a[i]:
			j += 1
		groups.append(j - i)
		i = j
	dp = [False for _ in range(2 * N + 1)]
	dp[0] = True
	for x in groups:
		for j in reversed(range(x, 2 * N + 1)):
			dp[j] |= dp[j - x]
	print('YES' if dp[N] else 'NO')


from sys import stdin

def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
for _ in range(int(input())):
	n = int(stdin.readline().rstrip())
	l = list(map(int, stdin.readline().rstrip().split(' ')))
	a = []
	d = {}
	for i in range(n * 2):
		d[l[i]] = i
	turn = 0
	end = 2 * n
	while True:
		ind = d[max(l[:end])]
		a.append(end - ind)
		end = ind
		if end == 0:
			break
	if isSubsetSum(a, len(a), n):
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		p = list(map(int, input().split()))
		m = p[0]
		l = 0
		peak = []
		runs = []
		for (index, i) in enumerate(p):
			m = max(m, i)
			peak.append(i == m)
			if i == m and index != 0:
				runs.append(l)
				l = 0
			l += 1
		runs.append(l)
		achievable = {0}
		for r in runs:
			for a in list(achievable):
				achievable.add(r + a)
		if n in achievable:
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	nums = [int(i) for i in input().split()]
	interval = []
	(pre, l) = (nums[0], 1)
	for i in range(1, 2 * n):
		if nums[i] < pre:
			l += 1
		else:
			interval.append(l)
			pre = nums[i]
			l = 1
	interval.append(l)
	memo = [False] * (n + 1)
	memo[0] = True
	for i in interval:
		for j in range(n, -1, -1):
			if memo[j] and j + i < n + 1:
				memo[j + i] = True
		if memo[n]:
			break
	if memo[n]:
		print('YES')
	else:
		print('NO')


def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
for x in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	k = 0
	l = 0
	z = 0
	a = []
	for i in range(2 * n):
		if m[i] > l:
			z = max(k, z)
			l = m[i]
			a.append(k)
			k = 0
		k += 1
	a.append(k)
	if z > n or k > n:
		print('NO')
	else:
		p = len(a)
		if isSubsetSum(a, p, n) == True:
			print('YES')
		else:
			print('NO')


def findMaxPos(A, start, end):
	pos = -1
	num = None
	for i in range(start, end + 1):
		if num is None:
			num = A[i]
			pos = i
		elif A[i] > num:
			num = A[i]
			pos = i
	return pos

def isSubsetSum(set, n, sum):
	subset = [[False for i in range(sum + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subset[i][0] = True
	for i in range(1, sum + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			if j < set[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= set[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - set[i - 1]]
	return subset[n][sum]
t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	L = list()
	i = 0
	j = 2 * n - 1
	while i <= j:
		pos = findMaxPos(A, i, j)
		L.append(j - pos + 1)
		j = pos - 1
	if isSubsetSum(L, len(L), n):
		print('YES')
	else:
		print('NO')


def max_element(arr, l, r):
	el = arr[l]
	ans = l
	for i in range(l, r + 1):
		if arr[i] > el:
			el = arr[i]
			ans = i
	return ans

def max_inds(arr, l, r):
	if l >= r:
		return [l]
	else:
		cur = max_element(arr, l, r)
		if cur == l:
			return [cur]
		else:
			return [cur] + max_inds(arr, l, cur - 1)
t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	if arr == sorted(arr):
		print('YES')
		continue
	dl = []
	r = len(arr) - 1
	for j in max_inds(arr, 0, r):
		dl.append(r - j + 1)
		r = j - 1
	ans = 1
	groupSize = 12
	x = 10 ** groupSize
	A = sorted(dl)
	val = 1 + x ** A[0]
	ptr = 0
	for j in range(1, len(A)):
		if A[j] == A[ptr]:
			val += x ** (A[j] * (j - ptr + 1))
		else:
			ans *= val
			ptr = j
			val = 1 + x ** A[j]
	ans *= val
	for j in range(0, n):
		ans //= x
	if ans % x:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, p) = (int(input()), list(map(int, input().split())))
	(v, w) = ([], [])
	(i, k) = (0, 0)
	while i < 2 * n:
		j = i + 1
		while j < 2 * n and p[j] < p[i]:
			j += 1
		v.append(j - i)
		w.append(j - i)
		k += 1
		i = j
	dp = [[0] * (n + 1) for _ in range(k + 1)]
	for i in range(1, k + 1):
		for j in range(1, n + 1):
			dp[i][j] = dp[i - 1][j]
			if j >= w[i - 1]:
				dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1])
	if dp[k][n] == n:
		print('YES')
	else:
		print('NO')


from functools import reduce
from typing import List

def canPartition(nums: List[int]) -> bool:
	(target, r) = divmod(sum(nums), 2)
	return r == 0 and reduce(lambda x, y: x << y | x, [1] + nums) >> target & 1
t = int(input())
for j in range(t):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	part_sum = []
	st = a[0]
	c = 1
	for i in range(1, len(a)):
		if a[i] < st:
			c += 1
		else:
			part_sum.append(c)
			c = 1
			st = a[i]
	part_sum.append(c)
	v = canPartition(part_sum)
	if v == 0:
		print('NO')
	else:
		print('YES')


def find(P):
	N = len(P)
	n = N // 2
	vals = []
	MAX = []
	temp = -1
	for i in range(len(P)):
		temp = max(temp, P[i])
		MAX += [temp]
	cur = 0
	for i in range(len(P) - 1, -1, -1):
		cur += 1
		if P[i] == MAX[i]:
			vals += [cur]
			cur = 0
	need = n
	dp = [[0 for j in range(n + 1)] for i in range(len(vals))]
	if vals[0] <= n:
		dp[0][vals[0]] = 1
	dp[0][0] = 1
	for i in range(1, len(vals)):
		dp[i][0] = 1
		val = vals[i]
		if val <= n:
			dp[i][val] = 1
		for j in range(1, n + 1):
			temp = j - val
			if temp < n and temp > 0:
				if dp[i - 1][temp] == 1:
					dp[i][j] = 1
			dp[i][j] = max(dp[i][j], dp[i - 1][j])
	if dp[-1][n] == 1:
		return 'YES'
	return 'NO'
ANS = []
for _ in range(int(input())):
	input()
	P = list(map(int, input().strip().split()))
	ANS += [find(P)]
print('\n'.join(ANS))