#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long inf = 0x7fffffffffffffff;
const long long infneg = -0x7fffffffffffffff;
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    bool next = 0;
    for (int i = 0; i < n; i++) {
      if (next) break;
      for (int j = i + 1; j < n; j++) {
        if (next) break;
        if (arr[i] == arr[j] && (j - i) > 1) {
          cout << "YES\n";
          next = 1;
        }
      }
    }
    if (next) continue;
    cout << "NO\n";
  }
}
