using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var t = NN; var ans = new int[t]; for (var u = 0; u < t; ++u) { var n = NN; var f = NList; var c = f.Sum(fi => 1 - fi); ans[u] = (c + 1) % n; } WriteLine(string.Join("\n", ans)); } }