#include <bits/stdc++.h>
using namespace std;
const double h = 1e-6;
const int MAX_ = 200005;
inline long long int mul(long long int a, long long int b) {
  return (a * 1ll * b) % 1000000007;
}
inline long long int sub(long long int a, long long int b) {
  long long int c = a - b;
  if (c < 0) c += 1000000007;
  return c;
}
inline long long int add(long long int a, long long int b) {
  long long int c = a + b;
  if (c > 1000000007) c -= 1000000007;
  return c;
}
long long int sqr(long long int x) { return x * x; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> v(n);
    for (long long int i = 0; i < n; i++) cin >> v[i];
    vector<int> pre(n + 1, 0);
    vector<int> pos(n + 1, 0);
    pre[0] = v[0];
    for (int i = 0; i < n; ++i) {
      pre[i + 1] = pre[i] + v[i];
    }
    for (int i = 0; i < n; ++i) {
      for (int j = i + 2; j <= n && pre[j] - pre[i] <= n; ++j) {
        int val = pre[j] - pre[i];
        pos[val] = 1;
      }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      int val = v[i];
      if (pos[val] == 1) ans++;
    }
    cout << ans << "\n";
  }
  return 0;
}
