#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int maxn = 1e6 + 10;
const long long inf = 0x3f3f3f3f;
const int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int a[8010], cnt[8010];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], cnt[i] = 0;
    for (int i = 1; i <= n; i++) {
      int s = a[i];
      for (int j = i + 1; j <= n; j++) {
        s += a[j];
        if (s > n) break;
        cnt[s] = 1;
      }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (cnt[a[i]]) ans++;
    }
    cout << ans << '\n';
  }
  return 0;
}
