//BRUH IMMA DEAD
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
ll n, m; cin >> n >> m;
vector<ll> cost(n + 5), weight(m + 5), pos(m + 5, -1);
for(int i = 1; i <= n; i++) cin >> cost[i];
for(int i = 1; i <= m; i++) cin >> weight[i];
priority_queue<ll, vector<ll>, greater<ll>> parkings;
for(int i = 1; i <= n; i++) parkings.push(i);
queue<ll> curr_car;
ll ans = 0;
for(int x = 1; x <= 2 * m; x++) {
ll i; cin >> i;
if (i > 0) curr_car.push(i);
else {
i = -i;
parkings.push(pos[i]);
}
while (!curr_car.empty() && !parkings.empty()) {
ll car = curr_car.front();
curr_car.pop();
ll parking = parkings.top();
parkings.pop();
pos[car] = parking;
ans += weight[car] * cost[parking];
}
}
cout << ans << endl;
}