Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount systems.

There are m types of discounts. We assume that the discounts are indexed from 1 to m. To use the discount number i, the customer takes a special basket, where he puts exactly q_{i} items he buys. Under the terms of the discount system, in addition to the items in the cart the customer can receive at most two items from the supermarket for free. The number of the "free items" (0, 1 or 2) to give is selected by the customer. The only condition imposed on the selected "free items" is as follows: each of them mustn't be more expensive than the cheapest item out of the q_{i} items in the cart.

Maxim now needs to buy n items in the shop. Count the minimum sum of money that Maxim needs to buy them, if he use the discount system optimally well.

Please assume that the supermarket has enough carts for any actions. Maxim can use the same discount multiple times. Of course, Maxim can buy items without any discounts.


-----Input-----

The first line contains integer m (1 ≤ m ≤ 10^5) — the number of discount types. The second line contains m integers: q_1, q_2, ..., q_{m} (1 ≤ q_{i} ≤ 10^5). 

The third line contains integer n (1 ≤ n ≤ 10^5) — the number of items Maxim needs. The fourth line contains n integers: a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^4) — the items' prices.

The numbers in the lines are separated by single spaces.


-----Output-----

In a single line print a single integer — the answer to the problem.


-----Examples-----
Input
1
2
4
50 50 100 100

Output
200

Input
2
2 3
5
50 50 50 50 50

Output
150

Input
1
1
7
1 1 1 1 1 1 1

Output
3



-----Note-----

In the first sample Maxim needs to buy two items that cost 100 and get a discount for two free items that cost 50. In that case, Maxim is going to pay 200.

In the second sample the best strategy for Maxim is to buy 3 items and get 2 items for free using the discount. In that case, Maxim is going to pay 150.

Difficulty: competition

Starter code:

Solutions:
import sys

n_discounts = int(sys.stdin.readline())
discount_values = [int(x) for x in sys.stdin.readline().split()]
n_items = int(sys.stdin.readline())
item_values = [int(x) for x in sys.stdin.readline().split()]

min_discount_req = 10000000
for discount_value in discount_values:
    min_discount_req = min(min_discount_req, discount_value)
item_values.sort(reverse=True)

index = 0
overall_price = 0
while index < n_items:
    n_left = min(min_discount_req, n_items - index)
    for i in range(n_left):
        overall_price += item_values[index+i]
    index += n_left + 2

print(overall_price)
    


input()
k = min(map(int, input().split()))
n = int(input())
p = sorted(map(int, input().split()), reverse = True) + [0] * k
print(sum(sum(p[i: i + k]) for i in range(0, n, k + 2)))

m, mSale = int(input()), list(map(int,input().split()))
n, nPrice = int(input()), list(map(int,input().split()))
nPrice.sort()
sum, small = 0, min(mSale)

while True:
    if len(nPrice) <= small:
        for k in nPrice: sum+=k
        print(sum)
        return
    else:
        for i in range(small): sum+=nPrice.pop()
        if len(nPrice) <= 2:
            print(sum)
            return
        else:
            for i in range(2): nPrice.pop()

# 261A

from sys import stdin

__author__ = 'artyom'


def read_int():
  return int(stdin.readline().strip())


def read_int_ary():
  return map(int, stdin.readline().strip().split())


m = read_int()
d = sorted(read_int_ary())[0]
n = read_int()
a = list(reversed(sorted(read_int_ary())))

res = i = 0
while i < n:
  next = i + d
  res += sum(a[i:min(next, n)])
  i = next + 2

print(res)

def main():
    input()
    q = min(list(map(int, input().split())))
    input()
    aa = sorted(map(int, input().split()), reverse=True)
    print(sum(aa) - sum(aa[q::q + 2]) - sum(aa[q + 1::q + 2]))


def __starting_point():
    main()

__starting_point()

input()
d=[int(i) for i in input().split()]
c=int(input())
b=[int(i) for i in input().split()]
b.sort()
#d.sort()
take=1
p=min(d)
s=0
buy=p
for i in reversed(b):
    if buy:
        s+=i
        buy-=1
    else:
        if take:
            take-=1
        else:
            buy=p
            take=1

print(s)



m=int(input())
q=list(map(int,input().split()))
n=int(input())
a=list(map(int,input().split()))
sk=min(q)
a.sort()
j=1
ans=0
for i in range(n-1,-1,-1):
    l=sk-j
    if l==-1:
        pass
    elif l==-2:
        j=0
    else:
        ans+=a[i]
    j+=1
print(ans)
        



m = int(input())
q = [int(i) for i in input().split()]

n = int(input())
a = [int(i) for i in input().split()]
c = min(q)
a.sort()

price = 0
for i in range(n):
  if i % (c+2) < c:
    price += a[n-1-i]
  
print(price)

discounts = int(input())
discount_values = list(map(int, input().split()))
target = int(input())
item_values = list(map(int, input().split()))
discount_values.sort()
item_values.sort()
item_values.reverse()
# print(item_values)
# print(discount_values)
basket_size = discount_values[0]
result = 0
bought = 0
counter = 0
while bought < target:
    if  target - bought < basket_size:
        result += sum(item_values[counter:])
        bought += target + 1
    else:
        bought += 2 + basket_size
        result += sum(item_values[counter:counter + basket_size])
        counter += 2 + basket_size

print(result)


m = int(input())
q = list(map(int, input().split()))
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
q.sort()

ans = 0
mm = q[0]

i = 0
while i<n:
    j = i
    if j+mm <= n:
        while i < j+mm:
            ans+=a[i]
            i+=1
        i+=1
    else:
        break
    i+=1
if i <n:
    ans += sum(a[i:])
print(ans)
    


input()

k = min(map(int, input().split()))

n = int(input())

p = sorted(map(int, input().split()), reverse = True) + [0] * k

print(sum(sum(p[i: i + k]) for i in range(0, n, k + 2)))

m = int(input())
dis = list(map(int, input().split()))
n = int(input())
p = list(map(int, input().split()))
p.sort(reverse=True)
dis.sort()
money = sum(p)
mind = dis[0]
if n <= mind:
    print(sum(p))
else:
    i = mind - 1
    while i < n:
        if i + 1 < n:
            money -= p[i + 1]
        if i + 2 < n:
            money -= p[i + 2]
        i += mind + 2
    print(money)


m = int(input())
dis = list(map(int, input().split()))
n = int(input())
p = list(map(int, input().split()))
p.sort(reverse=True)
dis.sort()
money = sum(p)
mind = dis[0]
if n <= mind:
    print(sum(p))
else:
    i = mind - 1
    while i < n:
        if i + 1 < n:
            money -= p[i + 1]
        if i + 2 < n:
            money -= p[i + 2]
        i += mind + 2
    print(money)
    


m = int(input())
q = list(map(int, input().split()))
c = min(q)

n = int(input())
a = list(map(int, input().split()))
a.sort()

res = 0
for i in range(n):
    if i % (c+2) < c:
        res += a[n-1-i]
print(res)


class CodeforcesTask261ASolution:
    def __init__(self):
        self.result = ''
        self.discounts = []
        self.items_count = 0
        self.prices = []

    def read_input(self):
        input()
        self.discounts = [int(x) for x in input().split(" ")]
        self.items_count = int(input())
        self.prices = [int(x) for x in input().split(" ")]

    def process_task(self):
        self.discounts.sort()
        self.prices.sort(reverse=True)
        price = 0
        discount = self.discounts[0]
        for x in range(self.items_count):
            if x % (discount + 2) < discount:
                price += self.prices[x]
        self.result = str(price)

    def get_result(self):
        return self.result


def __starting_point():
    Solution = CodeforcesTask261ASolution()
    Solution.read_input()
    Solution.process_task()
    print(Solution.get_result())

__starting_point()

a=input()
b=sorted([int(i) for i in input().split()])[0]
c=int(input())
d=sorted([int(i) for i in input().split()])
p=0
while len(d):
	for i in range(0, min(len(d), b)):
		p+=d.pop()
	for i in range(0, min(len(d), 2)):
		a=d.pop()
print(p)


a=int(input())
q=list(map(int,input().split()))
n=int(input())
cost=list(map(int,input().split()))
t=min(q)
cost.sort()
total=0
index=len(cost)-1
while(index>=0):
    r=t
    if(index>=t):
        r=t
        while(r):
            total+=cost[index]
            r-=1
            index-=1
        if(index>=2):
            index-=2
        else:
            break;
    else:
        total+=sum(cost[0:index+1])
        break;
print(total)
        


m=int(input())
q=[int(i) for i in input().split()]
q.sort()
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
ans=0
i=n-1
while(i>=0):
    d=0
    while(i>=0 and d<q[0]):
        ans+=a[i]
        i-=1
        d+=1
    d=0
    while(i>=0 and d<2):
        d+=1
        i-=1
print(ans)

m = int(input())
q = list(map(int, input().split()))

n = int(input())
a = list(map(int, input().split()))

mn = min(q)
a.sort(reverse = True)
ans, p = 0, 0
while 1:
    for i in range(p, min(p + mn, n)): ans += a[i]
    p += mn + 2
    if p >= n: break
print(ans)

m=int(input())
q=list(map(int,input().split()))
n=int(input())
a=list(map(int,input().split()))
q.sort()
a.sort()
j=n-1
i=0
ans=0
while j>=0:
    
    for i in range(q[0]):
        ans=ans+a[j]
        j=j-1
        if j<0:
            break
    j=j-2
print(ans)