#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t, i, j, k, n, m, x, y, z, l, r, ans, p, q, f = 0;
  bool temp;
  cin >> t;
  while (t--) {
    cin >> n;
    ans = 0;
    long long int a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i < n; i++) {
      l = 0, r = 0, x = 0;
      k = a[i];
      temp = true;
      while (l < n) {
        if (x < k) {
          if (r < n) {
            x += a[r];
            r++;
          } else
            break;
        } else if (x > k) {
          x -= a[l];
          l++;
        } else {
          if (r - l > 1) {
            ans++;
            break;
          } else {
            l = r;
            x = 0;
          }
        }
      }
    }
    cout << ans << endl;
  }
}
