#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string str, s;
  long long n, x, y, b, k = 0, a, i, j, t;
  cin >> t;
  while (t--) {
    k = 0;
    cin >> n;
    cin >> a;
    x = a;
    for (i = 1; i < n; i++) {
      cin >> b;
      if (abs(b - a) > 1) ++k;
      a = b;
    }
    if (abs(x - a) > 1) ++k;
    if (k > 1)
      cout << "NO";
    else
      cout << "YES";
    cout << endl;
  }
  return 0;
}
