#include <bits/stdc++.h>
namespace IPT {
const int L = 1 << 21;
char buf[L], *front = buf, *end = buf;
char GetChar() {
  if (front == end) end = buf + fread(front = buf, 1, L, stdin);
  return (front == end) ? -1 : *(front++);
}
template <typename T>
inline void qr(T &x) {
  char ch = GetChar(), lst = 0;
  x = 0;
  while (!isdigit(ch)) lst = ch, ch = GetChar();
  while (isdigit(ch)) x = x * 10 + (ch ^ 48), ch = GetChar();
  if (lst == '-') x = -x;
}
template <typename T>
void qra(T *const __ary, int __n) {
  for (int i = 0; i < __n; ++i) qr(__ary[i]);
}
template <typename T>
int qrs(T *p) {
  T *beg = p;
  do *p = GetChar();
  while (!isalnum(*p));
  do *(++p) = GetChar();
  while (isalnum(*p));
  *p = 0;
  return p - beg;
}
template <typename T>
void qrdb(T &x) {
  char ch = GetChar(), lst = 0;
  x = 0;
  while (!isdigit(ch)) lst = ch, ch = GetChar();
  while (isdigit(ch)) {
    x = x * 10 + (ch - '0');
    ch = GetChar();
  }
  if (ch == '.') {
    ch = GetChar();
    for (double t = 0.1; isdigit(ch); t *= 0.1) {
      x += (t * (ch - '0'));
      ch = GetChar();
    }
  }
  if (lst == '-') x = -x;
}
}  // namespace IPT
namespace OPT {
const int L = 30;
char buf[L];
template <typename T>
inline void qw(T x, const char aft = 0) {
  if (x < 0) {
    x = -x, putchar('-');
  }
  int top = 0;
  do {
    buf[++top] = static_cast<char>(x % 10 + '0');
  } while (x /= 10);
  while (top) putchar(buf[top--]);
  if (aft) putchar(aft);
}
template <typename T>
void qwa(T *const __ary, int __n, const char e1, const char e2) {
  int __dn = __n - 1;
  for (int i = 0; i < __dn; ++i) qw(__ary[i], e1);
  qw(__ary[__dn], e2);
}
template <typename T>
void qws(T *p, const int __n, const char ed) {
  for (int i = 0; i < __n; ++i) putchar(p[i]);
  if (ed) putchar(ed);
}
template <typename T>
void qws(T *p, const char ed) {
  while (*p) putchar(*p++);
  if (ed) putchar(ed);
}
}  // namespace OPT
using IPT::qr;
using IPT::qra;
using IPT::qrdb;
using IPT::qrs;
using OPT::qw;
using OPT::qwa;
using OPT::qws;
namespace Fusu {
void Main();
}
int main() {
  ;
  Fusu::Main();
  return 0;
}
namespace Fusu {
const int maxn = 8005;
int T;
int n;
int a[maxn], b[maxn];
void Main() {
  for (qr(T); T; --T) {
    qr(n);
    qra(a + 1, n);
    for (int i = 1; i <= n; ++i) ++b[a[i]];
    int ans = 0;
    for (int i = 1; i < n; ++i) {
      for (int j = i + 1, sum = a[i]; j <= n; ++j)
        if ((sum += a[j]) <= n) {
          if (b[sum]) {
            ans += b[sum];
            b[sum] = 0;
          }
        }
    }
    for (int i = 1; i <= n; ++i) b[i] = 0;
    qw(ans, '\n');
  }
}
}  // namespace Fusu
