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