#include <bits/stdc++.h>
using namespace std;
int t, n, r, foreheadNr, sum;
int main() {
  cin >> t;
  for (int i = 1; i <= t; ++i) {
    cin >> n >> r;
    sum = 0;
    for (int j = 0; j < n - 1; ++j) {
      cin >> foreheadNr;
      sum += foreheadNr;
    }
    if (r != n) {
      if (sum % n >= r) {
        cout << (n - sum % n) + r << "\n";
      } else {
        cout << r - sum % n << "\n";
      }
    } else {
      if (sum % n != 0)
        cout << n - sum % n << "\n";
      else
        cout << n << "\n";
    }
  }
  return 0;
}
