#include <bits/stdc++.h>
 using namespace std;
 int m(int x, int md) { return (((x) % md) + md) % md; }
 void solve() {
   int n;
   cin >> n;
   vector<int> a(n);
   for (int i = 0; i < n; i++) cin >> a[i];
   set<int> st;
   for (int r = 0; r < n; r++) {
     st.insert(m(r + a[r], n));
   }
   if (st.size() == n)
     cout << 'YES
';
   else
     cout << 'NO
';
 }
 int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   int T;
   cin >> T;
   for (int testcase = 1; testcase <= T; testcase++) {
     solve();
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 struct event {
   int pos, type, p;
   event(int pos = 0, int type = -1, int p = 0) : pos(pos), type(type), p(p) {}
   bool operator<(const event &e) const {
     if (pos == e.pos) return type < e.type;
     return pos < e.pos;
   }
 };
 const int maxE = 5e5 + 10;
 event E[maxE];
 int cnt[111];
 double fpow(double a, int n) {
   double r = 1;
   for (; n; n = n >> 1) {
     if (n & 1) r *= a;
     a = a * a;
   }
   return r;
 }
 int main() {
   memset((cnt), (0), sizeof(cnt));
   int n, m, x, h, l, r, sz = 0, b, z;
   scanf('%d%d', &n, &m);
   for (int _n(n), i(0); i < _n; i++) {
     scanf('%d%d%d%d', &x, &h, &l, &r);
     l = 100 - l;
     r = 100 - r;
     E[sz++] = event(x - h, 0, l);
     E[sz++] = event(x, 0, -1 - l);
     E[sz++] = event(x + 1, 0, r);
     E[sz++] = event(x + h + 1, 0, -1 - r);
   }
   for (int _n(m), i(0); i < _n; i++) {
     scanf('%d%d', &b, &z);
     E[sz++] = event(b, z);
   }
   sort(E, E + sz);
   double expectation = 0, pro = 0;
   for (int _n(sz), i(0); i < _n; i++) {
     if (E[i].type == 0) {
       if (E[i].p >= 0) {
         cnt[E[i].p]++;
       } else
         cnt[-E[i].p - 1]--;
     } else {
       pro = 1;
       for (int _n(101), i(0); i < _n; i++) pro *= fpow(0.01 * i, cnt[i]);
       expectation += pro * E[i].type;
     }
   }
   printf('%.7f
', expectation);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int MAX_N = 100011;
 const long long INF = (1 << 29) + 123;
 const long long MOD = 1000000007;
 const long double PI = 4 * atan((long double)1);
 int fenw[2 * MAX_N];
 int n;
 void mod(int i, int v) {
   while (i <= n) {
     fenw[i] += v;
     i += i & -i;
   }
 }
 int query(int i) {
   int sum = 0;
   while (i > 0) {
     sum += fenw[i];
     i -= i & -i;
   }
   return sum;
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin >> n;
   vector<pair<int, int> > p;
   int x[n], v[n];
   for (int i = 0; i < n; i++) cin >> x[i];
   for (int i = 0; i < n; i++) {
     cin >> v[i];
     p.push_back(make_pair(v[i], x[i]));
   }
   unordered_map<int, int> m;
   int rev_map[n];
   sort(x, x + n);
   for (int i = 0; i < n; i++) {
     m[x[i]] = i + 1;
     rev_map[i] = x[i];
   }
   for (int i = 0; i < n; i++) {
     p[i].second = m[p[i].second];
   }
   sort(p.begin(), p.end());
   long long ans = 0;
   for (int i = 0; i < n; i++) {
     int q = query(p[i].second);
     ans += 1LL * q * rev_map[p[i].second - 1];
     ans -=
         1LL * ((n - i - 1) - (p[i].second - 1 - q)) * rev_map[p[i].second - 1];
     mod(p[i].second, 1);
   }
   cout << ans << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n, p1 = 0, p2 = 0;
   cin >> n;
   int mid[1000], index = 0;
   for (int i = 0; i < n; i++) {
     int a;
     cin >> a;
     if (a % 2 == 0) {
       for (int j = 1; j <= (a / 2); j++) {
         int t;
         cin >> t;
         p1 += t;
       }
       for (int j = 1; j <= (a / 2); j++) {
         int t;
         cin >> t;
         p2 += t;
       }
     } else {
       for (int j = 1; j <= (a / 2); j++) {
         int t;
         cin >> t;
         p1 += t;
       }
       cin >> mid[index++];
       for (int j = 1; j <= (a / 2); j++) {
         int t;
         cin >> t;
         p2 += t;
       }
     }
   }
   sort(mid, mid + index);
   for (int i = index - 1; i >= 0; i--) {
     if (((index - 1) % 2 == 0 && i % 2 == 0) ||
         ((index - 1) % 2 == 1 && i % 2 == 1))
       p1 += mid[i];
     else
       p2 += mid[i];
   }
   cout << p1 << ' ' << p2 << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 6010;
 vector<int> a[N];
 int L[N], cnt, r[N], n, res = 0;
 void Refresh() {
   L[0] = cnt = 0;
   for (int i = 1; i <= n + 1; i++) L[i] = 10000000;
 }
 void DFS(int u, int p) {
   int Oldval, Oldid, Oldcnt = cnt;
   if (cnt == 0 || r[u] > L[cnt])
     L[++cnt] = r[u];
   else {
     Oldid = lower_bound(L, L + n + 1, r[u]) - L;
     Oldval = L[Oldid];
     L[Oldid] = r[u];
   }
   res = max(res, cnt);
   for (int i = 0; i < a[u].size(); i++) {
     int v = a[u][i];
     if (v != p) DFS(v, u);
   }
   if (Oldcnt != cnt)
     L[cnt--] = 10000000;
   else
     L[Oldid] = Oldval;
 }
 int main() {
   ios_base::sync_with_stdio(0);
   int u, v;
   cin >> n;
   for (int i = 1; i <= n; i++) cin >> r[i];
   for (int i = 1; i < n; i++) {
     cin >> u >> v;
     a[u].push_back(v);
     a[v].push_back(u);
   }
   for (int i = 1; i <= n; i++) {
     Refresh();
     DFS(i, 0);
   }
   cout << res;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long pow1(int a, int b) {
   long long res = 1;
   for (int i = 1; i <= b; i++) res *= a;
   return res;
 }
 int main() {
   int n;
   cin >> n;
   long long sum = 2 * (pow1(2, n) - 1);
   cout << sum << '
';
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long int gcd(long long int a, long long int b) {
   if (b == 0)
     return a;
   else
     return gcd(b, a % b);
 }
 bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
   return (a.second < b.second);
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   std::cout.precision(12);
   int t;
   cin >> t;
   while (t--) {
     bool f = 0;
     int n, m;
     cin >> n >> m;
     char a[n][m];
     char ans[n][m];
     vector<pair<int, int>> v[26];
     int ma = -1;
     int r, c;
     for (long long int i = 0; i < n; i++) {
       for (long long int j = 0; j < m; j++) {
         cin >> a[i][j];
         ans[i][j] = '.';
         if (a[i][j] >= 97 && a[i][j] <= 'z') {
           v[a[i][j] - 'a'].push_back({i + 1, j + 1});
           if (a[i][j] - 'a' > ma) {
             ma = a[i][j] - 'a';
             r = i + 1;
             c = j + 1;
           }
         }
       }
     }
     vector<pair<int, int>> start[ma + 1], end[ma + 1];
     for (long long int i = 0; i < ma + 1; i++) {
       if (v[i].size() == 0) {
         start[i].push_back({r, c});
         end[i].push_back({r, c});
       } else if (v[i].size() == 1) {
         ans[v[i][0].first - 1][v[i][0].second - 1] = 'a' + i;
         start[i].push_back({v[i][0].first, v[i][0].second});
         end[i].push_back({v[i][0].first, v[i][0].second});
       } else {
         if (v[i][1].first == v[i][0].first) {
           int mi = m + 6, m = 0;
           for (int j = 0; j < v[i].size(); j++) {
             if (v[i][j].first != v[i][0].first) {
               f = 1;
               break;
             }
             mi = min(mi, v[i][j].second);
             m = max(m, v[i][j].second);
           }
           if (f == 1) break;
           for (int j = mi - 1; j < m; j++) {
             ans[v[i][0].first - 1][j] = 'a' + i;
           }
           start[i].push_back({v[i][0].first, mi});
           end[i].push_back({v[i][0].first, m});
         } else if (v[i][1].second == v[i][0].second) {
           int mi = n + 6, m = 0;
           for (int j = 0; j < v[i].size(); j++) {
             if (v[i][j].second != v[i][0].second) {
               f = 1;
               break;
             }
             mi = min(mi, v[i][j].first);
             m = max(m, v[i][j].first);
           }
           if (f == 1) break;
           for (int j = mi - 1; j < m; j++) {
             ans[j][v[i][0].second - 1] = 'a' + i;
           }
           start[i].push_back({mi, v[i][0].second});
           end[i].push_back({m, v[i][0].second});
         } else {
           f = 1;
           break;
         }
       }
     }
     for (long long int i = 0; i < n; i++) {
       for (long long int j = 0; j < m; j++) {
         if (a[i][j] != ans[i][j]) {
           f = 1;
           break;
         }
       }
       if (f == 1) break;
     }
     if (f == 0) {
       cout << 'YES
';
       cout << ma + 1 << endl;
       for (long long int i = 0; i < ma + 1; i++)
         cout << start[i][0].first << ' ' << start[i][0].second << ' '
              << end[i][0].first << ' ' << end[i][0].second << endl;
     } else {
       cout << 'NO
';
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
 const long long linf = 4000000000000000000LL;
 const long long inf = 998244353;
 const long double pi = 3.1415926535;
 void pv(vector<int> a) {
   for (auto& x : a) cout << x << ' ';
   cout << '
';
 }
 void pv(vector<long long> a) {
   for (auto& x : a) cout << x << ' ';
   cout << '
';
 }
 void pv(vector<vector<int>> a) {
   for (int i = (0); i < (int(a.size())); ++i) {
     cout << i << '
';
     pv(a[i]);
     cout << '
';
   }
 }
 void pv(vector<vector<long long>> a) {
   for (int i = (0); i < (int(a.size())); ++i) {
     cout << i << '
';
     pv(a[i]);
   }
   cout << '
';
 }
 void pv(vector<string> a) {
   for (auto& x : a) cout << x << '
';
   cout << '
';
 }
 void build_primes(vector<int>& primes, int size) {
   vector<int> visited;
   visited.resize(size, 0);
   for (int i = (2); i < (size); ++i) {
     if (visited[i] == 0) {
       primes.push_back(i);
       int a = i;
       while (a < size) {
         visited[a] = 1;
         a += i;
       }
     }
   }
 }
 vector<vector<long long>> matrix_mult(vector<vector<long long>>& a,
                                       vector<vector<long long>>& b) {
   int n = a.size();
   vector<vector<long long>> answer;
   answer.resize(n);
   for (int i = 0; i < n; i++) answer[i].resize(n, 0);
   for (int i = 0; i < n; i++) {
     for (int j = 0; j < n; j++) {
       for (int k = 0; k < n; k++)
         answer[i][j] = (answer[i][j] + a[i][k] * b[k][j]) % inf;
     }
   }
   return answer;
 }
 int modInverse(int a, int m) {
   int m0 = m;
   int y = 0, x = 1;
   if (m == 1) return 0;
   while (a > 1) {
     int q = a / m;
     int t = m;
     m = a % m, a = t;
     t = y;
     y = x - q * y;
     x = t;
   }
   if (x < 0) x += m0;
   return x;
 }
 long long power(long long x, long long y) {
   long long k = 1LL << 60;
   long long z = 1;
   while (k != 0) {
     z *= z;
     z %= inf;
     if (y >= k) {
       z *= x;
       z %= inf;
       y -= k;
     }
     k >>= 1;
   }
   return z;
 }
 struct point {
   long double x, y;
   bool operator<(const point& rhs) const {
     if (x == rhs.x) return y < rhs.y;
     return x < rhs.x;
   }
 };
 struct pt {
   long long x, y;
   bool operator<(const point& rhs) const {
     if (x == rhs.x) return y < rhs.y;
     return x < rhs.x;
   }
 };
 long double area(point x, point y, point z) {
   return (x.y * y.x + y.y * z.x + z.y * x.x - x.x * y.y - y.x * z.y -
           z.x * x.y) /
          2.0;
 }
 bool clockwise(point x, point y, point z) { return area(x, y, z) > 0; }
 long double area(pt x, pt y, pt z) {
   return (x.y * y.x + y.y * z.x + z.y * x.x - x.x * y.y - y.x * z.y -
           z.x * x.y) /
          2.0;
 }
 bool clockwise(pt x, pt y, pt z) { return area(x, y, z) > 0; }
 long long gcd(long long a, long long b) {
   if (a > b) swap(a, b);
   if (a == 0) return b;
   return gcd(a, b % a);
 }
 int popcount(long long a) {
   int count = 0;
   while (a) {
     count += (a & 1);
     a >>= 1;
   }
   return count;
 }
 long long choose(long long n, long long r) {
   long long p = 1, k = 1;
   if (n - r < r) r = n - r;
   if (r != 0) {
     while (r) {
       p *= n;
       k *= r;
       long long m = gcd(p, k);
       p /= m;
       k /= m;
       n--;
       r--;
     }
   } else
     p = 1;
   return p;
 }
 vector<long long> prefix_hash(string& a, vector<long long>& powers) {
   int n = int(a.size());
   vector<long long> prefix(n + 1);
   for (int i = (0); i < (n); ++i)
     prefix[i + 1] = (prefix[i] + powers[i] * (a[i] - 'a' + 1)) % inf;
   return prefix;
 }
 struct custom_hash {
   static uint64_t splitmix64(uint64_t x) {
     x += 0x9e3779b97f4a7c15;
     x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
     x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
     return x ^ (x >> 31);
   }
   uint64_t operator()(uint64_t x) const {
     static const uint64_t FIXED_RANDOM =
         chrono::steady_clock::now().time_since_epoch().count();
     return splitmix64(x + FIXED_RANDOM);
   }
 };
 struct custom_hash_fast {
   uint64_t operator()(uint64_t x) const {
     static const uint64_t FIXED_RANDOM =
         chrono::steady_clock::now().time_since_epoch().count();
     x ^= FIXED_RANDOM;
     return x ^ (x >> 16);
   }
 };
 void setIO(string second) {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
 }
 int main() {
   setIO('');
   int testc;
   cin >> testc;
   while (testc--) {
     int n;
     cin >> n;
     string a;
     cin >> a;
     int i = n - 1;
     for (; i >= 0; i--)
       if ((a[i] - '0') & 1) break;
     if (i == -1) {
       cout << -1 << '
';
       continue;
     }
     int j = 0;
     for (; j < i; j++) {
       if ((a[j] - '0') % 2 == 1) break;
     }
     if (j == i) {
       cout << -1 << '
';
       continue;
     }
     cout << a[j] << a[i] << '
';
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int t;
   cin >> t;
   while (t--) {
     int n, m, k;
     cin >> n >> m >> k;
     int cardsPlayer = n / k;
     double maxCard;
     int jokerMax = min(m, cardsPlayer);
     maxCard = ceil((m - jokerMax) / (k - 1.0));
     if (jokerMax - maxCard > 0)
       cout << jokerMax - maxCard << endl;
     else
       cout << 0 << endl;
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 typedef struct {
   long long j, x1, x2;
 } inter;
 struct comp1 {
   bool operator()(const inter& a, const inter& b) const { return a.x1 < b.x1; };
 };
 struct comp2 {
   bool operator()(const inter& a, const inter& b) const {
     return (a.x2 == b.x2) ? (a.x1 < b.x1) : (a.x2 < b.x2);
   };
 };
 void solve() {
   long long n;
   cin >> n;
   vector<long long> a(n), b(n), m(n);
   unordered_map<long long, vector<long long>> dsize;
   for (long long i = 0; i < (n); i++) {
     cin >> a[i] >> b[i] >> m[i];
     dsize[a[i] + b[i] - m[i]].push_back(i);
   }
   long long c = 0;
   vector<long long> ea(n);
   for (auto& x : dsize) {
     multiset<inter, comp1> inter1;
     multiset<inter, comp2> inter2;
     for (auto& i : x.second) {
       long long eamax = min(m[i], a[i]);
       long long eamin = max(m[i] - b[i], 0LL);
       inter1.insert(inter{i, a[i] - eamax, a[i] - eamin});
       inter2.insert(inter{i, a[i] - eamax, a[i] - eamin});
     }
     auto p1 = inter1.begin();
     while (!inter2.empty()) {
       long long targ = inter2.begin()->x2;
       while ((p1 == inter1.end()) ? false : (p1->x1 <= targ)) {
         inter2.erase(*p1);
         ea[p1->j] = a[p1->j] - targ;
         p1++;
       }
       c++;
     }
   }
   cout << c << endl;
   for (long long i = 0; i < (n); i++)
     cout << ea[i] << ' ' << m[i] - ea[i] << endl;
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   ifstream ifs;
   if (''[0]) cin.rdbuf((ifs = ifstream('')).rdbuf());
   ;
   ofstream ofs;
   if (''[0]) cout.rdbuf((ofs = ofstream('')).rdbuf());
   ;
   ofstream lfs;
   if (''[0]) clog.rdbuf((lfs = ofstream('')).rdbuf());
   ;
   int t;
   cin >> t;
   for (int i = 1; i <= t; i++) {
     solve();
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const long long mod = 1e9 + 7;
 long long a[2000], dp[2000];
 long long qmod(long long y) {
   long long res = 1, two = (long long)2;
   for (; y; y >>= 1) {
     if (y & 1) res = res * two % mod;
     two = two * two % mod;
   }
   return res;
 }
 int main() {
   long long x, y;
   int cnt = 0;
   scanf('%lld%lld', &x, &y);
   if (y % x) return 0 * puts('0');
   for (long long i = 1; i <= sqrt(y); ++i) {
     if (y % i == 0) {
       if (i % x == 0) a[++cnt] = i;
       if (i * i != y && y / i % x == 0) a[++cnt] = y / i;
     }
   }
   sort(a + 1, a + 1 + cnt);
   for (int i = cnt; i > 0; --i) {
     dp[i] = qmod(y / a[i] - 1);
     for (int j = i + 1; j <= cnt; ++j)
       if (a[j] % a[i] == 0) dp[i] = ((dp[i] - dp[j]) % mod + mod) % mod;
   }
   printf('%lld
', dp[1]);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 inline void Input_Output() {}
 const double eps = 0.000001;
 const long double pi = acos(-1);
 const int maxn = 1e7 + 9;
 const int mod = 1e9 + 7;
 const long long MOD = 1e18 + 9;
 const long long INF = 1e18 + 123;
 const int inf = 2e9 + 11;
 const int mxn = 1e6 + 9;
 const int N = 6e5 + 123;
 const int K = 80;
 const int pri = 997;
 const int Magic = 2101;
 const int dx[] = {-1, 0, 1, 0};
 const int dy[] = {0, -1, 0, 1};
 int n, m, k, x;
 vector<int> state;
 int ids[(1 << 8)];
 struct Mat {
   long long d[K][K];
   Mat(long long val = INF) {
     for (int i = 0; i < K; ++i)
       for (int j = 0; j < K; ++j) d[i][j] = INF;
     for (int i = 0; i < K; ++i) d[i][i] = val;
   }
   Mat operator+(Mat &b) {
     Mat res;
     for (int i = 0; i < K; ++i)
       for (int j = 0; j < K; ++j)
         for (int k = 0; k < K; ++k)
           res.d[i][j] = min(res.d[i][j], d[i][k] + b.d[k][j]);
     return res;
   }
   void print() {
     for (int i = 0; i < K; ++i) {
       for (int j = 0; j < K; ++j) {
         if (d[i][j] == INF) {
           cout << 'bd ';
           continue;
         }
         cout << d[i][j] << ' ';
       }
       cout << '
';
     }
   }
 };
 Mat make_matrix(vector<long long> &c) {
   assert((int)(c.size()) == k);
   Mat res;
   for (int id = 0; id < (int)(state.size()); ++id) {
     int msk = state[id];
     if (msk % 2 == 0) {
       int nmsk = msk / 2;
       res.d[id][ids[nmsk]] = 0;
       continue;
     }
     for (int i = 0; i < k; ++i) {
       int nmsk = (msk >> 1);
       if (nmsk & (1 << i)) {
         continue;
       }
       nmsk |= (1 << i);
       res.d[id][ids[nmsk]] = min(res.d[id][ids[nmsk]], c[i]);
     }
   }
   return res;
 }
 int main() {
   ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   cin >> x >> k >> n >> m;
   for (int msk = 0; msk < (1 << k); ++msk) {
     ids[msk] = -1;
     if (__builtin_popcount(msk) != x) {
       continue;
     }
     ids[msk] = (int)(state.size());
     state.push_back(msk);
   }
   vector<long long> c(k);
   for (auto &e : c) cin >> e;
   vector<int> pos = {0, n - x};
   vector<pair<int, int> > spec(m);
   for (auto &it : spec) {
     cin >> it.first >> it.second;
     it.first--;
     for (int i = 0; i <= k; ++i) {
       int s = it.first - i;
       s = max(s, 0);
       s = min(s, n - x);
       pos.push_back(s);
     }
   }
   sort(pos.begin(), pos.end());
   pos.resize(unique(pos.begin(), pos.end()) - pos.begin());
   vector<Mat> Pw;
   Pw.push_back(make_matrix(c));
   int bit = 0;
   while ((1 << bit) <= n) {
     ++bit;
     Pw.push_back(Pw.back() + Pw.back());
   }
   Mat cur = 0;
   for (int it = 0; it + 1 < (int)(pos.size()); ++it) {
     int l = pos[it], r = pos[it + 1];
     vector<long long> nc = c;
     for (auto s : spec) {
       if (s.first > l && s.first <= l + k) {
         nc[s.first - l - 1] += s.second;
       }
     }
     if (nc != c) {
       Mat cn = make_matrix(nc);
       cur = cur + cn;
     } else {
       int dif = r - l;
       for (int i = 0; i < (int)(Pw.size()); ++i) {
         if (dif & (1 << i)) {
           cur = cur + Pw[i];
         }
       }
     }
   }
   int fin = (1 << x) - 1;
   fin = ids[fin];
   assert(fin != -1);
   cout << cur.d[fin][fin] << '
';
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 bool vis[2][100005];
 char c[2][100005];
 int main() {
   queue<pair<int, pair<int, int> > > q;
   bool flag = 0;
   int n, k;
   cin >> n >> k;
   scanf('%s%s', c[0], c[1]);
   q.push(make_pair(0, make_pair(0, 0)));
   while (!q.empty()) {
     int x = q.front().first, y = q.front().second.first,
         de = q.front().second.second;
     q.pop();
     if (y >= n) {
       flag = 1;
       break;
     }
     if (vis[x][y] || de > y) continue;
     vis[x][y] = 1;
     if (y - 1 >= 0 && c[x][y - 1] != 'X' && y - 1 >= de + 1 && !vis[x][y - 1]) {
       q.push(make_pair(x, make_pair(y - 1, de + 1)));
     }
     if (y + 1 >= n || (c[x][y + 1] != 'X' && !vis[x][y + 1])) {
       q.push(make_pair(x, make_pair(y + 1, de + 1)));
     }
     if (y + k >= n || (c[x ^ 1][y + k] != 'X' && !vis[x ^ 1][y + k])) {
       q.push(make_pair(x ^ 1, make_pair(y + k, de + 1)));
     }
   }
   if (flag)
     cout << 'YES';
   else
     cout << 'NO';
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   ;
   long long int n, k, sum = 0;
   cin >> n >> k;
   long long int a[n];
   for (long long int i = 0; i < n; i++) cin >> a[i];
   string s;
   cin >> s;
   vector<long long int> v;
   v.push_back(a[0]);
   for (long long int i = 1; s[i]; i++) {
     if (s[i] == s[i - 1])
       v.push_back(a[i]);
     else {
       sort(v.rbegin(), v.rend());
       for (long long int i = 0; i < k && i < v.size(); i++) {
         sum += v[i];
       }
       v.clear();
       v.push_back(a[i]);
     }
   }
   sort(v.rbegin(), v.rend());
   for (long long int i = 0; i < k && i < v.size(); i++) sum += v[i];
   cout << sum;
 }


#include<bits/stdc++.h>
 using namespace std;
 int a[10];
 int main() {
     int T;scanf('%d',&T);
     while(T--) {
         int sum = 0;
         for(int i = 1;i <= 3;i++) {
             scanf('%d',&a[i]);
             sum += a[i];
         }
         if(sum % 9 == 0) {
             if(a[1] >= sum / 9 && a[2] >= sum / 9 && a[3] >= sum / 9) {
                 printf('YES
');
             } else {
                 printf('NO
');
             }
         } else {
             printf('NO
');
         }
     }
     return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 using ll = long long int;
 using ld = long double;
 using vi = vector<int>;
 using vll = vector<ll>;
 using vd = vector<double>;
 using vvi = vector<vi>;
 int ctoi(char c) { return c - '0'; }
 int slen(string s) { return s.length(); }
 int vsize(vi a) { return (int)a.size(); }
 int in() {
   int x;
   cin >> x;
   return x;
 }
 int main() {
   ios::sync_with_stdio(false);
   cin.tie(nullptr);
   int N;
   cin >> N;
   vi d(N);
   for (auto& x : d) cin >> x;
   int mn = abs(d[N - 1] - d[0]);
   int a = N - 1, b = 0;
   for (int i = 1; i < N; i++) {
     if (abs(d[i] - d[i - 1]) < mn) {
       mn = abs(d[i] - d[i - 1]);
       a = i;
       b = i - 1;
     }
   }
   cout << a + 1 << ' ' << b + 1 << endl;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n;
   cin >> n;
   int result = 0;
   for (int i = 0; i < n; i++) {
     int k, a;
     cin >> k >> a;
     long x = k * a;
     int c = 0;
     if (a % 4 == 0) a--;
     while (a) {
       a /= 4;
       c++;
     }
     result = (((result) < (k + c)) ? (k + c) : (result));
   }
   cout << result;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   long long n, m;
   cin >> n >> m;
   long long x;
   for (int i = 0; i < m; i++) {
     cin >> x;
     if (x > n)
       cout << 0 << endl;
     else {
       if (x % 2 == 1)
         cout << x / 2 + 1 << endl;
       else {
         long long a = x, b, c = n;
         while (1) {
           if (a % 2 == 1) break;
           b = a + (c - a / 2);
           a = b;
         }
         cout << a / 2 + 1 << endl;
       }
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 const int inf = 0x3f3f3f3f;
 const int maxn = 100010;
 int x0[maxn], x1[maxn], d[maxn], c[maxn];
 int main() {
   int n, m, y0, y1;
   scanf('%d %d %d %d', &n, &m, &y0, &y1);
   for (int i = 0; i < n; ++i) {
     scanf('%d', &x0[i]);
   }
   memset(d, -1, sizeof(d));
   for (int i = 0; i < m; ++i) {
     scanf('%d', &x1[i]);
   }
   int p = 0, k = 0, last = -1;
   for (int i = 0; i < n; ++i) {
     while (p < m && abs(x0[i] - x1[p]) > abs(x0[i] - x1[p + 1])) ++p;
     if (last < p || abs(x0[i - 1] - x1[p]) == abs(x0[i] - x1[p]))
       ++k, last = p;
     else if (p < m && abs(x0[i] - x1[p]) == abs(x0[i] - x1[p + 1]))
       ++k, last = ++p;
     else
       last = p;
   }
   printf('%d
', n - k);
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   string a;
   cin >> a;
   long long int x = a.length();
   std::vector<long long int> v;
   long long int c = 0;
   long long int d = 0;
   for (long long int i = 0; i < x; i++) {
     if (a[i] == 'b') {
       d++;
     }
     if (a[i] == 'a') {
       if (d > 0 && c > 0) {
         v.push_back(c);
         d = 0;
         c = 0;
       }
       c++;
       d = 0;
     }
   }
   if (c > 0) v.push_back(c);
   long long int res = 1;
   for (long long int i = 0; i < v.size(); i++) {
     res = (res * (v[i] + 1)) % 1000000007;
   }
   cout << res - 1;
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int n, a[16], b[16];
 int main() {
   double cnt = 0;
   ios::sync_with_stdio(false);
   cin >> n;
   for (register int i = 0; i < n; i++) cin >> a[i];
   for (register int i = 0; i < n; i++) cin >> b[i];
   for (register int i = 0; i < 1e6; ++i) {
     register bool f = false;
     for (register int j = 0; !f && j < n; ++j) f |= i % a[j] == b[j];
     cnt += f;
   }
   cout.setf(ios::fixed, ios::floatfield);
   return (cout << setprecision(7) << cnt / 1e6 << endl) && 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 long long n, k1, k2;
 long long a[1005];
 long long b[1005];
 void ReadData() {
   cin >> n >> k1 >> k2;
   for (long long i = 1; i <= n; i++) cin >> a[i];
   for (long long i = 1; i <= n; i++) cin >> b[i];
 }
 long long c[1005];
 void process() {
   long long k = k1 + k2;
   priority_queue<long long> heap;
   for (long long i = 1; i <= n; i++) {
     c[i] = abs(a[i] - b[i]);
     heap.push(c[i]);
   }
   while (k--) {
     long long tmp = heap.top();
     heap.pop();
     tmp--;
     heap.push(abs(tmp));
   }
   long long res = 0;
   while (!heap.empty()) {
     long long tmp = heap.top();
     heap.pop();
     res += tmp * tmp;
   }
   cout << res;
 }
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   ReadData();
   process();
 }


#include <bits/stdc++.h>
 using namespace std;
 const int N = 1002, M = 10002;
 pair<int, long long> dp[N][M];
 map<long long, int> di;
 bool vis[N][M];
 int nxt[N][M];
 long long a[N], b[N], k;
 int T[M][N];
 int n;
 long long gcd(long long a, long long b) {
   if (b == 0) return a;
   return gcd(b, a % b);
 }
 int main() {
   scanf('%d %lld', &n, &k);
   for (int i = 0; i < n; ++i) {
     scanf('%lld', b + i);
     a[i] = gcd(b[i], k);
   }
   if (k == 1) return printf('%d
%ld
', 1, min_element(b, b + n) - b + 1), 0;
   vector<long long> divisor;
   for (long long i = 1; i * i <= k; ++i)
     if (k % i == 0) {
       divisor.push_back(i);
       divisor.push_back(k / i);
     }
   sort(divisor.begin(), divisor.end());
   divisor.resize(unique(divisor.begin(), divisor.end()) - divisor.begin());
   int m = divisor.size();
   for (int i = 0; i < m; ++i) di[divisor[i]] = i;
   for (int i = 0; i < m; ++i)
     for (int j = 0; j < n; ++j)
       T[i][j] = di[divisor[i] / gcd(divisor[i], a[j])];
   nxt[n][0] = -1;
   dp[n][0] = {0, 0};
   for (int i = 1; i < m; ++i) dp[n][i] = {n + 1, 0};
   for (int i = 0; i < m; ++i)
     for (int j = n - 1; j >= 0; --j) {
       pair<int, long long> ans1 = dp[j + 1][i];
       pair<int, long long> ans2 = dp[j + 1][T[i][j]];
       ans2.first += 1;
       ans2.second += b[j];
       if (ans1 <= ans2) {
         nxt[j][i] = nxt[j + 1][i];
         dp[j][i] = ans1;
       } else {
         nxt[j][i] = j;
         dp[j][i] = ans2;
       }
     }
   pair<int, long long> ans = dp[0][m - 1];
   if (ans.first > n) return puts('-1'), 0;
   printf('%d
', ans.first);
   int pos = 0;
   int nx = m - 1;
   while (pos != -1) {
     if (nxt[pos][nx] != pos)
       pos = nxt[pos][nx];
     else {
       nx = T[nx][pos];
       printf('%d ', pos + 1);
       pos += 1;
     }
   }
   puts('');
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   ios_base::sync_with_stdio(0);
   int n;
   cin >> n;
   int a[100005];
   for (int i = 0; i < n; i++) cin >> a[i];
   sort(a, a + n);
   if (n == 1) {
     cout << -1 << endl;
     return 0;
   }
   bool flag = true;
   for (int i = 1; i < n; i++) flag = flag && (a[0] == a[i]);
   if (flag) {
     cout << 1 << endl;
     cout << a[0] << endl;
     return 0;
   }
   if (n == 2) {
     if ((a[0] + a[1]) % 2 == 0)
       cout << 3 << endl;
     else
       cout << 2 << endl;
     cout << 2 * a[0] - a[1] << ' ';
     if ((a[0] + a[1]) % 2 == 0) cout << (a[1] + a[0]) / 2 << ' ';
     cout << 2 * a[1] - a[0] << ' ';
     return 0;
   }
   flag = true;
   for (int i = 2; i < n; i++) flag = flag && (a[1] - a[0] == a[i] - a[i - 1]);
   if (flag) {
     cout << 2 << endl;
     cout << 2 * a[0] - a[1] << ' ';
     cout << 2 * a[n - 1] - a[n - 2] << endl;
     return 0;
   }
   vector<int> diff;
   set<int> di;
   for (int i = 1; i < n; i++) {
     diff.push_back(a[i] - a[i - 1]);
     di.insert(a[i] - a[i - 1]);
   }
   if (di.size() != 2) {
     cout << 0 << endl;
     return 0;
   }
   sort(diff.begin(), diff.end());
   int chan = diff[n - 2];
   if (chan != 2 * diff[0]) {
     cout << 0 << endl;
     return 0;
   }
   for (int i = n - 3; i >= 0; i--) {
     if (diff[i] == chan || diff[i] != diff[0]) {
       cout << 0 << endl;
       return 0;
     }
   }
   for (int i = 1; i < n; i++) {
     if (a[i] - a[i - 1] == chan) {
       if ((a[i] + a[i - 1]) % 2 == 0) {
         cout << 1 << endl;
         cout << (a[i] + a[i - 1]) / 2 << endl;
         return 0;
       } else {
         cout << 0 << endl;
         return 0;
       }
     }
   }
   return 0;
 }


#include <bits/stdc++.h>
 using namespace std;
 vector<long int> fib(46, -1);
 int adv_fib(int n) {
   if (n == 0 || n == 1) {
     return 1;
   } else if (fib[n] == -1) {
     return fib[n] = adv_fib(n - 1) + adv_fib(n - 2);
   } else {
     return fib[n];
   }
 }
 int main() {
   int n, curr = 1;
   cin >> n;
   for (int i = 1; i <= n; i++) {
     if (adv_fib(curr) == i) {
       cout << 'O';
       curr++;
     } else {
       cout << 'o';
     }
   }
 }


#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n;
   cin >> n;
   vector<int> v(n);
   for (auto &x : v) cin >> x;
   int mine = *min_element(v.begin(), v.end());
   vector<int> temp;
   for (int i = 0; i < n; i++) {
     if (v[i] == mine) temp.push_back(i);
   }
   for (int i = 0; i < temp.size() - 1; i++) temp[i] = temp[i + 1] - temp[i];
   cout << *min_element(temp.begin(), temp.end() - 1) << endl;
 }


#include <bits/stdc++.h>
 using namespace std;
 const int maxn = 1e5 + 50;
 int n, a[maxn], ans, maxx = 0;
 int main() {
   cin >> n;
   for (int i = 1; i <= n; i++) {
     cin >> a[i];
     maxx = max(maxx, a[i]);
   }
   cout << maxx;
   return 0;
 }