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