#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m, t, sum, ch;
void R(int &x) {
  x = 0;
  ch = getchar();
  while (ch < '0' || '9' < ch) ch = getchar();
  while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
int main() {
  R(t);
  while (t--) {
    R(n);
    R(m);
    m--;
    sum = 0;
    for (i = 1; i < n; i++) {
      R(k);
      sum += k - 1;
      sum %= n;
    }
    printf("%d\n", (m + n - sum) % n + 1);
  }
}
