In Sicily Online Judge System, there is a special user rank list. Every user gets a score for every problem he solved, and the fewer people have solved this problem, the higher score he can get. The following table shows how many scores you can get:
Score 10 8 6 4 2 1
Solved 1-10 11-30 31-50 51-75 76-100 >100
Your job is to calculate the total score for a given user.
The first line contains an integer np(1<=np<300) which is the number of problems in Online Judge. The second line contains np integers representing the number of users who have solved this problem from problem 1000 to problem 1000+np-1.
The third line contains an integer t(t<=10), which is the number of test cases.
Each test case begins with an integer n, which is the number of problems the user has solved. Then it is followed by n distinct integers which are the problem ids. Problem id is labeled from 1000.
for each test case, print the total score he can get on a single line.