#include <bits/stdc++.h>
using namespace std;
int t, n;
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    int a[8001], fr[8001];
    for (int i = 1; i <= n; i++) fr[i] = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      fr[a[i]]++;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      int sum = 0;
      for (int j = i; j <= n; j++) {
        sum += a[j];
        if (i == j) continue;
        if (sum <= n) {
          ans += fr[sum];
          fr[sum] = 0;
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
