#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  int d = 0;
  vector<int> a(20), b(20), c(20);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    d = d + b[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i - 1] == a[i] - 1) {
      d = d + c[i - 1] - 1;
    }
  }
  cout << d << endl;
  return 0;
}
