#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  ll t;
  cin >> t;
  while (t--) {
    ll n, r;
    cin >> n >> r;
    for (ll i = 0; i < n - 1; ++i) {
      ll el;
      cin >> el;
      r = (r - (el - 1) + n) % n;
    }
    cout << r % n + 1 << '\n';
  }
}
