#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  short t;
  cin >> t;
  while (t--) {
    short n;
    cin >> n;
    unordered_map<short, short> ump;
    int sum = 0;
    short ai;
    vector<int> pref_sum(n + 1);
    pref_sum[0] = 0;
    for (short i = 1; i <= n; i++) {
      cin >> ai;
      ump[ai]++;
      sum += ai;
      pref_sum[i] = sum;
    }
    short c = 0;
    short j = 2;
    int num;
    for (short i = 0; i <= n; i++) {
      j = i + 2;
      while (j <= n && pref_sum[j] - pref_sum[i] <= n) {
        auto it = ump.find(pref_sum[j] - pref_sum[i]);
        if (it != ump.end()) {
          c += ump[pref_sum[j] - pref_sum[i]];
          ump.erase(it);
        }
        j++;
      }
    }
    cout << c << "\n";
  }
  return 0;
}
