#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 6;
int n, me;
int x[MAXN - 1];
void run() {
  scanf("%d%d", &n, &me);
  --me;
  for (int i = (0); i < (n - 1); ++i) scanf("%d", &x[i]);
  int sum = 0;
  for (int i = (0); i < (n - 1); ++i) sum += x[i];
  int ret = (me - sum) % n;
  if (ret <= 0) ret += n;
  printf("%d\n", ret);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) run();
  return 0;
}
