Naman owns a very famous Ice Cream parlour in Pune. He has a wide range of flavours with different pricing. 
Every flavour costs ₹ X per gram and quantity of each flavour in the parlour is indefinite. Now, Naman has 
received an order for a party wherein he is asked to prepare each Ice Cream with N number of flavours. 
He needs to prepare each Ice Cream of W grams and at the same time has to keep the cost minimum. 
Can you help him out?
Note: If it is not possible to prepare such an Ice Cream, print “Not Possible”.
-----Input:-----
First line contains an integer T denoting the number of test cases.
First line of every test case contains an integer N denoting the number of flavours.
The second line of every test case by N space separated integers denoting the cost per gram of each flavour. 
Second line of every test case contains two space separated integers W and Y denoting the weight 
of Ice Cream in grams and the number of flavours to be used respectively. 
-----Output:-----
For each test case, print the total cost of the Ice Cream in a single line.
-----Constraints:-----
1 ≤ T ≤ 100
1 ≤ N,W,Y ≤ 40000
-----Example:-----Input:
2
5 
4 6 8 1 10
10 3
2
1 2
1 2Output:
18
Not Possible
-----Explanation:-----
In the first test case to achieve the minimum cost, the Ice Cream will consist of 8 grams 
of flavour costing ₹1, 1 gram of flavour costing ₹4 and 1 gram of flavour costing ₹6.
In the second test case it is not possible to make an ice-cream weighing 1 gram using 2 flavours.
import sys
import math

def solution():
 T = int(input().strip())
 for _ in range(T):
  n = int(input().strip())
  cost_of_flavour = list(map(int, input().strip().split(' ')))
  cost_of_flavour = sorted(cost_of_flavour)
  w, y = list(map(int, input().strip().split(' ')))

  if y > w or y > n:
   print("Not Possible")
   continue
  else:
   min_sum = 0
   for i in range(y):
    min_sum += cost_of_flavour[i]
   min_sum += cost_of_flavour[0]*(w - y)
   print("%d"%(min_sum))
solution()
import sys
import math

def solution():
 T = int(input().strip())
 for _ in range(T):
  n = int(input().strip())
  cost_of_flavour = list(map(int, input().strip().split(' ')))
  cost_of_flavour = sorted(cost_of_flavour)
  w, y = list(map(int, input().strip().split(' ')))

  if y > w or y > n:
   print("Not Possible")
   continue
  else:
   min_sum = 0
   for i in range(y):
    min_sum += cost_of_flavour[i]
   min_sum += cost_of_flavour[0]*(w - y)
   print("%d"%(min_sum))
solution()