// Arup Guha
// 4/29/2020
// Alternate Solution to 2020 FHSPS Problem: Jump Conveyor

import java.util.*;

public class jump_arup {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process all cases.
		for (int loop=0; loop<nC; loop++) {
		
			// Read in the values.
			int n = stdin.nextInt();
			int[] vals = new int[n];
			for (int i=0; i<n; i++)
				vals[i] = stdin.nextInt();
		
			// comp[i] = which component vertex i is in.
			int[] comp = new int[n];
			Arrays.fill(comp, -1);
			
			// compList[i] will store whether or not the ith component goes forever.
			ArrayList<Boolean> compList = new ArrayList<Boolean>();
			
			int id = -1;
			
			// Go through each item.
			for (int i=0; i<n; i++) {
			
				// We've searched this vertex before.
				if (comp[i] != -1) continue;
			
				// Mark it.
				id++;
				comp[i] = id;
				int cur = i;
				
				// Deal with loop control later =)
				while (true) {
				
					// Where I go to next.
					int next = cur + vals[cur];
					
					// Jumped off our list of trampolines.
					if (next < 0 || next >= n) {
						compList.add(false);
						break;
					}
					
					// We've completed a cycle.
					if (comp[next] == id) {
						compList.add(true);
						break;
					}
					
					// Hooked onto a previously searched component.
					// Our fate is the fate of that component.
					if (comp[next] != -1) {
						compList.add(compList.get(comp[next]));
						break;
					}
					
					// If we get here, we continue hopping =)
					comp[next] = id;
					cur = next;
				} // end this jumping session
			} // end search
		
			// Now, go back through each trampoline and see if its component goes forever or not.
			int res = 0;
			for (int i=0; i<n; i++) 
				if (compList.get(comp[i]))
					res++;
					
			// Ta da!
			System.out.println(res);
		}
	}
}