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