#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
    ll n;
    cin >> n;

    vector<ll> a(n), b(n), p(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (ll i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (ll i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }

    ll ans = -2e9, cur = 0;
    for (ll i = 0; i < n; i++) {
        cur += a[i];
        ans = max(ans, cur);
    }

    cout << ans << '\n';
}