#include <bits/stdc++.h>
using namespace std;
const double PI = 4 * atan(1);
const long long INF = 1e18;
const int MX = 100001;
int t, n;
const int maxn = 8005;
int arr[maxn];
long long sm[maxn];
int valid[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> arr[i];
      sm[i] = sm[i - 1] + arr[i];
    }
    for (int i = 0; i < n; i++) {
      for (int j = i + 2; j <= n; j++) {
        int smm = sm[j] - sm[i];
        if (1 <= smm && smm <= n) {
          valid[smm] = 1;
        }
      }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
      if (valid[arr[i]]) ans++;
    cout << ans << "\n";
    for (int i = 1; i <= n; i++) sm[i] = arr[i] = valid[i] = 0;
  }
}
