#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedset;
#define MO2 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'
#define int long long
#define elif else if
#define sz(x) long(x.size())
#define all(vec) vec.begin(), vec.end()
const int mod = 1e9 + 7;
const int dx[] = {0, -1, 0, 1, 1, -1, 1, -1};
const int dy[] = {-1, 0, 1, 0, 1, 1, -1, -1};

int n, m;
void dope() {}

void solve() {
    int ans = 0;
    cin >> n;
    vector<int> vec(n);
    vector<bool> mp(n + 1);
    for (int i = 0; i < n;i++)
        cin >> vec[i];
    for (int i = 0; i < n; i++){
        int sum = 0;
        for (int j = i; j < n; j++) {
            sum += vec[j];
            if (sum>n) break;
            if (j >= i + 1)
                mp[sum] = true;
        }
    }
    for (auto&it:vec)
    if (mp[it])
        ans++;
    cout << ans;
}

signed main() {
    MO2
#if ONLINE_JUDGE || CPH
#else
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
    int nop = 1;  cin >> nop;
    while (nop--)
    {
        solve();
        if (nop)
            cout << endl;
    }
    return 0;
}