#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
const double pi = 3.14159265358979;
const double ep = 0.0;
int a[8500], vis[8500];
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < 8500; i++) vis[i] = 0;
    for (int i = 0; i < n; i++) {
      int x = a[i];
      for (int j = i + 1; j < n; j++) {
        x += a[j];
        if (x > n) break;
        vis[x] = 1;
      }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
      if (vis[a[i]] == 1) ans++;
    cout << ans << '\n';
  }
}
