#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
int arr[200001];
vector<int> prefix[201];
vector<int> id;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < 201; i++) {
      prefix[i].clear();
    }
    id.clear();
    id.resize(n);
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      prefix[arr[i]].push_back(i);
      id[i] = arr[i];
    }
    sort(id.begin(), id.end());
    id.resize(unique(id.begin(), id.end()) - id.begin());
    int len = id.size(), ans = 1;
    for (int i = 0; i < id.size(); i++) {
      for (int j = 0; j < id.size(); j++) {
        if (i == j) {
          ans = max(ans, (int)prefix[id[j]].size());
        } else {
          int limit = (prefix[id[i]].size() >> 1);
          for (int k = 1; k <= limit; k++) {
            int pre = prefix[id[i]][k - 1];
            int suf = prefix[id[i]][prefix[id[i]].size() - k];
            ans =
                max(ans, k * 2 + (int)(lower_bound(prefix[id[j]].begin(),
                                                   prefix[id[j]].end(), suf) -
                                       lower_bound(prefix[id[j]].begin(),
                                                   prefix[id[j]].end(), pre)));
          }
        }
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
