#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const long long INFLL = 1e18;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int MAX_SIZE = 5e5;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
bool IS_ONE_TEST = 0;
long double START_TIME, TIME;
void fast_in_out() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<int>> x(n + 1);
  for (int i = 1; i <= n; ++i) {
    x[i].emplace_back(0);
  }
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    x[a[i]].emplace_back(i + 1);
  }
  for (int i = 1; i <= n; ++i) {
    x[i].emplace_back(n + 1);
  }
  vector<int> mn(n + 1, INF);
  for (int i = 1; i <= n; ++i) {
    if (int((x[i]).size()) == 2) continue;
    int l = 0, r = n;
    while (r - l > 1) {
      int m = (r + l) / 2;
      int ans = 0;
      bool ok = 1;
      for (int j = 1; j < int((x[i]).size()); ++j) {
        if (x[i][j] - x[i][j - 1] > m) {
          ok = 0;
        }
      }
      if (ok) {
        r = m;
      } else {
        l = m;
      }
    }
    mn[r] = min(mn[r], i);
  }
  int now = mn[1];
  for (int i = 1; i <= n; ++i) {
    now = min(now, mn[i]);
    cout << (now == INF ? -1 : now) << ' ';
  }
  cout << '\n';
}
int main() {
  START_TIME = clock();
  fast_in_out();
  int TESTS = 1;
  if (!IS_ONE_TEST) cin >> TESTS;
  while (TESTS--) {
    solve();
  }
  return 0;
}
