import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd def sol(): n = int(input()) a = [2] + list(map(int,input().split())) ok = 0 rl = [] for i in range(1,n+1): if a[i] != a[i-1]: rl.append(1) else: rl[-1] += 1 if len(rl) % 2 == 0 or max(rl) >= 2: print('Yes') else: print('No') return T = int(input()) for i in range(T): sol()