#include <bits/stdc++.h>
using namespace std;
const int MAX = (int)(2e5) + 7;
const int MOD = (int)(1e9) + 7;
const int INF_I = (int)(1e9) + 7;
const long long INF_LL = (long long)(1e18);
template <typename T>
void info(T& v) {
  for (auto i : v) cout << i << ' ';
  cout << endl;
}
template <typename T>
bool chkmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chkmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void boot_up() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(false);
}
int q, n;
vector<int> v;
void solve();
bool check();
signed main() {
  boot_up();
  cin >> q;
  while (cin >> n) solve();
}
void solve() {
  v.assign(2 * n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
  }
  for (int i = n + 1; i <= 2 * n; ++i) {
    v[i] = v[i - n];
  }
  if (check()) {
    return;
  }
  reverse((v).begin(), (v).end());
  if (check()) {
    return;
  }
  cout << "NO" << '\n';
}
bool check() {
  for (int i = 1; i <= n; ++i) {
    int flag = 1;
    for (int j = 1, idx = i; idx < i + n; ++idx, ++j) {
      if (v[idx] != j) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      cout << "YES" << '\n';
      return true;
    }
  }
  return false;
}
