#include <bits/stdc++.h>
using namespace std;
const int N = 8001;
bool vis[N * N];
int a[N];
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    for (int i = 0; i <= n * n; ++i) vis[i] = 0;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    int s = 0;
    for (int i = 1; i <= n; ++i) {
      s = 0;
      for (int j = i; j <= n; ++j) {
        s += a[j];
        if (j - i + 1 >= 2) vis[s] = 1;
      }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
      if (vis[a[i]]) ans++;
    cout << ans << endl;
  }
  return 0;
}
