#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, r, x, s = 0;
    scanf("%d%d", &n, &r);
    for (int i = 1; i < n; ++i) {
      scanf("%d", &x);
      s += x;
    }
    for (int i = 1; i <= n; ++i)
      if ((s + i - 1) % n + 1 == r) printf("%d\n", i);
  }
}
