#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define rep(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
int N, M, R[101], W[2001];
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
cin >> N >> M;
vi parking(N + 1, 0), cars(M + 1, 0);
rep(i, 1, N) cin >> R[i];
rep(i, 1, M) cin >> W[i];
queue<int> q; int in, ans = 0;
set<int> avail;
rep(i, 1, N) avail.insert(i);
rep(i, 1, 2 * M) {
cin >> in;
if (in > 0) {
if (avail.empty()) {
q.push(in);
} else {
cars[in] = *begin(avail); // set cars to the parking spot
parking[cars[in]] = i; // set time
avail.erase(cars[in]); // erase
}
} else {
in = -in;
ans += W[in] * R[cars[in]];
if (q.empty()) {
avail.insert(cars[in]);
} else {
int cur = q.front(); q.pop();
cars[cur] = cars[in]; // replace with the cars from the queue
parking[cars[cur]] = i;
}
cars[in] = 0;
}
// for (int j : avail) cout << j << ' '; cout << '\n';
}
cout << ans << '\n';
return 0;
}