#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > pos;
vector<vector<int> > v;
int find_max(int l, int r) {
  l++;
  int ans = 0;
  if (l >= r) return ans;
  for (int i = 1; i <= 200; i++) {
    ans = max(ans, v[i][r] - v[i][l]);
  }
  return ans;
}
int main() {
  int t, n, x;
  cin >> t;
  while (t--) {
    cin >> n;
    int a[n];
    pos.clear();
    v.clear();
    pos.resize(201);
    v.resize(201);
    for (int j = 1; j <= 200; j++) v[j].resize(n + 1, 0);
    for (int i = 0; i < n; i++) {
      cin >> x;
      a[i] = x;
      pos[x].push_back(i);
      for (int j = 1; j <= 200; j++) {
        v[j][i + 1] = v[j][i];
      }
      v[x][i + 1]++;
    }
    if (n == 1) {
      cout << 1 << endl;
      continue;
    }
    if (n == 2) {
      if (a[0] == a[1])
        cout << 2 << endl;
      else
        cout << 1 << endl;
      continue;
    }
    int m = 200, ans = 0, i, j;
    for (i = 1; i <= m; i++) {
      ans = max(ans, int(pos[i].size()));
    }
    for (i = 1; i <= m; i++) {
      if (pos[i].size() == 1) {
        continue;
      }
      for (j = 0; j < pos[i].size() / 2; j++) {
        ans = max(ans, 2 * (j + 1) +
                           find_max(pos[i][j], pos[i][pos[i].size() - j - 1]));
      }
    }
    cout << ans << endl;
  }
}
