#include <bits/stdc++.h>
#define ll long long int
#define endl  "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

void rBuild(vector<ll>  &arr,vector<ll> &tree, ll l,ll r,ll treenode)
{
    if(l == r)
    {
        tree[treenode] = arr[l];
        return ;
    }
    int mid = (l+r) / 2;
    rBuild(arr,tree,l,mid,2*treenode);
    rBuild(arr,tree,mid+1,r,2*treenode+1);
    tree[treenode] = tree[2*treenode] + tree[2*treenode+1];
}

void update(vector <int> &tree,int l, int r,int diff,int ind)
{
    int curInd = 1;
    if(diff == 1)
        tree[curInd] += 1;
    else if(diff == 0)
    {
        if(tree[curInd] != 0)
            tree[curInd] -= 1;
    }

    while(l != r)
    {
        int mid = (l+r)/2;
        if (ind<=mid)
        {
            curInd *= 2;
            r = mid;
        }
        else
        {
            curInd = curInd * 2 + 1;
            l = mid+1;
        }

        if(diff == 1)
            tree[curInd] += 1;
        else if(diff == 0)
        {
            if(tree[curInd] != 0)
                tree[curInd] -= 1;
        }
    }
}

void rUpdate(vector <ll> &tree, ll st,ll end,ll ind,ll curNode)
{
    if(ind <st || ind  > end)
        return;

    tree[curNode] -= 1;
    if(st == end)
        return;

    ll mid = (st+end)/2;
    rUpdate(tree,st,mid,ind,2*curNode);
    rUpdate(tree,mid+1,end,ind,2*curNode+1);
}

int smRange(vector <ll> &arr,ll x,ll y)
{
    ll sm = 0;
    for(ll i=x;i<=y;i++)
    {
        sm += arr[i];
    }
    return  sm;
}

void rRangeSum(vector <ll> &tree,ll l,ll r,ll st,ll en,ll treenode,ll &sum)
{
    if(l<= st && en <= r)
    {
        sum += tree[treenode];
        return;
    }

    ll mid = (st+en)/2;
    if(mid >= l)
    {
        rRangeSum(tree,l,r,st,mid,2*treenode,sum);
    }

    if(r > mid)
    {
        rRangeSum(tree,l,r,mid+1,en,2*treenode + 1,sum);
    }
}

ll query(vector<ll> &tree, ll index, int s, int e, int qs, int qe)
{

    if ( qs > e || qe < s)
        return 0;

    if (qs <= s && qe >= e)
        return tree[index];

    int mid = (s + e)/2;
    return query(tree, 2*index, s, mid, qs, qe) + query(tree, 2*index+1, mid+1, e, qs, qe);

}

ll sumQuery(vector<ll> &tree, ll index, int s, int e, int qs, int qe, ll sum)
{

    if(tree[index] == sum)
        return -1*e -1;

    if(tree[index] < sum)
        return sum - tree[index];

    if(s == e  )
    {
        if(tree[index] - sum > 0)
            return  tree[index] - sum;
        else
            return  sum;
    }

    int mid = ( s + e ) / 2;
    sum = sumQuery(tree, 2*index, s, mid, qs, qe,sum);
    if(sum > 0)
        sum = sumQuery(tree, 2*index+1, mid+1, e, qs, qe,sum);
    return  sum;
}

ll fastExponential(ll b,ll p)
{
    ll res = 1;
    while(p > 0)
    {
        if(p & 1)
        {
            res = res*b;
        }
        b = b*b;
        p = p>>1;
    }
    return res;
}

ll ModularExponential(ll b,ll p,ll mod)
{
    if(p==0)
        return 1;
    if(p == 1)
        return  b%mod;

    ll res = 1;

    while(p > 1)
    {
        if(p & 1)
        {
            res = ((res%mod) * (b%mod))%mod;
            p--;
        }
        else {
            b = (b%mod * b%mod)%mod;
            p = p / 2;
        }
    }

    return ((b%mod)*(res%mod))%mod;
}

ll calcCommanPrefix(vector<string> &arr,int i,int j)
{
    ll sm = 0;
    ll st= i;
    ll en = j;
    ll ind = 0;
    char ch = arr[i][0];
    while(st<en)
    {
        if(ind >= arr[st].size())
            break;
        if(arr[st][ind] != ch)
            break;
        st++;
        if(st == en)
        {
            ind++;
            st = i;
            ch = arr[st][ind];
            sm++;
        }
    }
    return   sm;
}

ll calcBitDiff(ll x,ll y)
{
    ll sm = 0;
    ll st = 1;
    while(x>0 || y>0)
    {
        if((x&1) != (y&1))
            sm += st;
        st = st*2;
        x = x>>1;
        y = y>>1;
    }
    return  sm;
}

int main()
{
    //fast
    ll t;
    cin>>t;

    while(t--)
    {
        ll n,ans = 0;
        cin>>n;
        vector <ll> arr(n);
        for(ll i=0;i<n;i++)
            cin>>arr[i];

        ll mx = *max_element(arr.begin(),arr.end());

        bool dp[n+1];
        memset(dp,0, sizeof(dp));

        for(ll i=0;i<n-1;i++) {
            ll sm = arr[i];
            for (ll j = i + 1; j < n; j++) {
                sm += arr[j];
                if(sm>mx)
                    break;
                else
                    dp[sm] = 1;
            }
        }

        for(ll i=0;i<n;i++) ans += dp[arr[i]];
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
#define ll long long int
#define endl  "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

void rBuild(vector<ll>  &arr,vector<ll> &tree, ll l,ll r,ll treenode)
{
    if(l == r)
    {
        tree[treenode] = arr[l];
        return ;
    }
    int mid = (l+r) / 2;
    rBuild(arr,tree,l,mid,2*treenode);
    rBuild(arr,tree,mid+1,r,2*treenode+1);
    tree[treenode] = tree[2*treenode] + tree[2*treenode+1];
}

void update(vector <int> &tree,int l, int r,int diff,int ind)
{
    int curInd = 1;

    if(diff == 1)
        tree[curInd] += 1;
    else if(diff == 0)
    {
        if(tree[curInd] != 0)
            tree[curInd] -= 1;
    }

    while(l != r)
    {
        int mid = (l+r)/2;
        if (ind<=mid)
        {
            curInd *= 2;
            r = mid;
        }
        else
        {
            curInd = curInd * 2 + 1;
            l = mid+1;
        }

        if(diff == 1)
            tree[curInd] += 1;
        else if(diff == 0)
        {
            if(tree[curInd] != 0)
                tree[curInd] -= 1;
        }
    }
}

void rUpdate(vector <ll> &tree, ll st,ll end,ll ind,ll curNode)
{
    if(ind <st || ind  > end)
        return;

    tree[curNode] -= 1;
    if(st == end)
        return;

    ll mid = (st+end)/2;
    rUpdate(tree,st,mid,ind,2*curNode);
    rUpdate(tree,mid+1,end,ind,2*curNode+1);
}

int smRange(vector <ll> &arr,ll x,ll y)
{
    ll sm = 0;
    for(ll i=x;i<=y;i++)
    {
        sm += arr[i];
    }
    return  sm;
}

void rRangeSum(vector <ll> &tree,ll l,ll r,ll st,ll en,ll treenode,ll &sum)
{
    if(l<= st && en <= r)
    {
        sum += tree[treenode];
        return;
    }

    ll mid = (st+en)/2;
    if(mid >= l)
    {
        rRangeSum(tree,l,r,st,mid,2*treenode,sum);
    }

    if(r > mid)
    {
        rRangeSum(tree,l,r,mid+1,en,2*treenode + 1,sum);
    }
}

ll query(vector<ll> &tree, ll index, int s, int e, int qs, int qe)
{

    if ( qs > e || qe < s)
        return 0;

    if (qs <= s && qe >= e)
        return tree[index];

    int mid = (s + e)/2;
    return query(tree, 2*index, s, mid, qs, qe) + query(tree, 2*index+1, mid+1, e, qs, qe);

}

ll sumQuery(vector<ll> &tree, ll index, int s, int e, int qs, int qe, ll sum)
{

    if(tree[index] == sum)
        return -1*e -1;

    if(tree[index] < sum)
        return sum - tree[index];

    if(s == e  )
    {
        if(tree[index] - sum > 0)
            return  tree[index] - sum;
        else
            return  sum;
    }

    int mid = ( s + e ) / 2;
    sum = sumQuery(tree, 2*index, s, mid, qs, qe,sum);
    if(sum > 0)
        sum = sumQuery(tree, 2*index+1, mid+1, e, qs, qe,sum);
    return  sum;
}

ll fastExponential(ll b,ll p)
{
    ll res = 1;
    while(p > 0)
    {
        if(p & 1)
        {
            res = res*b;
        }
        b = b*b;
        p = p>>1;
    }
    return res;
}

ll ModularExponential(ll b,ll p,ll mod)
{
    if(p==0)
        return 1;
    if(p == 1)
        return  b%mod;

    ll res = 1;

    while(p > 1)
    {
        if(p & 1)
        {
            res = ((res%mod) * (b%mod))%mod;
            p--;
        }
        else {
            b = (b%mod * b%mod)%mod;
            p = p / 2;
        }
    }

    return ((b%mod)*(res%mod))%mod;
}

ll calcCommanPrefix(vector<string> &arr,int i,int j)
{
    ll sm = 0;
    ll st= i;
    ll en = j;
    ll ind = 0;
    char ch = arr[i][0];
    while(st<en)
    {
        if(ind >= arr[st].size())
            break;
        if(arr[st][ind] != ch)
            break;
        st++;
        if(st == en)
        {
            ind++;
            st = i;
            ch = arr[st][ind];
            sm++;
        }
    }
    return   sm;
}

ll calcBitDiff(ll x,ll y)
{
    ll sm = 0;
    ll st = 1;
    while(x>0 || y>0)
    {
        if((x&1) != (y&1))
            sm += st;
        st = st*2;
        x = x>>1;
        y = y>>1;
    }
    return  sm;
}

int main()
{
    fast
    ll t;
    cin>>t;

    while(t--)
    {
        int n,ans = 0;
        cin>>n;
        vector <int> arr(n);
        int mx = 0;
        for(int i=0;i<n;i++) {
            cin >> arr[i];
            mx = max((int)arr[i],mx);
        }

        bitset <8080> dp;

        for(int i=0;i<n-1;i++) {
            int sm = arr[i];
            for (int j = i + 1; j < n; j++) {
                sm += arr[j];
                if(sm>mx)
                    break;
                else
                    dp[sm] = 1;
            }
        }

        for(int i=0;i<n;i++) ans += dp[arr[i]];
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
#define ll long long int
#define endl  "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

void rBuild(vector<ll>  &arr,vector<ll> &tree, ll l,ll r,ll treenode)
{
    if(l == r)
    {
        tree[treenode] = arr[l];
        return ;
    }
    int mid = (l+r) / 2;
    rBuild(arr,tree,l,mid,2*treenode);
    rBuild(arr,tree,mid+1,r,2*treenode+1);
    tree[treenode] = tree[2*treenode] + tree[2*treenode+1];
}

void update(vector <int> &tree,int l, int r,int diff,int ind)
{
    int curInd = 1;
    if(diff == 1)
        tree[curInd] += 1;
    else if(diff == 0)
    {
        if(tree[curInd] != 0)
            tree[curInd] -= 1;
    }

    while(l != r)
    {
        int mid = (l+r)/2;
        if (ind<=mid)
        {
            curInd *= 2;
            r = mid;
        }
        else
        {
            curInd = curInd * 2 + 1;
            l = mid+1;
        }

        if(diff == 1)
            tree[curInd] += 1;
        else if(diff == 0)
        {
            if(tree[curInd] != 0)
                tree[curInd] -= 1;
        }
    }
}

void rUpdate(vector <ll> &tree, ll st,ll end,ll ind,ll curNode)
{
    if(ind <st || ind  > end)
        return;

    tree[curNode] -= 1;
    if(st == end)
        return;

    ll mid = (st+end)/2;
    rUpdate(tree,st,mid,ind,2*curNode);
    rUpdate(tree,mid+1,end,ind,2*curNode+1);
}

int smRange(vector <ll> &arr,ll x,ll y)
{
    ll sm = 0;
    for(ll i=x;i<=y;i++)
    {
        sm += arr[i];
    }
    return  sm;
}

void rRangeSum(vector <ll> &tree,ll l,ll r,ll st,ll en,ll treenode,ll &sum)
{
    if(l<= st && en <= r)
    {
        sum += tree[treenode];
        return;
    }

    ll mid = (st+en)/2;
    if(mid >= l)
    {
        rRangeSum(tree,l,r,st,mid,2*treenode,sum);
    }

    if(r > mid)
    {
        rRangeSum(tree,l,r,mid+1,en,2*treenode + 1,sum);
    }
}

ll query(vector<ll> &tree, ll index, int s, int e, int qs, int qe)
{

    if ( qs > e || qe < s)
        return 0;

    if (qs <= s && qe >= e)
        return tree[index];

    int mid = (s + e)/2;
    return query(tree, 2*index, s, mid, qs, qe) + query(tree, 2*index+1, mid+1, e, qs, qe);

}

ll sumQuery(vector<ll> &tree, ll index, int s, int e, int qs, int qe, ll sum)
{

    if(tree[index] == sum)
        return -1*e -1;

    if(tree[index] < sum)
        return sum - tree[index];

    if(s == e  )
    {
        if(tree[index] - sum > 0)
            return  tree[index] - sum;
        else
            return  sum;
    }

    int mid = ( s + e ) / 2;
    sum = sumQuery(tree, 2*index, s, mid, qs, qe,sum);
    if(sum > 0)
        sum = sumQuery(tree, 2*index+1, mid+1, e, qs, qe,sum);
    return  sum;
}

ll fastExponential(ll b,ll p)
{
    ll res = 1;
    while(p > 0)
    {
        if(p & 1)
        {
            res = res*b;
        }
        b = b*b;
        p = p>>1;
    }
    return res;
}

ll ModularExponential(ll b,ll p,ll mod)
{
    if(p==0)
        return 1;
    if(p == 1)
        return  b%mod;

    ll res = 1;

    while(p > 1)
    {
        if(p & 1)
        {
            res = ((res%mod) * (b%mod))%mod;
            p--;
        }
        else {
            b = (b%mod * b%mod)%mod;
            p = p / 2;
        }
    }

    return ((b%mod)*(res%mod))%mod;
}

ll calcCommanPrefix(vector<string> &arr,int i,int j)
{
    ll sm = 0;
    ll st= i;
    ll en = j;
    ll ind = 0;
    char ch = arr[i][0];
    while(st<en)
    {
        if(ind >= arr[st].size())
            break;
        if(arr[st][ind] != ch)
            break;
        st++;
        if(st == en)
        {
            ind++;
            st = i;
            ch = arr[st][ind];
            sm++;
        }
    }
    return   sm;
}

ll calcBitDiff(ll x,ll y)
{
    ll sm = 0;
    ll st = 1;
    while(x>0 || y>0)
    {
        if((x&1) != (y&1))
            sm += st;
        st = st*2;
        x = x>>1;
        y = y>>1;
    }
    return  sm;
}

int main()
{
    fast
    ll t;
    cin>>t;

    while(t--)
    {
        ll n,ans = 0;
        cin>>n;
        vector <ll> arr(n);
        ll mx = 0;
        for(ll i=0;i<n;i++) {
            cin >> arr[i];
            mx = max(arr[i],mx);
        }

        bitset <8080> dp;

        for(ll i=0;i<n-1;i++) {
            ll sm = arr[i];
            for (ll j = i + 1; j < n; j++) {
                sm += arr[j];
                if(sm>mx)
                    break;
                else
                    dp[sm] = 1;
            }
        }

        for(ll i=0;i<n;i++) ans += dp[arr[i]];
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
#define ll long long int
#define endl  "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

void rBuild(vector<ll>  &arr,vector<ll> &tree, ll l,ll r,ll treenode)
{
    if(l == r)
    {
        tree[treenode] = arr[l];
        return ;
    }
    int mid = (l+r) / 2;
    rBuild(arr,tree,l,mid,2*treenode);
    rBuild(arr,tree,mid+1,r,2*treenode+1);
    tree[treenode] = tree[2*treenode] + tree[2*treenode+1];
}

void update(vector <int> &tree,int l, int r,int diff,int ind)
{
    int curInd = 1;
    if(diff == 1)
        tree[curInd] += 1;
    else if(diff == 0)
    {
        if(tree[curInd] != 0)
            tree[curInd] -= 1;
    }

    while(l != r)
    {
        int mid = (l+r)/2;
        if (ind<=mid)
        {
            curInd *= 2;
            r = mid;
        }
        else
        {
            curInd = curInd * 2 + 1;
            l = mid+1;
        }

        if(diff == 1)
            tree[curInd] += 1;
        else if(diff == 0)
        {
            if(tree[curInd] != 0)
                tree[curInd] -= 1;
        }
    }
}

void rUpdate(vector <ll> &tree, ll st,ll end,ll ind,ll curNode)
{
    if(ind <st || ind  > end)
        return;

    tree[curNode] -= 1;
    if(st == end)
        return;

    ll mid = (st+end)/2;
    rUpdate(tree,st,mid,ind,2*curNode);
    rUpdate(tree,mid+1,end,ind,2*curNode+1);
}

int smRange(vector <ll> &arr,ll x,ll y)
{
    ll sm = 0;
    for(ll i=x;i<=y;i++)
    {
        sm += arr[i];
    }
    return  sm;
}

void rRangeSum(vector <ll> &tree,ll l,ll r,ll st,ll en,ll treenode,ll &sum)
{
    if(l<= st && en <= r)
    {
        sum += tree[treenode];
        return;
    }

    ll mid = (st+en)/2;
    if(mid >= l)
    {
        rRangeSum(tree,l,r,st,mid,2*treenode,sum);
    }

    if(r > mid)
    {
        rRangeSum(tree,l,r,mid+1,en,2*treenode + 1,sum);
    }
}

ll query(vector<ll> &tree, ll index, int s, int e, int qs, int qe)
{

    if ( qs > e || qe < s)
        return 0;

    if (qs <= s && qe >= e)
        return tree[index];

    int mid = (s + e)/2;
    return query(tree, 2*index, s, mid, qs, qe) + query(tree, 2*index+1, mid+1, e, qs, qe);

}

ll sumQuery(vector<ll> &tree, ll index, int s, int e, int qs, int qe, ll sum)
{

    if(tree[index] == sum)
        return -1*e -1;

    if(tree[index] < sum)
        return sum - tree[index];

    if(s == e  )
    {
        if(tree[index] - sum > 0)
            return  tree[index] - sum;
        else
            return  sum;
    }

    int mid = ( s + e ) / 2;
    sum = sumQuery(tree, 2*index, s, mid, qs, qe,sum);
    if(sum > 0)
        sum = sumQuery(tree, 2*index+1, mid+1, e, qs, qe,sum);
    return  sum;
}

ll fastExponential(ll b,ll p)
{
    ll res = 1;
    while(p > 0)
    {
        if(p & 1)
        {
            res = res*b;
        }
        b = b*b;
        p = p>>1;
    }
    return res;
}

ll ModularExponential(ll b,ll p,ll mod)
{
    if(p==0)
        return 1;
    if(p == 1)
        return  b%mod;

    ll res = 1;

    while(p > 1)
    {
        if(p & 1)
        {
            res = ((res%mod) * (b%mod))%mod;
            p--;
        }
        else {
            b = (b%mod * b%mod)%mod;
            p = p / 2;
        }
    }

    return ((b%mod)*(res%mod))%mod;
}

ll calcCommanPrefix(vector<string> &arr,int i,int j)
{
    ll sm = 0;
    ll st= i;
    ll en = j;
    ll ind = 0;
    char ch = arr[i][0];
    while(st<en)
    {
        if(ind >= arr[st].size())
            break;
        if(arr[st][ind] != ch)
            break;
        st++;
        if(st == en)
        {
            ind++;
            st = i;
            ch = arr[st][ind];
            sm++;
        }
    }
    return   sm;
}

ll calcBitDiff(ll x,ll y)
{
    ll sm = 0;
    ll st = 1;
    while(x>0 || y>0)
    {
        if((x&1) != (y&1))
            sm += st;
        st = st*2;
        x = x>>1;
        y = y>>1;
    }
    return  sm;
}

int main()
{
    fast
    int t;
    cin>>t;

    while(t--)
    {
        int n,ans = 0;
        cin>>n;
        vector <int> arr(n);
        int mx = 0;
        for(int i=0;i<n;i++) {
            cin >> arr[i];
            mx = max((int)arr[i],mx);
        }

        bool dp[n+1];
        memset(dp,0, sizeof(dp));

        for(int i=0;i<n-1;i++) {
            int sm = arr[i];
            for (int j = i + 1; j < n; j++) {
                sm += arr[j];
                if(sm>mx)
                    break;
                else
                    dp[sm] = 1;
            }
        }

        for(int i=0;i<n;i++) ans += dp[arr[i]];
        cout<<ans<<endl;
    }
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1, 0);
    unordered_map<int, int>times;
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        times[arr[i]]++;
    }
    unordered_map<int, int>m;
    m[0] = 1;
    for (int i = 1; i <= n; i++) {
        arr[i] += arr[i - 1];
        m[arr[i]] = i + 1;
    }
    int cnt = 0;
    for (auto i : times)
    {
        for (auto a : m)
        {
            if (m.find(a.first - i.first) != m.end()   && (m[a.first] - m[a.first - i.first ]) > 1 ) {
                cnt += i.second;
                break;
            }
        }
    }
    cout << cnt << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1, 0);
    // vector<int>ans;
    // vector<int>num;
    map<int, int>times;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        // if (times[arr[i]] == 0)
        //     num.pb(arr[i]);
        times[arr[i]]++;
    }
    // for (int a : num)
    //     cout << a << ' ';
    for (int i = 1; i <= n; i++)
        arr[i] += arr[i - 1];
    map<int, int>m;
    for (int i = 0; i <= n; i++) {
        // debug(a);
        m[arr[i]] = i + 1;
        // cout << arr[i] << '-' << m[arr[i]] << endl;
    }
    // cout << endl;
    // map<pair<int, int>, bool>tmp;
    // for (int a : num)
    //     debug(a);
    int cnt = 0;
    for (auto i : times)
    {
        for (auto a : m)
        {
            if (m[a.first - i.first] != 0  && (m[a.first] - m[a.first - i.first ]) > 1 ) {
                // && (m[a.first] - m[a.first - i ]) > 1 ) {
                // cout << m[i] << ' ' << m[a.first] << endl;
                // ans.pb(num[i]);
                cnt += i.second;
                break;
            }
        }
    }
    // for (int a : ans)
    //     debug(a);
    cout << cnt << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1, 0);
    // vector<int>ans;
    vector<int>num;
    map<int, int>times;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];

        if (times[arr[i]] == 0)
            num.pb(arr[i]);
        times[arr[i]]++;
    }
    // for (int a : num)
    //     cout << a << ' ';
    for (int i = 1; i <= n; i++)
        arr[i] += arr[i - 1];
    map<int, int>m;
    for (int i = 0; i <= n; i++) {
        // debug(a);
        m[arr[i]] = i + 1;
        // cout << arr[i] << '-' << m[arr[i]] << endl;
    }
    // cout << endl;
    // map<pair<int, int>, bool>tmp;
    // for (int a : num)
    //     debug(a);
    int cnt = 0;
    for (int i : num)
    {
        for (auto a : m)
        {
            if (m[a.first - i] != 0  && (m[a.first] - m[a.first - i ]) > 1 ) {
                // && (m[a.first] - m[a.first - i ]) > 1 ) {
                // cout << m[i] << ' ' << m[a.first] << endl;
                // ans.pb(num[i]);
                cnt += times[i];
                break;
            }
        }
    }
    // for (int a : ans)
    //     debug(a);
    cout << cnt << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1, 0);
    map<int, int>times;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        times[arr[i]]++;
    }
    map<int, int>m;
    m[0] = 1;
    for (int i = 1; i <= n; i++) {
        arr[i] += arr[i - 1];
        m[arr[i]] = i + 1;
    }
    int cnt = 0;
    for (auto i : times)
    {
        for (auto a : m)
        {
            if (m[a.first - i.first] != 0  && (m[a.first] - m[a.first - i.first ]) > 1 ) {
                cnt += i.second;
                break;
            }
        }
    }
    cout << cnt << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1, 0);
    map<int, int>times;
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        times[arr[i]]++;
    }
    map<int, int>m;
    m[0] = 1;
    for (int i = 1; i <= n; i++) {
        arr[i] += arr[i - 1];
        m[arr[i]] = i + 1;
    }
    int cnt = 0;
    for (auto i : times)
    {
        for (auto a : m)
        {
            if (m[a.first - i.first] != 0  && (m[a.first] - m[a.first - i.first ]) > 1 ) {
                cnt += i.second;
                break;
            }
        }
    }
    cout << cnt << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1);
    unordered_map<int, int>times;
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        times[arr[i]]++;
    }
    unordered_map<int, int>m;
    m[0] = 1;
    for (int i = 1; i <= n; i++) {
        arr[i] += arr[i - 1];
        m[arr[i]] = i + 1;
    }
    int cnt = 0;
    for (auto i : times)
    {
        for (auto a : m)
        {
            if (m.find(a.first - i.first) != m.end()  && (m[a.first] - m[a.first - i.first ]) > 1 ) {
                cnt += i.second;
                break;
            }
        }
    }
    cout << cnt << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1, 0);
    unordered_map<int, int>times;
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        times[arr[i]]++;
    }
    unordered_map<int, int>m;
    m[0] = 1;
    int pref = 0;
    for (int i = 1; i <= n; i++) {
        pref += arr[i];
        m[pref] = i + 1;
    }
    int cnt = 0;
    for (auto i : times)
    {
        for (auto a : m)
        {
            if (m.find(a.first - i.first) != m.end()  && (m[a.first] - m[a.first - i.first ]) > 1 ) {
                cnt += i.second;
                break;
            }
        }
    }
    cout << cnt  << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1);
    map<int, int>times;
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        times[arr[i]]++;
    }
    map<int, int>m;
    m[0] = 1;
    for (int i = 1; i <= n; i++) {
        arr[i] += arr[i - 1];
        m[arr[i]] = i + 1;
    }
    int cnt = 0;
    for (auto i : times)
    {
        for (auto a : m)
        {
            if (m.find(a.first - i.first) != m.end()  && (m[a.first] - m[a.first - i.first ]) > 1 ) {
                cnt += i.second;
                break;
            }
        }
    }
    cout << cnt << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1, 0);
    map<int, int>times;
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        times[arr[i]]++;
    }
    map<int, int>m;
    m[0] = 1;
    for (int i = 1; i <= n; i++) {
        arr[i] += arr[i - 1];
        m[arr[i]] = i + 1;
    }
    int cnt = 0;
    for (auto i : times)
    {
        for (auto a : m)
        {
            if (m.find(a.first - i.first) != m.end()   && (m[a.first] - m[a.first - i.first ]) > 1 ) {
                cnt += i.second;
                break;
            }
        }
    }
    cout << cnt << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1);
    map<int, int>times;
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        times[arr[i]]++;
    }
    map<int, int>m;
    m[0] = 1;
    for (int i = 1; i <= n; i++) {
        arr[i] += arr[i - 1];
        m[arr[i]] = i + 1;
    }
    int cnt = 0;
    for (auto i : times)
    {
        for (auto a : m)
        {
            if (m[a.first - i.first] != 0  && (m[a.first] - m[a.first - i.first ]) > 1 ) {
                cnt += i.second;
                break;
            }
        }
    }
    cout << cnt << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1, 0);
    map<int, int>times;
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        times[arr[i]]++;
    }
    map<int, int>m;
    m[0] = 1;
    for (int i = 1; i <= n; i++) {
        arr[i] += arr[i - 1];
        m[arr[i]] = i + 1;
    }
    int cnt = 0;
    for (auto i : times)
    {
        for (auto a : m)
        {
            if ((m.find(a.first - i.first) != m.end()   && (m[a.first] - m[a.first - i.first ]) > 1 ) {
                cnt += i.second;
                break;
            }
        }
    }
    cout << cnt << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1);
    unordered_map<int, int>times;
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        times[arr[i]]++;
    }
    unordered_map<int, int>m;
    m[0] = 1;
    for (int i = 1; i <= n; i++) {
        arr[i] += arr[i - 1];
        m[arr[i]] = i + 1;
    }
    int cnt = 0;
    for (auto i : times)
    {
        for (auto a : m)
        {
            if (m[a.first - i.first] != 0  && (m[a.first] - m[a.first - i.first ]) > 1 ) {
                cnt += i.second;
                break;
            }
        }
    }
    cout << cnt << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    unordered_map<int, int>m;
    m[0] = 1;
    int pref = 0;
    for (int i = 1; i <= n; i++) {
        pref += arr[i];
        m[pref] = i + 1;
    }
    int cnt = 0;
    for (auto i : arr)
    {
        if (i == 0)continue;
        for (auto a : m)
        {
            if (m.find(a.first - i) != m.end()  && (m[a.first] - m[a.first - i ]) > 1 ) {
                cnt ++;
                break;
            }
        }
    }
    cout << cnt  << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll 		long long
#define ld 		long double
#define vll 	vector<ll>
#define pll 	pair<ll,ll>
#define map 	map<ll,ll>
#define pqb 	priority_queue<ll>
#define pqs 	priority_queue<ll, vll.greater<ll> >
#define N 		1001
#define mod 	1e9+9
#define MAX 	1e9
#define test(t) ll t; cin>>t; while(t--)
#define fast 	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll subArraySum(int arr[], int n, int sum)
{
    map<int, int> map;
    int curr_sum = 0;

    for (int i = 0; i < n; i++)
    {
        if (curr_sum == sum)
        {
                 if((i-0)>=1)
            		return 1;
        }
        if (map.find(curr_sum - sum) != map.end())
        {

            if((i-(map[curr_sum-sum]+1))>=1)
            	return 1;
        }
        map[curr_sum] = i;
    }
    return 0;
}
int main(){
	fast;
	test(t)
	{
		ll n; cin>>n;
		ll a[n];
		map m; vector<ll> v;
		for( ll i=0 ; i<n ;i++) {
			cin>>a[i];

			if(m[a[i]]==0)
				v.push_back(a[i]);
			m[a[i]]++;
		}
		sort(v.begin(),v.end());
		ll l=0, r=n-1, ans=0;
		for(ll i=v.size()-1 ; i>=0; i--){
			//cout<<v[i]<<" "<<subArraySum(a,n,v[i])<<"    "<<m[v[i]]<<endl;
			if(subArraySum(a,n,v[i]))
				ans+= m[v[i]];
		}
		cout<<ans<<"\n";
	}
}


#include<bits/stdc++.h>
#include <stdint.h>
using namespace std;

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n; cin >> n;
    vector<int> arr(n + 1, 0);
    map<int, int>times;
    arr[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        times[arr[i]]++;// times is imp else we would get tle!
    }
    unordered_map<int, int>m;
    m[0] = 1;
    int pref = 0;
    for (int i = 1; i <= n; i++) {
        pref += arr[i];
        m[pref] = i + 1;
    }
    int cnt = 0;
    for (auto i : times)
    {
        for (auto a : m)
        {
            if (m.find(a.first - i.first) != m.end()  && (m[a.first] - m[a.first - i.first ]) > 1 ) {
                cnt += i.second;
                break;
            }
        }
    }
    cout << cnt  << endl;

}

int32_t main()
{
    fast();
    w(t)
    {
        mysol();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> a(n);
		vector<int> cnt(n + 1);
		int ans = 0;
		for (auto &it : a) {
			cin >> it;
			++cnt[it];
		}
		for (int l = 0; l < n; ++l) {
			int sum = 0;
			for (int r = l; r < n; ++r) {
				sum += a[r];
				if (l == r) continue;
				if (sum <= n) {
					ans += cnt[sum];
					cnt[sum] = 0;
				}
			}
		}
		cout << ans << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    //vector<int> s;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }
        int ps[n]={0};
        ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            ps[j]+=ps[j-1]+a[j];
            //cout<<ps[j]<<" ";
        }
        int sp=0;
        int s[9000]={0};
        int add=0;
        map<int,int> f;
        for(int p=0;p<n;++p)
        {
            f[a[p]]++;
        }
        map<int, int>::iterator itr;
        // for (itr = f.begin(); itr != f.end(); ++itr) {
        // cout << '\t' << itr->first
        //      << '\t' << itr->second << '\n';
        // }
        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(r-l<2)
                     {
                         continue;
                     }
                s[add]=(ps[r]-ps[l]);
                add+=1;
                // if(count(a,a+n,ps[r]-ps[l])>0)
                // {
                //     if(r-l<2)
                //     {
                //         continue;
                //     }
                //     sp+=count(a,a+n,ps[r]-ps[l]);
                //     replace(a,a+n,ps[r]-ps[l],100000);
                //     //cout<<sp<<" ";
                // }
            }
        }
        for(int j=1;j<n;++j)

        {
            s[add]=(ps[j]);
            add+=1;
        }
        for (itr = f.begin(); itr != f.end(); ++itr)
        {
            if(find(s,end(s),itr->first)!=end(s))
            sp+=itr->second;
        }

        cout<<sp<<endl;
        //s.clear();
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    vector<int> s;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }
        int ps[n]={0};
        ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            ps[j]+=ps[j-1]+a[j];
            //cout<<ps[j]<<" ";
        }
        int sp=0;
        //int s[9000]={0};
        int add=0;
        map<int,int> f;
        for(int p=0;p<n;++p)
        {
            f[a[p]]++;
        }
        map<int, int>::iterator itr;
        // for (itr = f.begin(); itr != f.end(); ++itr) {
        // cout << '\t' << itr->first
        //      << '\t' << itr->second << '\n';
        // }
        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(r-l<2)
                     {
                         continue;
                     }
                s.push_back(ps[r]-ps[l]);

                // if(count(a,a+n,ps[r]-ps[l])>0)
                // {
                //     if(r-l<2)
                //     {
                //         continue;
                //     }
                //     sp+=count(a,a+n,ps[r]-ps[l]);
                //     replace(a,a+n,ps[r]-ps[l],100000);
                //     //cout<<sp<<" ";
                // }
            }
        }
        for(int j=1;j<n;++j)

        {
            s.push_back(ps[j]);
        }
        for (itr = f.begin(); itr != f.end(); ++itr)
        {
            if(find(s.begin(),s.end(),itr->first)!=s.end())
            sp+=itr->second;
            //cout<<sp<<" ";
        }

        cout<<sp<<endl;
        s.clear();
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    //vector<int> s;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }
        map<int,int> f;
        for(int p=0;p<n;++p)
        {
            f[a[p]]++;
        }
        // int ps[n]={0};
        // ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            a[j]+=a[j-1];
            //cout<<ps[j]<<" ";
        }
        // for(int j=1;j<n;++j)

        // {
        //     s.push_back(a[j]);
        // }
        int sp=0;
        //int s[9000]={0};
        int add=0;

        map<int, int>::iterator itr;
        // for (itr = f.begin(); itr != f.end(); ++itr) {
        // cout << '\t' << itr->first
        //      << '\t' << itr->second << '\n';
        // }
        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(r-l<2)
                     {
                         continue;
                     }
                //s.push_back(a[r]-a[l]);

                if(f.count(a[r]-a[l])>0)
                {
                sp+=f[a[r]-a[l]];
                f[a[r]-a[l]]=0;
                }

                // if(count(a,a+n,ps[r]-ps[l])>0)
                // {
                //     if(r-l<2)
                //     {
                //         continue;
                //     }
                //     sp+=count(a,a+n,ps[r]-ps[l]);
                //     replace(a,a+n,ps[r]-ps[l],100000);
                //     //cout<<sp<<" ";
                // }
            }
        }

        // for (itr = f.begin(); itr != f.end(); ++itr)
        // {
        //     if(find(s.begin(),s.end(),itr->first)!=s.end())
        //     sp+=itr->second;
        //     //cout<<sp<<" ";
        // }
        // cout<<endl;
         for(int j=1;j<n;++j)
        {
            if(f.count(a[j])>0)
            {
                sp+=f[a[j]];
                //cout<<sp<<" ";
            }
        }

        cout<<sp<<endl;
        //s.clear();
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    vector<int> s;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }
        int ps[n]={0};
        ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            ps[j]+=ps[j-1]+a[j];
            //cout<<ps[j]<<" ";
        }
        int sp=0;
        //int s[9000]={0};
        int add=0;
        map<int,int> f;
        for(int p=0;p<n;++p)
        {
            f[a[p]]++;
        }
        map<int, int>::iterator itr;
        // for (itr = f.begin(); itr != f.end(); ++itr) {
        // cout << '\t' << itr->first
        //      << '\t' << itr->second << '\n';
        // }
        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(r-l<2)
                     {
                         continue;
                     }
                s.push_back(ps[r]-ps[l]);

                // if(count(a,a+n,ps[r]-ps[l])>0)
                // {
                //     if(r-l<2)
                //     {
                //         continue;
                //     }
                //     sp+=count(a,a+n,ps[r]-ps[l]);
                //     replace(a,a+n,ps[r]-ps[l],100000);
                //     //cout<<sp<<" ";
                // }
            }
        }
        for(int j=1;j<n;++j)

        {
            s.push_back(ps[j]);
        }
        for (itr = f.begin(); itr != f.end(); ++itr)
        {
            if(find(s.begin(),s.end(),itr->first)!=s.end())
            sp+=itr->second;
        }

        cout<<sp<<endl;
        //s.clear();
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    vector<int> s;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }

        map<int,int> f;
        for(int p=0;p<n;++p)
        {
            f[a[p]]++;
        }
        // int ps[n]={0};
        // ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            a[j]+=a[j-1];
            //cout<<ps[j]<<" ";
        }
        for(int j=1;j<n;++j)

        {
            s.push_back(a[j]);
        }
        int sp=0;
        //int s[9000]={0};
        int add=0;

        map<int, int>::iterator itr;
        // for (itr = f.begin(); itr != f.end(); ++itr) {
        // cout << '\t' << itr->first
        //      << '\t' << itr->second << '\n';
        // }
        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(r-l<2)
                     {
                         continue;
                     }
                s.push_back(a[r]-a[l]);

                // if(count(a,a+n,ps[r]-ps[l])>0)
                // {
                //     if(r-l<2)
                //     {
                //         continue;
                //     }
                //     sp+=count(a,a+n,ps[r]-ps[l]);
                //     replace(a,a+n,ps[r]-ps[l],100000);
                //     //cout<<sp<<" ";
                // }
            }
        }

        for (itr = f.begin(); itr != f.end(); ++itr)
        {
            if(find(s.begin(),s.end(),itr->first)!=s.end())
            sp+=itr->second;
            //cout<<sp<<" ";
        }

        cout<<sp<<endl;
        s.clear();
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    //vector<int> s;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }
        int ps[n]={0};
        ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            ps[j]+=ps[j-1]+a[j];
            //cout<<ps[j]<<" ";
        }
        int sp=0;
        int s[8001]={0};
        int add=0;
        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(r-l<2)
                     {
                         continue;
                     }
                if(count(s,end(s),ps[r]-ps[l])==0)
                {
                s[add]=(ps[r]-ps[l]);
                add+=1;
                }
                // if(count(a,a+n,ps[r]-ps[l])>0)
                // {
                //     if(r-l<2)
                //     {
                //         continue;
                //     }
                //     sp+=count(a,a+n,ps[r]-ps[l]);
                //     replace(a,a+n,ps[r]-ps[l],100000);
                //     //cout<<sp<<" ";
                // }
            }
        }
        for(int j=1;j<n;++j)

        {
            if(find(s,end(s),ps[j])==end(s))
            {
            s[add]=(ps[j]);
            add+=1;
            }
        }
        for(int j=0;j<n;++j)
        {
            if(find(s,end(s),a[j])!=end(s))
            sp+=1;
        }

        cout<<sp<<endl;
        //s.clear();
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }
        int ps[n]={0};
        ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            ps[j]+=ps[j-1]+a[j];
            //cout<<ps[j]<<" ";
        }
        int sp=0;
        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(count(a,a+n,ps[r]-ps[l])>0)
                {
                    if(r-l<2)
                    {
                        continue;
                    }
                    sp+=count(a,a+n,ps[r]-ps[l]);
                    replace(a,a+n,ps[r]-ps[l],100000);
                    //cout<<sp<<" ";
                }
            }
        }
        for(int j=1;j<n;++j)
        {
            if(count(a,a+n,ps[j]>0))
            {
                sp+=count(a,a+n,ps[j]);
                replace(a,a+n,ps[j],100000);
            }
        }
        cout<<sp<<endl;
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }
        int ps[n]={0};
        ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            ps[j]+=ps[j-1]+a[j];
            //cout<<ps[j]<<" ";
        }
        int sp=0;
        set<int> s;
        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(r-l<2)
                     {
                         continue;
                     }
                s.insert(ps[r]-ps[l]);
                // if(count(a,a+n,ps[r]-ps[l])>0)
                // {
                //     if(r-l<2)
                //     {
                //         continue;
                //     }
                //     sp+=count(a,a+n,ps[r]-ps[l]);
                //     replace(a,a+n,ps[r]-ps[l],100000);
                //     //cout<<sp<<" ";
                // }
            }
        }
        for(int j=1;j<n;++j)
        {
            s.insert(ps[j]);
        }
        for(int j=0;j<n;++j)
        {
            if(s.find(a[j])!=s.end())
            sp+=1;
        }

        cout<<sp<<endl;
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    vector<int> s;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }
        int ps[n]={0};
        ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            ps[j]+=ps[j-1]+a[j];
            //cout<<ps[j]<<" ";
        }
        int sp=0;

        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(r-l<2)
                     {
                         continue;
                     }
                if(find(s.begin(),s.end(),ps[r]-ps[l])==s.end())
                s.push_back(ps[r]-ps[l]);
                // if(count(a,a+n,ps[r]-ps[l])>0)
                // {
                //     if(r-l<2)
                //     {
                //         continue;
                //     }
                //     sp+=count(a,a+n,ps[r]-ps[l]);
                //     replace(a,a+n,ps[r]-ps[l],100000);
                //     //cout<<sp<<" ";
                // }
            }
        }
        for(int j=1;j<n;++j)

        {
            if(find(s.begin(),s.end(),ps[j])==s.end())
            s.push_back(ps[j]);
        }
        for(int j=0;j<n;++j)
        {
            if(find(s.begin(),s.end(),a[j])!=s.end())
            sp+=1;
        }

        cout<<sp<<endl;
        s.clear();
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    //vector<int> s;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }
        map<int,int> f;
        for(int p=0;p<n;++p)
        {
            if(a[p]>1)
            f[a[p]]++;
        }
        // int ps[n]={0};
        // ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            a[j]+=a[j-1];
            //cout<<ps[j]<<" ";
        }
        // for(int j=1;j<n;++j)

        // {
        //     s.push_back(a[j]);
        // }
        int sp=0;
        //int s[9000]={0};
        int add=0;

        map<int, int>::iterator itr;
        // for (itr = f.begin(); itr != f.end(); ++itr) {
        // cout << '\t' << itr->first
        //      << '\t' << itr->second << '\n';
        // }
        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(r-l<2)
                     {
                         continue;
                     }
                //s.push_back(a[r]-a[l]);

                if(f.count(a[r]-a[l])>0)
                {
                sp+=f[a[r]-a[l]];
                f[a[r]-a[l]]=0;
                }

                // if(count(a,a+n,ps[r]-ps[l])>0)
                // {
                //     if(r-l<2)
                //     {
                //         continue;
                //     }
                //     sp+=count(a,a+n,ps[r]-ps[l]);
                //     replace(a,a+n,ps[r]-ps[l],100000);
                //     //cout<<sp<<" ";
                // }
            }
        }

        // for (itr = f.begin(); itr != f.end(); ++itr)
        // {
        //     if(find(s.begin(),s.end(),itr->first)!=s.end())
        //     sp+=itr->second;
        //     //cout<<sp<<" ";
        // }
        // cout<<endl;
         for(int j=1;j<n;++j)
        {
            if(f.count(a[j])>0)
            {
                sp+=f[a[j]];
                //cout<<sp<<" ";
            }
        }

        cout<<sp<<endl;
        //s.clear();
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    //vector<int> s;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }
        int ps[n]={0};
        ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            ps[j]+=ps[j-1]+a[j];
            //cout<<ps[j]<<" ";
        }
        int sp=0;
        int s[9000]={0};
        int add=0;
        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(r-l<2)
                     {
                         continue;
                     }
                s[add]=(ps[r]-ps[l]);
                add+=1;
                // if(count(a,a+n,ps[r]-ps[l])>0)
                // {
                //     if(r-l<2)
                //     {
                //         continue;
                //     }
                //     sp+=count(a,a+n,ps[r]-ps[l]);
                //     replace(a,a+n,ps[r]-ps[l],100000);
                //     //cout<<sp<<" ";
                // }
            }
        }
        for(int j=1;j<n;++j)

        {
            s[add]=(ps[j]);
            add+=1;
        }
        for(int j=0;j<n;++j)
        {
            if(find(s,end(s),a[j])!=end(s))
            sp+=1;
        }

        cout<<sp<<endl;
        //s.clear();
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    vector<int> s;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }
        int ps[n]={0};
        ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            ps[j]+=ps[j-1]+a[j];
            //cout<<ps[j]<<" ";
        }
        int sp=0;

        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(r-l<2)
                     {
                         continue;
                     }
                s.push_back(ps[r]-ps[l]);
                // if(count(a,a+n,ps[r]-ps[l])>0)
                // {
                //     if(r-l<2)
                //     {
                //         continue;
                //     }
                //     sp+=count(a,a+n,ps[r]-ps[l]);
                //     replace(a,a+n,ps[r]-ps[l],100000);
                //     //cout<<sp<<" ";
                // }
            }
        }
        for(int j=1;j<n;++j)
        {
            s.push_back(ps[j]);
        }
        for(int j=0;j<n;++j)
        {
            if(find(s.begin(),s.end(),a[j])!=s.end())
            sp+=1;
        }

        cout<<sp<<endl;
        s.clear();
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int test;
    cin>>test;
    for(int i=0;i<test;++i)
    {
        int n;
        cin>>n;
        int a[n];
        for(int j=0;j<n;++j)
        {
            cin>>a[j];
        }
        int ps[n]={0};
        ps[0]=a[0];
        for(int j=1;j<n;++j)
        {
            ps[j]+=ps[j-1]+a[j];
            //cout<<ps[j]<<" ";
        }
        int sp=0;
        for(int l=0;l<n-1;++l)
        {
            for(int r=n-1;r>l;--r)
            {
                if(count(a,a+n,ps[r]-ps[l])>0)
                {
                    if(r-l<2)
                    {
                        continue;
                    }
                    sp+=count(a,a+n,ps[r]-ps[l]);
                    replace(a,a+n,ps[r]-ps[l],100000);
                    //cout<<sp<<" ";
                }
            }
        }
        for(int j=1;j<n;++j)
        {
            if(count(a,a+n,ps[j])>0)
            {
                sp+=count(a,a+n,ps[j]);
                replace(a,a+n,ps[j],100000);
            }
        }
        cout<<sp<<endl;
        // for(int j=0;j<n;++j)
        // {
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef unsigned short int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n, count = 0;
		cin >> n;
		ll freq[n + 1] = {0};
		set<ll> s, s1;
		ll a[n];
		int pre[n];
		for (ll i = 0; i < n; i++) {
			cin >> a[i];
			freq[a[i]]++;
			s1.insert(a[i]);
		}
		pre[0] = a[0];
		for (ll i = 0; i < n - 1; i++) {
			pre[i + 1] = pre[i] + a[i + 1];
			// if(pre[i+1]<=n)
			s.insert(pre[i + 1]);
			// debug2(pre[i + 1], i + 1);
		}
		for (ll i = 1; i < n; i++) {
			for (ll j = i - 1; j >= 1; j--) {
				if (pre[i] - pre[j - 1] > n) {
					break;
				}
				s.insert(pre[i] - pre[j - 1]);
			}
		}
		for (auto it = s1.begin(); it != s1.end(); it++) {
			if (s.find(*it) != s.end()) {
				count += freq[*it];
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef unsigned short int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n, count = 0;
		cin >> n;
		set<ll> s;
		ll a[n], pre[n];
		for (ll i = 0; i < n; i++) {
			cin >> a[i];
		}
		pre[0] = a[0];
		for (ll i = 0; i < n - 1; i++) {
			pre[i + 1] = pre[i] + a[i + 1];
			s.insert(pre[i + 1]);
			// debug2(pre[i + 1], i + 1);
		}
		for (ll i = 1; i < n; i++) {
			for (ll j = 1; j < i; j++) {
				s.insert(pre[i] - pre[j - 1]);
			}
		}
		for (ll i = 0; i < n; i++) {
			if (s.find(a[i]) != s.end()) {
				count++;
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef unsigned short int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n, count = 0;
		cin >> n;
		ll freq[n + 1] = {0};
		set<ll> s, s1;
		ll a[n];
		int pre[n];
		cin >> a[0];
		pre[0] = a[0];
		for (ll i = 1; i < n ; i++) {
			cin >> a[i];
			freq[a[i]]++;
			s1.insert(a[i]);
			pre[i] = pre[i - 1] + a[i];
			if (pre[i] <= n)
				s.insert(pre[i]);
			// debug2(pre[i + 1], i + 1);
		}
		for (ll i = 1; i < n; i++) {
			for (ll j = i - 1; j >= 1; j--) {
				if (pre[i] - pre[j - 1] > n) {
					break;
				}
				s.insert(pre[i] - pre[j - 1]);
			}
		}
		for (auto it = s1.begin(); it != s1.end(); it++) {
			if (s.find(*it) != s.end()) {
				count += freq[*it];
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef unsigned short int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n, count = 0;
		cin >> n;
		ll freq[n + 1] = {0};
		set<ll> s, s1;
		ll a[n], pre[n];
		for (ll i = 0; i < n; i++) {
			cin >> a[i];
			freq[a[i]]++;
			s1.insert(a[i]);
		}
		pre[0] = a[0];
		for (ll i = 0; i < n - 1; i++) {
			pre[i + 1] = pre[i] + a[i + 1];
			s.insert(pre[i + 1]);
			// debug2(pre[i + 1], i + 1);
		}
		for (ll i = 1; i < n; i++) {
			for (ll j = i - 1; j >= 1; j--) {
				if (pre[i] - pre[j - 1] > n) {
					break;
				}
				s.insert(pre[i] - pre[j - 1]);
			}
		}
		for (auto it = s1.begin(); it != s1.end(); it++) {
			if (s.find(*it) != s.end()) {
				count += freq[*it];
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef unsigned short int ll;
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
typedef pair<pair<int, int>, int> ppp;
#define X first
#define Y second
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define frv(i,a,b) for (ll i = (a), _b = (b); i < _b; i++)
#define frrv(i,b,a) for (ll i = (a), _b = (b); i >= _b; i--)
#define fr(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define frr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fordata(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) fr(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) fr(i,sizeof(ar)/sizeof(ar[0])) fr(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define all(ar) ar.begin(), ar.end()
#define INF 1000000000000000000
#define PI 3.14159265358979323846L
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
// const ll mod = 1e9 + 7;
// ll hashstr(string a) {
// 	ll sum = 0;
// 	ll pow_p = 1;
// 	fr(i, sz(a)) {
// 		sum += ((a[i] - 'a' + 1) * pow_p) % mod;
// 		pow_p = (pow_p * 31) % mod;
// 		sum %= mod;
// 	}
// 	sum %= mod;
// 	return sum;
// }
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		multiset<ll> s1;
		ll a[n], pre[n] = {0};
		fr(i, n) {
			cin >> a[i];
			s1.insert(a[i]);
			pre[i] = (i > 0 ? pre[i - 1] : 0) + a[i];
			// debug(pre[i]);
		}
		set<ll> s;
		fr(i, n) {
			frv(j, i, n) {
				if (j > i)
					s.insert(pre[j] - (i > 0 ? pre[i - 1] : 0));
			}
		}
		ll count = 0;
		fordata(it, s1) {
			if (s.find(*it) != s.end()) {
				count++;
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef unsigned short int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
int main() {
	fastIO;
	ll t;
	cin >> t;
	while (t--) {
		ll n, count = 0;
		cin >> n;
		set<ll> s;
		ll a[n], pre[n];
		for (ll i = 0; i < n; i++) {
			cin >> a[i];
		}
		pre[0] = a[0];
		for (ll i = 0; i < n - 1; i++) {
			pre[i + 1] = pre[i] + a[i + 1];
			s.insert(pre[i + 1]);
			// debug2(pre[i + 1], i + 1);
		}
		for (ll i = 1; i < n; i++) {
			for (ll j = i - 1; j >= 1; j--) {
				if (pre[i] - pre[j - 1] > n) {
					break;
				}
				s.insert(pre[i] - pre[j - 1]);
			}
		}
		for (ll i = 0; i < n; i++) {
			if (s.find(a[i]) != s.end()) {
				count++;
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef unsigned short int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n, count = 0;
		ll freq[n] = {0};
		cin >> n;
		set<ll> s, s1;
		ll a[n], pre[n];
		for (ll i = 0; i < n; i++) {
			cin >> a[i];
			freq[a[i]]++;
			s1.insert(a[i]);
		}
		pre[0] = a[0];
		for (ll i = 0; i < n - 1; i++) {
			pre[i + 1] = pre[i] + a[i + 1];
			s.insert(pre[i + 1]);
			// debug2(pre[i + 1], i + 1);
		}
		for (ll i = 1; i < n; i++) {
			for (ll j = i - 1; j >= 1; j--) {
				if (pre[i] - pre[j - 1] > n) {
					break;
				}
				s.insert(pre[i] - pre[j - 1]);
			}
		}
		for (auto it = s1.begin(); it != s1.end(); it++) {
			if (s.find(*it) != s.end()) {
				count += freq[*it];
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int N = 1e6 + 1;
const ll K = 1e9 + 7;
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n, count = 0;
		cin >> n;
		set<ll> s;
		ll a[n], pre[n];
		for (ll i = 0; i < n; i++) {
			cin >> a[i];
		}
		pre[0] = a[0];
		for (ll i = 0; i < n - 1; i++) {
			pre[i + 1] = pre[i] + a[i + 1];
			s.insert(pre[i + 1]);
			// debug2(pre[i + 1], i + 1);
		}
		for (ll i = 1; i < n; i++) {
			for (ll j = 1; j < i; j++) {
				s.insert(pre[i] - pre[j - 1]);
			}
		}
		for (ll i = 0; i < n; i++) {
			if (s.find(a[i]) != s.end()) {
				count++;
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef unsigned short int ll;
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
typedef pair<pair<int, int>, int> ppp;
#define X first
#define Y second
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define frv(i,a,b) for (ll i = (a), _b = (b); i < _b; i++)
#define frrv(i,b,a) for (ll i = (a), _b = (b); i >= _b; i--)
#define fr(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define frr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fordata(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) fr(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) fr(i,sizeof(ar)/sizeof(ar[0])) fr(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define all(ar) ar.begin(), ar.end()
#define INF 1000000000000000000
#define PI 3.14159265358979323846L
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
// const ll mod = 1e9 + 7;
// ll hashstr(string a) {
// 	ll sum = 0;
// 	ll pow_p = 1;
// 	fr(i, sz(a)) {
// 		sum += ((a[i] - 'a' + 1) * pow_p) % mod;
// 		pow_p = (pow_p * 31) % mod;
// 		sum %= mod;
// 	}
// 	sum %= mod;
// 	return sum;
// }
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		multiset<ll> s1;
		ll a[n], pre[n] = {0};
		fr(i, n) {
			cin >> a[i];
			s1.insert(a[i]);
			pre[i] = (i > 0 ? pre[i - 1] : 0) + a[i];
			// debug(pre[i]);
		}
		set<ll> s;
		fr(i, n) {
			for (short int j = i - 1; j >= 0; j--) {
				if (pre[i] - (j > 0 ? pre[j - 1] : 0) <= n)
					s.insert(pre[i] - (j > 0 ? pre[j - 1] : 0));
				else break;
			}
		}
		ll count = 0;
		fordata(it, s1) {
			if (s.find(*it) != s.end()) {
				count++;
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef short int ll;
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
typedef pair<pair<int, int>, int> ppp;
#define X first
#define Y second
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define frv(i,a,b) for (ll i = (a), _b = (b); i < _b; i++)
#define frrv(i,b,a) for (ll i = (a), _b = (b); i >= _b; i--)
#define fr(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define frr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fordata(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) fr(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) fr(i,sizeof(ar)/sizeof(ar[0])) fr(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define all(ar) ar.begin(), ar.end()
#define INF 1000000000000000000
#define PI 3.14159265358979323846L
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
// const ll mod = 1e9 + 7;
// ll hashstr(string a) {
// 	ll sum = 0;
// 	ll pow_p = 1;
// 	fr(i, sz(a)) {
// 		sum += ((a[i] - 'a' + 1) * pow_p) % mod;
// 		pow_p = (pow_p * 31) % mod;
// 		sum %= mod;
// 	}
// 	sum %= mod;
// 	return sum;
// }
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		multiset<ll> s1;
		ll a[n];
		long long int pre[n] = {0};
		fr(i, n) {
			cin >> a[i];
			s1.insert(a[i]);
			pre[i] = (i > 0 ? pre[i - 1] : 0) + a[i];
			// debug(pre[i]);
		}
		ll maxi = *s1.rbegin();
		set<ll> s;
		fr(i, n) {
			for (ll j = i - 1; j >= 0; j--) {
				if (pre[i] - (j > 0 ? pre[j - 1] : 0) <= maxi)
					s.insert(pre[i] - (j > 0 ? pre[j - 1] : 0));
				else break;
			}
		}
		ll count = 0;
		fordata(it, s1) {
			if (s.find(*it) != s.end()) {
				count++;
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef short int ll;
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
typedef pair<pair<int, int>, int> ppp;
#define X first
#define Y second
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define frv(i,a,b) for (ll i = (a), _b = (b); i < _b; i++)
#define frrv(i,b,a) for (ll i = (a), _b = (b); i >= _b; i--)
#define fr(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define frr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fordata(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) fr(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) fr(i,sizeof(ar)/sizeof(ar[0])) fr(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define all(ar) ar.begin(), ar.end()
#define INF 1000000000000000000
#define PI 3.14159265358979323846L
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
// const ll mod = 1e9 + 7;
// ll hashstr(string a) {
// 	ll sum = 0;
// 	ll pow_p = 1;
// 	fr(i, sz(a)) {
// 		sum += ((a[i] - 'a' + 1) * pow_p) % mod;
// 		pow_p = (pow_p * 31) % mod;
// 		sum %= mod;
// 	}
// 	sum %= mod;
// 	return sum;
// }
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		multiset<ll> s1;
		ll a[n];
		long long int pre[n] = {0};
		fr(i, n) {
			cin >> a[i];
			s1.insert(a[i]);
			pre[i] = (i > 0 ? pre[i - 1] : 0) + a[i];
			// debug(pre[i]);
		}
		ll maxi = *s1.rbegin(), count = 0;
		fr(i, n) {
			for (ll j = i - 1; j >= 0; j--) {
				if (pre[i] - (j > 0 ? pre[j - 1] : 0) <= maxi) {
					if (s1.find(pre[i] - (j > 0 ? pre[j - 1] : 0)) != s1.end())
						count++;
				}
				else break;
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef short int ll;
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
typedef pair<pair<int, int>, int> ppp;
#define X first
#define Y second
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define frv(i,a,b) for (ll i = (a), _b = (b); i < _b; i++)
#define frrv(i,b,a) for (ll i = (a), _b = (b); i >= _b; i--)
#define fr(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define frr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fordata(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) fr(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) fr(i,sizeof(ar)/sizeof(ar[0])) fr(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define all(ar) ar.begin(), ar.end()
#define INF 1000000000000000000
#define PI 3.14159265358979323846L
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
// const ll mod = 1e9 + 7;
// ll hashstr(string a) {
// 	ll sum = 0;
// 	ll pow_p = 1;
// 	fr(i, sz(a)) {
// 		sum += ((a[i] - 'a' + 1) * pow_p) % mod;
// 		pow_p = (pow_p * 31) % mod;
// 		sum %= mod;
// 	}
// 	sum %= mod;
// 	return sum;
// }
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		multiset<ll> s1;
		ll a[n];
		long long int pre[n] = {0}, cnt[n + 1] = {0};
		fr(i, n) {
			cin >> a[i];
			cnt[a[i]]++;
			s1.insert(a[i]);
			pre[i] = (i > 0 ? pre[i - 1] : 0) + a[i];
			// debug(pre[i]);
		}
		ll maxi = *s1.rbegin();
		ll ans = 0;
		fr(i, n) {
			for (ll j = i - 1; j >= 0; j--) {
				if (pre[i] - (j > 0 ? pre[j - 1] : 0) <= maxi)
				{	ans += cnt[pre[i] - (j > 0 ? pre[j - 1] : 0)];
					cnt[pre[i] - (j > 0 ? pre[j - 1] : 0)] = 0;
				}
				else break;
			}
		}
		cout << ans << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef short int ll;
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
typedef pair<pair<int, int>, int> ppp;
#define X first
#define Y second
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define frv(i,a,b) for (ll i = (a), _b = (b); i < _b; i++)
#define frrv(i,b,a) for (ll i = (a), _b = (b); i >= _b; i--)
#define fr(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define frr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fordata(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) fr(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) fr(i,sizeof(ar)/sizeof(ar[0])) fr(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define all(ar) ar.begin(), ar.end()
#define INF 1000000000000000000
#define PI 3.14159265358979323846L
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
// const ll mod = 1e9 + 7;
// ll hashstr(string a) {
// 	ll sum = 0;
// 	ll pow_p = 1;
// 	fr(i, sz(a)) {
// 		sum += ((a[i] - 'a' + 1) * pow_p) % mod;
// 		pow_p = (pow_p * 31) % mod;
// 		sum %= mod;
// 	}
// 	sum %= mod;
// 	return sum;
// }
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		multiset<ll> s1;
		ll a[n];
		long long int pre[n] = {0};
		fr(i, n) {
			cin >> a[i];
			s1.insert(a[i]);
			pre[i] = (i > 0 ? pre[i - 1] : 0) + a[i];
			// debug(pre[i]);
		}
		set<ll> s;
		fr(i, n) {
			for (ll j = i - 1; j >= 0; j--) {
				if (pre[i] - (j > 0 ? pre[j - 1] : 0) <= n)
					s.insert(pre[i] - (j > 0 ? pre[j - 1] : 0));
				else break;
			}
		}
		ll count = 0;
		fordata(it, s1) {
			if (s.find(*it) != s.end()) {
				count++;
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef unsigned short int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n, count = 0;
		cin >> n;
		ll freq[n] = {0};
		set<ll> s, s1;
		ll a[n], pre[n];
		for (ll i = 0; i < n; i++) {
			cin >> a[i];
			freq[a[i]]++;
			s1.insert(a[i]);
		}
		pre[0] = a[0];
		for (ll i = 0; i < n - 1; i++) {
			pre[i + 1] = pre[i] + a[i + 1];
			s.insert(pre[i + 1]);
			// debug2(pre[i + 1], i + 1);
		}
		for (ll i = 1; i < n; i++) {
			for (ll j = i - 1; j >= 1; j--) {
				if (pre[i] - pre[j - 1] > n) {
					break;
				}
				s.insert(pre[i] - pre[j - 1]);
			}
		}
		for (auto it = s1.begin(); it != s1.end(); it++) {
			if (s.find(*it) != s.end()) {
				count += freq[*it];
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef unsigned short int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n, count = 0;
		cin >> n;
		ll freq[n + 1] = {0};
		set<ll> s, s1;
		ll a[n];
		int pre[n];
		for (ll i = 0; i < n; i++) {
			cin >> a[i];
			freq[a[i]]++;
			s1.insert(a[i]);
		}
		pre[0] = a[0];
		for (ll i = 0; i < n - 1; i++) {
			pre[i + 1] = pre[i] + a[i + 1];
			if(pre[i+1]<=n)
			s.insert(pre[i + 1]);
			// debug2(pre[i + 1], i + 1);
		}
		for (ll i = 1; i < n; i++) {
			for (ll j = i - 1; j >= 1; j--) {
				if (pre[i] - pre[j - 1] > n) {
					break;
				}
				s.insert(pre[i] - pre[j - 1]);
			}
		}
		for (auto it = s1.begin(); it != s1.end(); it++) {
			if (s.find(*it) != s.end()) {
				count += freq[*it];
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef unsigned short int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n, count = 0;
		cin >> n;
		ll freq[n + 1] = {0};
		set<ll> s, s1;
		ll a[n];
		int pre[n];
		for (ll i = 0; i < n; i++) {
			cin >> a[i];
			freq[a[i]]++;
			s1.insert(a[i]);
		}
		pre[0] = a[0];
		for (ll i = 0; i < n - 1; i++) {
			pre[i + 1] = pre[i] + a[i + 1];
			s.insert(pre[i + 1]);
			// debug2(pre[i + 1], i + 1);
		}
		for (ll i = 1; i < n; i++) {
			for (ll j = i - 1; j >= 1; j--) {
				if (pre[i] - pre[j - 1] > n) {
					break;
				}
				s.insert(pre[i] - pre[j - 1]);
			}
		}
		for (auto it = s1.begin(); it != s1.end(); it++) {
			if (s.find(*it) != s.end()) {
				count += freq[*it];
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef unsigned short int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n, count = 0;
		cin >> n;
		ll freq[n + 1] = {0};
		set<ll> s, s1;
		ll a[n];
		int pre[n];
		cin >> a[0];
		freq[a[0]]++;
		pre[0] = a[0];
		for (ll i = 1; i < n ; i++) {
			cin >> a[i];
			freq[a[i]]++;
			s1.insert(a[i]);
			pre[i] = pre[i - 1] + a[i];
			if (pre[i] <= n)
				s.insert(pre[i]);
			// debug2(pre[i + 1], i + 1);
		}
		for (ll i = 1; i < n; i++) {
			for (ll j = i - 1; j >= 1; j--) {
				if (pre[i] - pre[j - 1] > n) {
					break;
				}
				s.insert(pre[i] - pre[j - 1]);
			}
		}
		for (auto it = s1.begin(); it != s1.end(); it++) {
			if (s.find(*it) != s.end()) {
				count += freq[*it];
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef long long int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int N = 1e6 + 1;
const ll K = 1e9 + 7;
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n, count = 0;
		cin >> n;
		set<ll> s;
		ll a[n], pre[n];
		for (ll i = 0; i < n; i++) {
			cin >> a[i];
		}
		pre[0] = a[0];
		for (ll i = 0; i < n - 1; i++) {
			pre[i + 1] = pre[i] + a[i + 1];
			s.insert(pre[i + 1]);
			// debug2(pre[i + 1], i + 1);
		}
		for (ll i = 1; i < n; i++) {
			for (ll j = 1; j < i; j++) {
				s.insert(pre[i] - pre[j - 1]);
			}
		}
		for (ll i = 0; i < n; i++) {
			if (s.find(a[i]) != s.end()) {
				count++;
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef long long int ll;
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
typedef pair<pair<int, int>, int> ppp;
#define X first
#define Y second
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define frv(i,a,b) for (ll i = (a), _b = (b); i < _b; i++)
#define frrv(i,b,a) for (ll i = (a), _b = (b); i >= _b; i--)
#define fr(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define frr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fordata(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) fr(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) fr(i,sizeof(ar)/sizeof(ar[0])) fr(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define all(ar) ar.begin(), ar.end()
#define INF 1000000000000000000
#define PI 3.14159265358979323846L
const int N = 1e6 + 1;
const ll K = 1e9 + 7;
const ll mod = 1e9 + 7;
ll hashstr(string a) {
	ll sum = 0;
	ll pow_p = 1;
	fr(i, sz(a)) {
		sum += ((a[i] - 'a' + 1) * pow_p) % mod;
		pow_p = (pow_p * 31) % mod;
		sum %= mod;
	}
	sum %= mod;
	return sum;
}
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		multiset<ll> s1;
		ll a[n], pre[n] = {0};
		fr(i, n) {
			cin >> a[i];
			s1.insert(a[i]);
			pre[i] = (i > 0 ? pre[i - 1] : 0) + a[i];
			// debug(pre[i]);
		}
		set<ll> s;
		fr(i, n) {
			frv(j, i, n) {
				if (j > i)
					s.insert(pre[j] - (i > 0 ? pre[i - 1] : 0));
			}
		}
		ll count = 0;
		fordata(it, s1) {
			if (s.find(*it) != s.end()) {
				count++;
			}
		}
		cout << count << endl;
	}
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef short int ll;
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
typedef pair<pair<int, int>, int> ppp;
#define X first
#define Y second
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define frv(i,a,b) for (ll i = (a), _b = (b); i < _b; i++)
#define frrv(i,b,a) for (ll i = (a), _b = (b); i >= _b; i--)
#define fr(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define frr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fordata(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) fr(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) fr(i,sizeof(ar)/sizeof(ar[0])) fr(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define all(ar) ar.begin(), ar.end()
#define INF 1000000000000000000
#define PI 3.14159265358979323846L
// const int N = 1e6 + 1;
// const ll K = 1e9 + 7;
// const ll mod = 1e9 + 7;
// ll hashstr(string a) {
// 	ll sum = 0;
// 	ll pow_p = 1;
// 	fr(i, sz(a)) {
// 		sum += ((a[i] - 'a' + 1) * pow_p) % mod;
// 		pow_p = (pow_p * 31) % mod;
// 		sum %= mod;
// 	}
// 	sum %= mod;
// 	return sum;
// }
int main() {
	ll t;
	cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		multiset<ll> s1;
		ll a[n], pre[n] = {0};
		fr(i, n) {
			cin >> a[i];
			s1.insert(a[i]);
			pre[i] = (i > 0 ? pre[i - 1] : 0) + a[i];
			// debug(pre[i]);
		}
		set<ll> s;
		fr(i, n) {
			for (short int j = i - 1; j >= 0; j--) {
				if (pre[i] - (j > 0 ? pre[j - 1] : 0) <= n)
					s.insert(pre[i] - (j > 0 ? pre[j - 1] : 0));
				else break;
			}
		}
		ll count = 0;
		fordata(it, s1) {
			if (s.find(*it) != s.end()) {
				count++;
			}
		}
		cout << count << endl;
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ;
typedef vector<int> vi;
#define sz(x) int(x.size())
#define mod 1000000007
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll exp(ll x,ll y){
  //x%=mod;
  ll res=1;
  while(y){
    if(y&1)
    res=res*x;//%mod;
    x=x*x;//%mod;
    y>>=1;
  }
  return res;
}
ll fact(ll n){
  ll res=1;
  for(ll i=2;i<=n;++i)
  (res*=i)%=mod;
  return res;
}
bool isprime(int n){
  for(int i=2;i*i<=n;++i)
  if(n%i==0) return 0;
  return 1;
}

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios::sync_with_stdio(0);
//cin.tie(0);
int t;
cin>>t;
while(t--){
  int n;
  cin>>n;
  vi v(n);
  rep(i,0,n-1) cin>>v[i];
  int ans=0;
  for(int q=0;q<n;++q){
   int i=0,j=0; int sum=0;bool mk=true;
   while(j<n){
     if(sum<v[q]){
       sum+=v[j];
       ++j;
     }
     if(sum==v[q]){
       if(j-1-i>0){
         ++ans;
         mk=false;
         break;
       }
       i=j;
       sum=0;
     }
     if(sum>v[q]){
       sum-=v[i];
       ++i;
     }
   }
   if(mk)
   while(i<n){
     if(sum==v[q]){
       ++ans;
       break;
     }
     sum-=v[i];++i;
   }
  }
  cout<<ans<<'\n';
}

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ;
typedef vector<int> vi;
#define sz(x) int(x.size())
#define mod 1000000007
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll exp(ll x,ll y){
  //x%=mod;
  ll res=1;
  while(y){
    if(y&1)
    res=res*x;//%mod;
    x=x*x;//%mod;
    y>>=1;
  }
  return res;
}
ll fact(ll n){
  ll res=1;
  for(ll i=2;i<=n;++i)
  (res*=i)%=mod;
  return res;
}
bool isprime(int n){
  for(int i=2;i*i<=n;++i)
  if(n%i==0) return 0;
  return 1;
}

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios::sync_with_stdio(0);
//cin.tie(0);
int t;
cin>>t;
while(t--){
  int n;
  cin>>n;
  vi v(n);
  rep(i,0,n-1) cin>>v[i];
  int ans=0;
  for(int q=0;q<n;++q){
   int sum=0;
   int i=0,j=0;
   while(j<n){
    while(j<n&&sum+v[j]<v[q]){
      sum+=v[j];
      ++j;
    }
    if(sum+v[j]==v[q]){
      if(j-i-1>0){
        ++ans;
        break;
      }
      i=j;
      sum=0;
    }
    if(sum+v[j]>v[q]){
      sum-=v[i];
      ++i;
    }
   }
  }
  cout<<ans<<'\n';
}

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ;
typedef vector<int> vi;
#define sz(x) int(x.size())
#define mod 1000000007
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll exp(ll x,ll y){
  //x%=mod;
  ll res=1;
  while(y){
    if(y&1)
    res=res*x;//%mod;
    x=x*x;//%mod;
    y>>=1;
  }
  return res;
}
ll fact(ll n){
  ll res=1;
  for(ll i=2;i<=n;++i)
  (res*=i)%=mod;
  return res;
}
bool isprime(int n){
  for(int i=2;i*i<=n;++i)
  if(n%i==0) return 0;
  return 1;
}

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios::sync_with_stdio(0);
//cin.tie(0);
int t;
cin>>t;
while(t--){
  int n;
  cin>>n;
  vi v(n);
  rep(i,0,n-1) cin>>v[i];
  int ans=0;
  for(int q=0;q<n;++q){
   int i=0,j=0; int sum=0;
   while(j<n){
     if(v[j]>=v[q]){
       ++j;
       i=j;
       sum=0;
       continue;
     }
    if(sum<v[q]){
      sum+=v[j];
      ++j;
      continue;
    }
    if(sum==v[q]){
      if(j-1-i>0){
        ++ans;
        break;
      }
      i=j;
      sum=0;
    }
    if(sum>v[q]){
      sum-=v[i];
      ++i;
    }

   }
  }
  cout<<ans<<'\n';
}

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ;
typedef vector<int> vi;
#define sz(x) int(x.size())
#define mod 1000000007
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll exp(ll x,ll y){
  //x%=mod;
  ll res=1;
  while(y){
    if(y&1)
    res=res*x;//%mod;
    x=x*x;//%mod;
    y>>=1;
  }
  return res;
}
ll fact(ll n){
  ll res=1;
  for(ll i=2;i<=n;++i)
  (res*=i)%=mod;
  return res;
}
bool isprime(int n){
  for(int i=2;i*i<=n;++i)
  if(n%i==0) return 0;
  return 1;
}

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios::sync_with_stdio(0);
//cin.tie(0);
int t;
cin>>t;
while(t--){
  int n;
  cin>>n;
  vi v(n);
  rep(i,0,n-1) cin>>v[i];
  int ans=0;
  for(int q=0;q<n;++q){
   int i=0,j=0; int sum=0;
   while(j<n){

     if(sum==v[q]){
       if(j-i>1)
       {
        ++ans;
        break;
       }
       else {
         j=i;
         i=j;
         sum=0;
       }
    }
      if(sum<v[q]){
       sum+=v[j];
       ++j;
     }
    if(sum>v[q]){
      sum-=v[i];
      ++i;
     continue;
    }
   }
  }
  cout<<ans<<'\n';
}

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ;
typedef vector<int> vi;
#define sz(x) int(x.size())
#define mod 1000000007
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll exp(ll x,ll y){
  //x%=mod;
  ll res=1;
  while(y){
    if(y&1)
    res=res*x;//%mod;
    x=x*x;//%mod;
    y>>=1;
  }
  return res;
}
ll fact(ll n){
  ll res=1;
  for(ll i=2;i<=n;++i)
  (res*=i)%=mod;
  return res;
}
bool isprime(int n){
  for(int i=2;i*i<=n;++i)
  if(n%i==0) return 0;
  return 1;
}

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios::sync_with_stdio(0);
//cin.tie(0);
int t;
cin>>t;
while(t--){
  int n;
  cin>>n;
  vi v(n);
  rep(i,0,n-1) cin>>v[i];
  int ans=0;
  for(int q=0;q<n;++q){
   int sum=0;
   int i=0,j=0;
   while(j<=n+1){
     if(sum>v[q]){
       sum-=v[i];
       ++i;
     }
     if(sum<v[q]){
       sum+=v[j];
       ++j;
     }
     if(sum==v[q]){
       if(j-i-1>0){
         ++ans;
         break;
       }
       i=j;
       sum=0;
     }

   }
  }
  cout<<ans<<'\n';
}

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ;
typedef vector<int> vi;
#define sz(x) int(x.size())
#define mod 1000000007
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll exp(ll x,ll y){
  //x%=mod;
  ll res=1;
  while(y){
    if(y&1)
    res=res*x;//%mod;
    x=x*x;//%mod;
    y>>=1;
  }
  return res;
}
ll fact(ll n){
  ll res=1;
  for(ll i=2;i<=n;++i)
  (res*=i)%=mod;
  return res;
}
bool isprime(int n){
  for(int i=2;i*i<=n;++i)
  if(n%i==0) return 0;
  return 1;
}

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios::sync_with_stdio(0);
//cin.tie(0);
int t;
cin>>t;
while(t--){
  int n;
  cin>>n;
  vi v(n);
  rep(i,0,n-1) cin>>v[i];
  int ans=0;
  for(int q=0;q<n;++q){
   int i=0,j=0; int sum=0;
   while(j<n){
     if(sum<v[q]){
       sum+=v[j];
       ++j;
     }
     if(sum==v[q]){
       if(j-1-i>0){
         ++ans;
         break;
       }
       i=j;
       sum=0;
     }
     if(sum>v[q]){
       sum-=v[i];
       ++i;
     }
   }
  }
  cout<<ans<<'\n';
}

    return 0;
}