#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n], flag = 0;
    for (int k = 0; k < n; k++) cin >> a[k];
    map<int, int> m;
    for (int i = 0; i < n; i++) {
      if (m[a[i]] == 1) {
        cout << "Yes" << endl;
        flag = 1;
        break;
      }
      m[a[i]]++;
      int c = 0;
      while (i < n - 1 && a[i] == a[i + 1]) {
        c++;
        i++;
      }
      if (c >= 2) {
        cout << "Yes" << endl;
        flag = 1;
        break;
      }
    }
    if (flag == 0) cout << "No" << endl;
  }
  return 0;
}
