#include <bits/stdc++.h>
using namespace std;
const long long N = 8005;
long long a[N], pref[N];
bool special[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long tests;
  cin >> tests;
  while (tests--) {
    memset(special, false, sizeof(special));
    memset(pref, 0, sizeof(pref));
    long long n;
    cin >> n;
    for (long long i = 1; i <= n; i += 1)
      cin >> a[i], pref[i] = pref[i - 1] + a[i];
    for (long long i = 0; i <= n - 2; i += 1) {
      for (long long j = i + 2; j <= n; j += 1) {
        if (pref[j] - pref[i] <= n) special[pref[j] - pref[i]] = true;
      }
    }
    long long output = 0;
    for (long long i = 1; i <= n; i += 1)
      if (special[a[i]]) output++;
    cout << output << endl;
  }
}
