#include <bits/stdc++.h>
using namespace std;
const int N = 8e3 + 5, INF = int(1e9) + 1, mod = 1e9 + 7;
const long long BIG = 1e16;
int n, a[N], cnt[N], ans;
bool used[N];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    cin >> n;
    ans = 0;
    for (int i = 1; i <= 8e3; i++) {
      used[i] = cnt[i] = 0;
    }
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
      cnt[a[i]]++;
    }
    for (int i = 1; i <= n; i++) {
      int su = a[i];
      for (int j = i + 1; j <= n; j++) {
        su += a[j];
        if (su <= 8e3 and !used[su]) {
          ans += cnt[su];
          used[su] = 1;
        }
      }
    }
    cout << ans << endl;
  }
}
