//#include "testlib.h"
//#include <spoj.h>

#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <assert.h>
#include <time.h>
#include <memory.h>
#include <set>
#include <numeric>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <unordered_map>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    int t, sumn = 0, n, x1, x2, x3, ok;
    cin >> t; assert(1 <= t && t <= 1e5);
    while (t --> 0) {
        cin >> n; assert(3 <= n && n <= 1e5);
        sumn += n; assert(sumn <= 5e5);
        ok = false;
        cin >> x1 >> x2; assert(1 <= x1 && x1 <= 1e5); assert(1 <= x2 && x2 <= 1e5);
        for(int i = 0; i < n-2; ++i) {
            cin >> x3; assert(1 <= x3 && x3 <= 1e5);
            ok |= (x1 == x2 && x2 == x3);
            x1 = x2; x2 = x3;
        }
        cout << (ok ? "Yes\n" : "No\n");
    }
    return 0;
}