'Jeopardy!' is an intellectual game where players answer questions and earn points. Company Q conducts a simplified 'Jeopardy!' tournament among the best IT companies. By a lucky coincidence, the old rivals made it to the finals: company R1 and company R2. 

The finals will have n questions, m of them are auction questions and n - m of them are regular questions. Each question has a price. The price of the i-th question is a_{i} points. During the game the players chose the questions. At that, if the question is an auction, then the player who chose it can change the price if the number of his current points is strictly larger than the price of the question. The new price of the question cannot be less than the original price and cannot be greater than the current number of points of the player who chose the question. The correct answer brings the player the points equal to the price of the question. The wrong answer to the question reduces the number of the player's points by the value of the question price.

The game will go as follows. First, the R2 company selects a question, then the questions are chosen by the one who answered the previous question correctly. If no one answered the question, then the person who chose last chooses again.

All R2 employees support their team. They want to calculate what maximum possible number of points the R2 team can get if luck is on their side during the whole game (they will always be the first to correctly answer questions). Perhaps you are not going to be surprised, but this problem was again entrusted for you to solve.


-----Input-----

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 100; m ≤ min(n, 30)) — the total number of questions and the number of auction questions, correspondingly. The second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^7) — the prices of the questions. The third line contains m distinct integers b_{i} (1 ≤ b_{i} ≤ n) — the numbers of auction questions. Assume that the questions are numbered from 1 to n.


-----Output-----

In the single line, print the answer to the problem — the maximum points the R2 company can get if it plays optimally well. It is guaranteed that the answer fits into the integer 64-bit signed type.


-----Examples-----
Input
4 1
1 3 7 5
3

Output
18

Input
3 2
10 3 8
2 3

Output
40

Input
2 2
100 200
1 2

Output
400

Difficulty: interview

Starter code:

Solutions:
n, m =  list(map(int, input().split()))
prices =  list(map(int, input().split()))
auci = list(map(int, input().split()))

scores = 0

# m auc
# n - m default

for i in range(len(prices)):
    if (i+1) not in auci:
        scores += prices[i]
        prices[i] = 0

ra = []
for i in prices:
    if i != 0:
        ra.append(i)
ra.sort()
ra = ra[::-1]

for i in ra:
    if i > scores:
        scores += i
    else:
        scores *= 2

print(scores)
#print(ra)


n, m = map(int, input().split())
prices = list(map(int, input().split()))
normal = []
auct = []
q = list(map(int, input().split()))
sum = 0
for i in range(n):
    if i + 1 in q:
        auct.append(prices[i])
    else:
        sum += prices[i]
auct = sorted(auct, reverse=True)
for elem in auct:
    sum += max(elem, sum)
print(sum)

n, m = map(int, input().split())
a = list(map(int, input().split()))
nums = set(list(map(int, input().split())))
stan = []
auct = []
for i in range(len(a)):
    if i + 1 not in nums:
        stan.append(a[i])
    else:
        auct.append(a[i])
sm = sum(stan)
auct = list(reversed(sorted(auct)))
for i in range(len(auct)):
    if sm >= auct[i]:
        if sm > auct[i]:
            sm *= 2
        else:
            sm += auct[i]
    else:
        sm += auct[i]
print(sm)

[n, m], q, a = list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split()))
ans = sum(q[x - 1] for x in set(range(1, n + 1)) - set(a))
for x in sorted(a, key = lambda x: q[x - 1], reverse = True):
    if q[x - 1] <= ans:
        ans <<= 1
    else:
        ans += q[x - 1]
print(ans)


n, m = list(map(int, input().split()))
lst = list(map(int, input().split()))
au = list(map(int, input().split()))
res = sum(lst)
ls = []
for i in range(m): 
    res -= lst[au[i] - 1]
    ls.append(lst[au[i] - 1])
ls.sort(reverse = True)
for i in range(len(ls)):
    res += max(ls[i], res)
print(res)


n, m = tuple(map(int, str.split(input())))
a = tuple(map(int, str.split(input())))
mi = tuple(map(int, str.split(input())))
ms = sorted([a[i - 1] for i in mi], reverse=True)

points = 0
for i, ai in enumerate(a):

    if i + 1 not in mi:

        points += ai

for m in ms:

    if m > points:

        points += m

    else:

        points += points

print(points)


n,m = map(int,input().split())
mat = list(map(int,input().split()))
auction = list(map(int,input().split()))
aucpoint = [mat[i-1] for i in auction]
aucpoint.sort(reverse = True)
for i in auction:
    mat[i-1] = 0
s = sum(mat)
for point in aucpoint:
    if s > point:
        s *= 2
    else: s += point
print(s)

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [a[i - 1] for i in map(int, input().split())]
b.sort(reverse = True)
s = sum(a) - sum(b)
for i in b: s += s if i < s else i
print(s)

n, m = map(int, input().split())
ques = list(map(int,input().split()))
acutions = set(map(int, input().split()))

acu = []
points = 0

for i in range(n):
	if i + 1 in acutions:
		acu.append(ques[i])
	else:
		points += ques[i]

acu.sort(reverse= True)

for a in acu:
	if points > a:
		points += points
	else:
		points += a

print(points)

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(len(b)):
    b[i] -= 1
b = set(b)
c = []
d = []
for i in range(len(a)):
    if i in b:
        c.append(a[i])
    else:
        d.append(a[i])
sum = 0
for i in range(len(d)):
    sum += d[i]
c = sorted(c)
if sum < c[-1]:
    sum += c[-1]
    sum *= (2**(len(c)-1))
else:
    sum *= (2**len(c))
print(sum)

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
ans = 0
for i in range(m):
    ans -= a[b[i] - 1]
    c.append(a[b[i] - 1])
ans += sum(a)
c.sort()
c = c[::-1]
mx = ans
for i in range(m + 1):
    x = (sum(c[:i])+ans)*(2**(m-i))
    if x > mx:
        mx = x

print(mx)

from operator import itemgetter
R = lambda:map(int, input().split())
n, m = R()
a = list(R())
b = [0] * n
for i in R():
  b[i - 1] = 1
a = sorted(enumerate(a), key=itemgetter(1), reverse=True)
s = sum(x for i, x in a if b[i] != 1)
for i, x in a:
  if b[i] == 1:
    s += s if s > x else x
print(s)

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
ans = 0
for i in range(m):
    ans -= a[b[i] - 1]
    c.append(a[b[i] - 1])
ans += sum(a)
c.sort()
c = c[::-1]
mx = ans
for i in range(m + 1):
    x = (sum(c[:i]) + ans) * (2 ** (m - i))
    if x > mx:
        mx = x
print(mx)

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
ans = 0

for i in range(m):
    ans -= a[b[i] - 1]
    c.append(a[b[i] - 1])
ans += sum(a)
c.sort()
c = c[::-1]
mx = ans
for i in range(m + 1):
    x = (sum(c[:i]) + ans) * (2 ** (m - i))
    if x > mx:
        mx = x
print(mx)

import sys
from itertools import *
from math import *
MAX = 10000000
def solve():
    n, m = list(map(int, input().split()))
    quest = list(map(int, input().split()))
    auctindex = set(map(int, input().split()))
    aucts = list()
    firstsum = 0
    for i, q in enumerate(quest):
        if (i + 1) not in auctindex:
            firstsum+= q
        else:
            aucts.append(q)
    aucts.sort(reverse = True)
    for val in aucts:
        firstsum += max(firstsum, val)
    print(firstsum)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()


# -*- coding: utf-8 -*-
"""
yl3 jeopardy
"""
a=lambda :list(map(int,input().split()))
n,m=a()
sa=a()
sb=a()
au=[]

for i in reversed(sorted(sb)):
    au.append(sa.pop(i-1))
su=sum(sa)
au.sort(reverse=True)
for i in range(m):
    t=au.pop(0)
    if t>su:
        su+=t
    else:su*=2
print(su)

import sys


def main():
    n, m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    auction_questions = set(map(int, input().split()))

    regular_a = [a[i] for i in range(len(a)) if (i + 1) not in auction_questions]
    auction_a = [a[i] for i in range(len(a)) if (i + 1) in auction_questions]

    total_points = sum(regular_a)
    auction_a.sort(reverse=True)
    for a in auction_a:
        if a < total_points:
            total_points += total_points
        else:
            total_points += a
    print(total_points)


def __starting_point():
    main()

__starting_point()

from operator import itemgetter

R = lambda:list(map(int, input().split()))

n, m = R()

a = list(R())

b = [0] * n

for i in R():

  b[i - 1] = 1

a = sorted(enumerate(a), key=itemgetter(1), reverse=True)

s = sum(x for i, x in a if b[i] != 1)

for i, x in a:

  if b[i] == 1:

    s += s if s > x else x

print(s)



# Made By Mostafa_Khaled


n, m = list(map(int, input().split(' ')))
tmp = list(map(int, input().split(' ')))
m_nums = list([int(x)-1 for x in input().split(' ')])
m_list = [tmp[el] for el in m_nums]
_sum = sum(tmp)-sum(m_list)
m_list.sort()
while (m_list) and (m_list[len(m_list)-1] > _sum): _sum += m_list.pop()
print(_sum * 2**(len(m_list)))


n , m = map(int,input().split())
que =list(map(int,input().split())) 
auc = list(map(int,input().split()))
s = sum(que)
aa=[]
for i in auc:
    s-=que[i-1]
    aa.append(que[i-1])
aa.sort()
for i in aa[::-1]:
    if i<s:
        s*=2
    else:
        s+=i
print(s)

R = lambda :map(int, input().split())
n, m = R()
a = list(R())
b = list(R())
li = []
cost = 0
for i in range(1, n + 1):
    if i not in b:
        cost += a[i - 1]
    else:
        li.append(a[i - 1])
li.sort(reverse=True)
for i in range(m):
    cost += max(cost, li[i])
print(cost)