#include <bits/stdc++.h>
using namespace std;
int T, N, R;
int main() {
  scanf("%d", &T);
  for (int(_z) = (0); (_z) < (T); ++(_z)) {
    scanf("%d %d", &N, &R);
    R %= N;
    int cum = 0;
    for (int(i) = (0); (i) < (N - 1); ++(i)) {
      int _a;
      scanf("%d", &_a);
      cum += _a;
      cum %= N;
    }
    int ans = (R - cum + N) % N;
    if (ans == 0) ans = N;
    printf("%d\n", ans);
  }
  return 0;
}
