import java.util.*;
import java.io.*;

/*
Consider the problem as a graph problem.
Notice how every node has at most 1 outgoing edge.
Therefore, each path forms either a tree, or some group of trees leading to a cycle.
In the first case, if the component has n nodes, it has n-1 edges.
In the other case, it will have n edges.
We need to count the components with equal number of edges to nodes, and sum up the number of nodes in these components to get the answer.
*/

public class jump{

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new FileReader(new File("jump.in")));
		int t = Integer.parseInt(br.readLine());
		long x = System.currentTimeMillis();
		for(int q = 1; q <= t; q++){
			int n = Integer.parseInt(br.readLine());
			int[] arr = new int[n];
			String[] in = br.readLine().split(" ");
			for(int i = 0; i < n; i++) arr[i] = Integer.parseInt(in[i]);
			ArrayList<Integer>[] graph = new ArrayList[n];
			for(int i = 0; i < n; i++) graph[i] = new ArrayList<Integer>();
			for(int i = 0; i < n; i++){
				int v = arr[i]+i;
				if(v < n && v >= 0){
					graph[v].add(i);
					graph[i].add(v);
				}
			}

			boolean[] v = new boolean[n];
			int ans = 0;
			for(int i = 0; i < n; i++){
				if(v[i]) continue;
				ArrayDeque<Integer> bfs = new ArrayDeque<Integer>();
				bfs.add(i);
				v[i] = true;
				int nodes = 0;
				int edges = 0;
				while(!bfs.isEmpty()){
					int p = bfs.poll();
					nodes++;
					edges += graph[p].size();
					for(int j : graph[p]){
						if(!v[j]){
							v[j] = true;
							bfs.add(j);
						}
					}
				}
				if(nodes == edges/2) ans += nodes;
			}
			System.out.println(ans);
		}
		System.out.println(System.currentTimeMillis()-x);
	}
}