#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int mod = 998244353;
int tt, ans, A, n;
int main() {
  cin >> tt;
  while (tt) {
    cin >> n;
    vector<int> vec(n, 0);
    A = 200;
    vector<vector<int> > pref(A, vector<int>(n + 1));
    vector<vector<int> > pos(A);
    for (auto& it : vec) cin >> it;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < A; ++j) {
        pref[j][i + 1] = pref[j][i];
      }
      ++pref[vec[i] - 1][i + 1];
      pos[vec[i] - 1].push_back(i);
    }
    ans = 0;
    for (int i = 0; i < A; ++i) {
      ans = max(ans, (int)pos[i].size());
      for (int p = 0; p < pos[i].size() / 2; ++p) {
        int l = pos[i][p] + 1;
        int r = pos[i][pos[i].size() - p - 1] - 1;
        for (int k = 0; k < A; ++k) {
          int sum = pref[k][r + 1] - pref[k][l];
          ans = max(ans, (p + 1) * 2 + sum);
        }
      }
    }
    cout << ans << endl;
    tt--;
  }
  return 0;
}
