#include <bits/stdc++.h>
using namespace std;
const int maxn = 10000;
int a[maxn];
int sum[maxn];
int vis[maxn];
int main() {
  int t;
  cin >> t;
  while (t--) {
    memset(sum, 0, sizeof(sum));
    memset(vis, 0, sizeof(vis));
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum[i] = sum[i - 1] + a[i];
    }
    for (int i = 1; i <= n; i++) {
      for (int j = i - 2; j >= 0; j--) {
        if (sum[i] - sum[j] <= n) {
          vis[sum[i] - sum[j]] = 1;
        } else {
          break;
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      if (vis[a[i]]) {
        ans++;
      }
    }
    cout << ans << endl;
  }
}
