#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
void solve() {
  int n;
  int ans = 0;
  cin >> n;
  int a[8008];
  int b[8008] = {0};
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = b[i - 1] + a[i];
  }
  if (n < 3) {
    cout << 0 << endl;
    return;
  }
  for (int i = 1; i <= n; i++) {
    int l = 1, r = 2;
    for (; r <= n;) {
      if (r > n) {
        break;
      }
      if (r >= i && l <= i) {
        l = i + 1;
        r = i + 2;
        continue;
      }
      if (b[r] - b[l - 1] < a[i]) {
        r++;
        continue;
      } else if (b[r] - b[l - 1] > a[i]) {
        if (r - 1 <= l) {
          l++;
          r++;
        } else {
          l++;
        }
      } else {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
