#include <bits/stdc++.h>
using namespace std;
const long long N = 3e3;
long long q;
int main() {
  cin >> q;
  for (long long j = 0; j < q; ++j) {
    long long n, r;
    cin >> n >> r;
    --r;
    long long sum = 0;
    for (long long i = 0; i < n - 1; ++i) {
      long long x;
      cin >> x;
      --x;
      sum += x;
    }
    long long ans = (n - sum % n + r) % n;
    cout << ans + 1 << "\n";
  }
  return 0;
}
