#include <stdio.h>

int antre[2005];

int main () {
    // n statsiun, m robot
    // n baris berikutnya : r tarif
    // m baris berikutnya : w berat robot
    // 2m baris berikutnya : robot ke i datang (i > 0) atau robot ke i pergi (i < 0)
    int n, m; scanf("%d %d", &n, &m);
    int r[105], w[2005];
    for(int i = 0; i < n; i++) scanf("%d", &r[i]);
    for(int i = 1; i <= m; i++) scanf("%d", &w[i]);
    //extra variables
    //ans = money, station stores robot idx, or -1 if empty
    //parkir where robots at
    long long ans = 0;
    int station[105];
    int parkir[105];
    for(int i = 0; i < n; i++) station[i] = -1;
    //manual queue (antre)
    //left defines the next robot that deserves an exit
    //right defines where the next robot will be stored (in terms of index)
    //if left == right queue is empty
    int left = 0;
    int right = 0;

    for(int ite = 1; ite <= 2 * m; ite++) {
        int x; scanf("%d", &x);
        if(x > 0) {
            int find = -1;
            for(int i = 0; i < n; i++) {
                if(station[i] == -1) {
                    station[i] = x;
                    parkir[x] = i;
                    find = 1;
                    break;
                }
            }
            if(find == -1) {
                antre[right] = x;
                right++;
            }
        } else { //count ans here
            //robot leaving
            x *= -1;
            ans = ans + (long long)r[parkir[x]] * w[x];
         //   printf("%d : %d | %d | %d\n", x, parkir[x], r[parkir[x]], w[x]);
            station[parkir[x]] = -1;
            //if there exist a robot waiting
            if(left < right) {
                int cur = antre[left];
        //        printf("Added : %d", cur);
                left++;
                parkir[cur] = parkir[x];
                station[parkir[x]] = cur;
            }
        }
    //    for(int i = 0; i < n; i++) {
  //          printf("%d | ", station[i]);
   //     }
   //     printf("\n");
    }
    printf("%d", ans);

    return 0;
}
