#include <bits/stdc++.h>
using namespace std;
const int P = 998244353;
const int INF = 1e9;
const int N = 8005;
const double pi = acos(-1);
mt19937 rng(time(0));
int T, n, a[N], s[N];
bitset<N> st;
int main() {
  cin >> T;
  a[0] = s[0] = 0;
  while (T--) {
    st.reset();
    scanf("%d", &n);
    for (int i = (1); i <= (n); ++i) scanf("%d", a + i);
    for (int i = (1); i <= (n); ++i) s[i] = a[i] + s[i - 1];
    for (int i = (0); i <= (n); ++i)
      for (int j = (i + 2); j <= (n); ++j)
        if (s[j] - s[i] <= n) st[s[j] - s[i]] = 1;
    int ans = 0;
    for (int i = (1); i <= (n); ++i)
      if (st[a[i]]) ans++;
    cout << ans << endl;
  }
  return 0;
}
