#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, in, ans = 1, count[202];
    cin >> n;
    vector<int> v, m[202];
    for (int i = 0; i < n; i++) {
      cin >> in;
      v.push_back(in);
      m[in].push_back(i);
    }
    for (int i = 1; i <= 200; i++) {
      memset(count, 0, sizeof count);
      int maxim = 0;
      if (m[i].size() < 2) continue;
      int l = m[i].size() / 2 - 1;
      int r = m[i].size() / 2 + (m[i].size() & 1 ? 1 : 0);
      for (int j = m[i][l] + 1; j < m[i][r]; j++)
        maxim = max(maxim, ++count[v[j]]);
      while (1) {
        ans = max((l + 1) * 2 + maxim, ans);
        if (l == 0) break;
        for (int j = m[i][l] - 1; j > m[i][l - 1]; j--)
          maxim = max(maxim, ++count[v[j]]);
        for (int j = m[i][r] + 1; j < m[i][r + 1]; j++)
          maxim = max(maxim, ++count[v[j]]);
        l--, r++;
      }
    }
    cout << ans << '\n';
  }
}
