# Tripartite String SOLUTIONS CMX1P02

Page Contents

### Tripartite String SOLUTIONS CMX1P02

The String Family brought forth another Tripartite trio sisters and named them Hema, Rekha and Sushma. Hema and Rekha are exceptionally enamored with parties while Sushma detests them. One day Hema and Rekha requested that their folks get them confections to disseminate to individuals in their birthday celebration. (Recollect Hema, Rekha and Sushma were conceived around the same time). However, Sushma was uninterested in the gathering and just needed confections for herself.

You will be given elite P of conceivable number of up-and-comers going to the gathering. Were P[i] indicates the include of individuals coming in the I th probability. For each situation each individual should get greatest conceivable equivalent number of confections with the end goal that in the wake of appropriating the confections, there are consistently R confections staying for Sushma. You need to figure the base number of confections needed to purchase so that, in any conceivable circumstance of the given exhibit, every individual coming to party gets equivalent number of confections (in any event 1 and greatest conceivable out of aggregate) and there are consistently R confections staying for Sushma.

Information:

First line will contain T, number of testcases. At that point the testcases follow.

First line of each experiment contain N, number of conceivable check of individuals coming to party

Next line contain N divided whole numbers indicating the check of individuals

Next line contain R the quantity of confections continually staying after most extreme equivalent appropriation

Yield:

For each testcase, yield in a solitary line answer, the base number of confections needed to purchase.

Limitations

1≤T≤100

1≤N≤104

1≤P[i]≤41

0≤R<min(P[i])

Test Input:

2 3

Test Output:

7