#C3885. Taco Card Score Calculation

    ID: 47361 Type: Default 1000ms 256MiB

Taco Card Score Calculation

Taco Card Score Calculation

You are given a number of test cases. In each test case, a player draws a number of cards with integer values. The score is calculated as follows:

  • If the number of cards drawn, \(N\), is less than or equal to 5, the score is the sum of all card values.
  • If \(N > 5\), the score is the sum of the top 5 card values (i.e. the 5 largest numbers).

Your task is to compute the score for each test case.

Input Format: The first line contains an integer \(T\) indicating the number of test cases. For each test case, the first line contains an integer \(N\) (the number of cards drawn) and the second line contains \(N\) space-separated integers representing the card values.

Output Format: For each test case, output the final score on a new line.

inputFormat

The input is read from standard input and has the following format:

T
N1
card1_1 card1_2 ... card1_N1
N2
card2_1 card2_2 ... card2_N2
...
NT
cardT_1 cardT_2 ... cardT_NT

Where \(T\) is the number of test cases, and for each test case, \(N\) is the number of drawn cards followed by \(N\) integers representing the card values.

outputFormat

For each test case, print the final score computed according to the rules described, each on its own line. The output is to be written to standard output.

## sample
3
7
2 9 4 8 5 6 10
4
7 1 5 3
5
6 6 6 6 6
38

16 30

</p>