#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int c = 0; c < t; c++) {
    int n;
    cin >> n;
    int pre[n + 1];
    pre[0] = 0;
    int a = 0, sum = 0, A = 0;
    map<int, int> m;
    map<int, int> mi;
    map<int, int>::iterator it;
    for (int i = 1; i <= n; i++) {
      cin >> a;
      m[a] = 0;
      mi[a]++;
      A = max(A, a);
      sum = sum + a;
      pre[i] = sum;
    }
    for (int i = 0; i <= n - 2; i++) {
      for (int j = i + 2; j <= n; j++) {
        sum = pre[j] - pre[i];
        if (sum > A) {
          break;
        }
        it = m.find(sum);
        if (it != m.end()) {
          it->second = (it->second) + 1;
        }
      }
    }
    int count = 0;
    for (auto x : m) {
      if (x.second > 0) {
        count = count + mi[x.first];
      }
    }
    cout << count << endl;
  }
  return 0;
}
