#include <bits/stdc++.h>
using namespace std;
ifstream fin("AAtest.in.txt");
long long t, n, a[8005], jad[8005], pr[2][8005], l, r, mit;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    l = 0;
    r = 1;
    for (int j = 0; j <= n; j++) pr[l][j] = 0, jad[j] = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      for (int j = 0; j <= n; j++) pr[r][j] = 0;
      for (int j = n; j >= 0; j--)
        if (pr[l][j])
          if (j + a[i] <= n) jad[j + a[i]] = 1, pr[r][j + a[i]] = 1;
      pr[r][a[i]] = 1;
      swap(l, r);
    }
    mit = 0;
    for (int i = 0; i < n; i++)
      if (jad[a[i]]) mit++;
    cout << mit << "\n";
  }
}
