Under construction

Still being built. Things may change

Counting Subsequences

Interview

Time limit2sMemory limit1024 MB

Summary
Count the contiguous subarrays of a sequence whose elements sum to exactly 47.
Level

Easy3 of 10

Topics
Prefix sum, Hash map, Array
Solved
No attempts yet

Problem

"47 is the quintessential random number," states the 47 society. And there might be a grain of truth in that.

For example, the first ten digits of Euler's constant are 2 7 1 8 2 8 1 8 2 8.

And what is their sum? It is 47.

Try walking around with your eyes open. You will soon start noticing occurrences of the number 47 everywhere.

You are given a sequence SS of integers that we saw somewhere in nature. Your task is to compute how strongly this sequence supports the above claims.

We call a continuous subsequence of SS interesting if the sum of its terms is equal to 47. For example, consider the sequence S=(24,17,23,24,5,47)S = (24, 17, 23, 24, 5, 47). It has two interesting continuous subsequences: (23,24)(23, 24) and (47)(47).

Given a sequence SS, find the number of its interesting subsequences.

Input

The first line contains an integer TT, the number of test cases. Each test case is preceded by a blank line.

The first line of each test case contains the length of a sequence NN. The second line contains NN space-separated integers AiA_i, the elements of the sequence.

Output

For each test case, output a single line containing one integer: the count of interesting subsequences of the given sequence.

Hint

1≤T≤71 \le T \le 7

Examples1

  1. Example 1

    Input
    2
    
    13
    2 7 1 8 2 8 1 8 2 8 4 5 9
    
    7
    2 47 10047 47 1047 47 47
    
    Expected output
    3
    4