import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
import std.string;
import std.array;
import core.stdc.stdlib;
import core.stdc.stdio;
import core.stdc.string;

void main() @nogc {
	// int tt = 1000;
	int tt;
	scanf("%d", &tt);
	foreach (t; 0 .. tt) {
		// int n = 8000;
		int n;
		scanf("%d", &n);
		int[] arr = (cast(int*)malloc(int.sizeof * n))[0 .. n];
		foreach (i; 0 .. arr.length) {
			scanf("%d", &arr[i]);
			// arr[i] = rand() % n + 1;
		}
		bool[] specials = (cast(bool*)malloc(bool.sizeof * (n + 2)))[0 .. n + 2];
		memset(specials.ptr, 0, bool.sizeof * (n + 2));
		foreach (i; 0 .. arr.length) {
			int sum = arr[i];
			foreach (j; i + 1 .. arr.length) {
				sum += arr[j];
				if (sum < n + 2) {
					specials[sum] = true;
				}
				else {
					break;
				}
			}
		}
		int res;
		foreach (i; arr) {
			if (specials[i]) {
				res++;
			}
		}
		printf("%d\n", res);
	}
}
