Fazil’s faculty gave him a string S consisting of only 1s and 0s and he need to find the number of sub-strings which start and end both in 1.

In this problem, a sub-string is defined as a sequence of continuous characters S_{i}, S_{i+1}, …, S_{j} where 1 ≤ i ≤ j ≤ N.

Can you help Fazil in completing the task?

**Input:**
T, the number of testcases.
**Each test-case consists of N**(the length of string) in one line and string in second line.
**Output:**
For each testcase, print the required answer in one line.
**Explanation:**
Assume the String with 5 digits 10001 then it has 3 substrings such as S[1,1], S[5,5] and S[1,5] that satisfy the condition.

#include <stdio.h> int main() { int t; int l; scanf("%d",&t); int sum; char string; int pair; while(t>0){ pair=0; sum=0; scanf("%d",&l); int i; for(i=0;i<=l;i++){ scanf("%c",&string); if(string=='1') pair++; } for(i=1;i<=pair;i++) sum+=i; printf("%d\n",sum); t--; } return 0; }

**INPUT_1:**

3

6

111011

8

01101111

5

10011

**OUTPUT:**

15

21

6

**INPUT_2:**

5

3

101

6

011101

8

11100101

4

0010

7

1000011

**OUTPUT:**

3

10

15

1

6

**ILLUSTRATION**

**Morae Q!**

- Conversion of days into year, weeks and days.
- Find if the number is a perfect number or not.
- Compute conversion of Binary to Octal.
- Return the sum of digits in a number.
- Find if a word exists or not in a sentence.
- Convert Numbers into Words.
- Read a word if it consists only of the letters known.
- Check if the string is a dynamic string or not.
- Convert all Uppercase letters to Lowercase and vice-versa.
- Change the string such that there are no matching adjacent characters.
- Find the number of sub-strings which start and end both in 1.
- Find the start and end index of unsorted sub-array.
- Find the maximum number of pairs that can be formed.
- Figure out the number of bubbly words present.
- Check if a string is lapindrome or not even with a middle character.
- Seating layout in a triangular shaped class according to the number of rows.
- Find and Sort a sub-array which makes whole array sorted.
- Seating layout according to the number of rows.
- Find the final states of the bulbs.
- Check if reversing sub array makes the array sorted.