#include <bits/stdc++.h>
using namespace std;
int main()
{
size_t n, m;
cin >> n >> m;
queue<unsigned> q_car;
priority_queue<pair<unsigned, unsigned>> q_lot;
for (size_t i = 0; i < n; i++)
{
unsigned s;
cin >> s;
q_lot.emplace(n - i, s);
}
vector<unsigned> weights(m);
vector<pair<unsigned, unsigned>> assigned_lot(m);
for (unsigned &x : weights)
cin >> x;
unsigned revenue = 0;
for (size_t i = 0; i < 2 * m; i++)
{
int j;
cin >> j;
if (j < 0)
{
if (!q_car.empty())
{
assigned_lot[q_car.front()] = assigned_lot[-j - 1];
revenue += weights[q_car.front()] * assigned_lot[-j - 1].second;
q_car.pop();
}
else
{
q_lot.push(assigned_lot[-j - 1]);
}
}
else
{
if (!q_lot.empty())
{
assigned_lot[j - 1] = q_lot.top();
revenue += weights[j - 1] * q_lot.top().second;
q_lot.pop();
}
else
{
q_car.push(j - 1);
}
}
}
cout << revenue << '\n';
}