import java.io.*;
import java.util.*;

public class glade_pk_re {
	public static void main(String[] args) {
		new glade_pk_re().run();
	}

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	long[] aHash, bHash, st;
	long modulo;

	public long get(int l, int r, long[] hash) {
		long res;
		if (l > 0)
			res = hash[r] - hash[l - 1];
		else
			res = hash[r];
		while (res < 0)
			res += modulo;
		res *= st[hash.length - r + 1];
		res %= modulo;
		return res;
	}

	public void solve() throws IOException {
		modulo = 1000000;
		int n = nextInt();
		assert ((1 <= n) && (n <= 100000));
		int[] a = new int[2 * n];
		int[] b = new int[2 * n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
			assert ((0 <= a[i]) && (a[i] <= 1));
			a[i + n] = a[i];
			b[2 * n - i - 1] = a[i];
			b[n - i - 1] = a[i];
		}

		st = new long[2 * n + 1];
		st[0] = 1;
		for (int i = 1; i <= 2 * n; i++)
			st[i] = st[i - 1] * 2 % modulo;

		aHash = new long[2 * n];
		bHash = new long[2 * n];
		aHash[0] = a[0];
		bHash[0] = b[0];
		for (int i = 1; i < 2 * n; i++) {
			aHash[i] = (aHash[i - 1] + st[i] * a[i]) % modulo;
			bHash[i] = (bHash[i - 1] + st[i] * b[i]) % modulo;
		}

		for (int i = 0; i < n; i++) {
			if (n % 2 == 1) {
				if (get(i, i + n / 2 - 1, aHash) == get(n - i, n - i + n / 2
						- 1, bHash)) {
					out.println("Yes");
					return;
				}
			} else {
				if ((get(i, i + n / 2 - 1, aHash) == get(n - i, n - i + n / 2 - 1, bHash))||
						(get(i, i + n / 2 - 2, aHash) == get(n - i + 1, n - i + n / 2 - 1, bHash))) {
					out.println("Yes");
					return;
				}
			}
		}
		out.println("No");

	}

	public void run() {
		try {
			br = new BufferedReader(new FileReader("glade.in"));
			out = new PrintWriter("glade.out");
			// br = new BufferedReader(new InputStreamReader(System.in));
			// out = new PrintWriter(System.out);

			int T = nextInt();
			assert ((1 <= T) && (T <= 10));
			for (int i = 0; i < T; i++) {
				solve();
			}

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}