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