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