#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    unsigned int a, b, sum = 0;
    cin >> a >> b;
    for (int i = 1; i < a; ++i) {
      int c;
      cin >> c;
      sum += c;
    }
    sum %= a;
    sum = (a + b - sum) % a;
    cout << sum + 1 << endl;
  }
  return 0;
}
