#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  cin >> x;
}
template <typename T, typename T0>
void read(T &x, T0 &y) {
  cin >> x >> y;
}
template <typename T, typename T0, typename T1>
void read(T &x, T0 &y, T1 &z) {
  cin >> x >> y >> z;
}
bool isPowerOfTwo(int x) { return x && (!(x & (x - 1))); }
int digits(int n) {
  int x = floor(log10(n)) + 1;
  return x;
}
long long int fact(long long int n) {
  if (n == 0) return 1;
  return (n % 1000000007 * fact(n - 1) % 1000000007) % 1000000007;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
vector<bool> sieve(1000000, true);
void sieve_er() {
  sieve[0] = false;
  sieve[1] = false;
  for (long long int i = 2; i * i <= 1000000; i++) {
    if (sieve[i] == true) {
      for (long long int j = i * i; j < 1000000; j += i) sieve[j] = false;
    }
  }
}
vector<long long int> vec;
void divisors(long long int n) {
  for (long long int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        vec.push_back(i);
      else {
        vec.push_back(i);
        vec.push_back(n / i);
      }
    }
  }
}
long long int total_divisors(long long int n) {
  long long int c = 0;
  for (long long int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        c = c + 1;
      else
        c = c + 2;
    }
  }
  return c;
}
long long int nCr(long long int n, long long int r) {
  long long int ans = 1;
  for (int i = 0; i < r; i++) {
    ans *= (n - i) % 1000000007;
    ans /= (i + 1) % 1000000007;
    ans %= 1000000007;
  }
  return ans;
}
long long int power_m(long long int a, long long int b,
                      long long int m = 1000000007) {
  a %= m;
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long int power(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
long long int strTo(string s) {
  stringstream tmp(s);
  long long int x = 0;
  tmp >> x;
  return x;
}
string NoTo(long long int n) {
  ostringstream str1;
  str1 << n;
  string ans = str1.str();
  return ans;
}
int fun() { return 0; }
void start() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    int n;
    read(n);
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    if (n == 1)
      cout << "0" << endl;
    else {
      int c = 0, p = 0, q = 1, ct = 0, sum = a[0] + a[1];
      for (int i = 0; i < n; i++) {
        p = 0, q = 1;
        sum = a[p] + a[q];
        if (a[i] != 1) {
          while (q < (n - 1)) {
            if (sum == a[i]) {
              ct++;
              break;
            }
            if (sum < a[i]) {
              q++;
              sum += a[q];
            } else if (sum > a[i] && (q - p) > 1) {
              sum -= a[p];
              p++;
            } else if (sum > a[i] && (q - p) <= 1) {
              sum -= a[p];
              p++;
              q++;
              sum += a[q];
            }
            if (sum == a[i]) {
              ct++;
              break;
            }
          }
          if (ct != 0) {
            c++;
            ct = 0;
          } else {
            long long int st = a[n - 1];
            for (int k = n - 2; k >= 0; k--) {
              st += a[k];
              if (st == a[i]) {
                c++;
                break;
              }
            }
          }
        }
      }
      cout << c << endl;
    }
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
