#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = (res * a);
      b--;
    }
    a = (a * a);
    b >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t > 0) {
    int n;
    cin >> n;
    vector<int> freq(n + 1, 0);
    vector<int> pre(n);
    for (int i = 0; i < n; i++) {
      int temp;
      cin >> temp;
      freq[temp]++;
      if (i)
        pre[i] = pre[i - 1] + temp;
      else
        pre[i] = temp;
    }
    int ans = 0;
    for (int i = 0; i < n - 2; i++) {
      for (int j = i + 2; j < n; j++) {
        if (pre[j] - pre[i] > n) break;
        if (freq[pre[j] - pre[i]]) {
          ans += freq[pre[j] - pre[i]];
          freq[pre[j] - pre[i]] = 0;
        }
      }
    }
    for (int i = 1; i < n; i++) {
      if (pre[i] > n) break;
      if (freq[pre[i]]) {
        ans += freq[pre[i]];
        freq[pre[i]] = 0;
      }
    }
    cout << ans << "\n";
    t--;
  }
}
