process.stdin.resume(); process.stdin.setEncoding('ascii'); var input_stdin = ""; var input_stdin_array = ""; var input_currentline = 0; process.stdin.on('data', function (data) { input_stdin += data; }); process.stdin.on('end', function () { input_stdin_array = input_stdin.split("\n"); main(); }); function readLine() { return input_stdin_array[input_currentline++]; } /////////////// ignore above this line //////////////////// function maximumPeople(p, x, y, r) { var all = [] for(var i =0;i prev + curr ) all.sort() return (total(p,x,y,r) + all.pop()) // Return the maximum number of people that will be in a sunny town after removing exactly one cloud. } function free (p,x, a ,b){ var townI = x.filter(t => (((t -1)<= (a + b) && (t -1) >=(a- b)) || ((t+1) >= (a-b) && (t+1)<=(a+b)))).map((e,i) => i) var pop = p.filter((e,i) => townI.includes(i)) return pop.reduce( (prev, curr) => prev + curr ); } function total(p,x,y,r){ let s = new Set() for(var i =0;i (((t -1)<= (a + b) && (t -1) >=(a- b)) || ((t+1) >= (a-b) && (t+1)<=(a+b)))).map((e,i) => i) townI.map((e,i)=> s.add(i)) } var arr = Array.from(s) var pop = p.filter((e,i)=> !arr.includes(i)) return pop.reduce( (prev, curr) => prev + curr ); } function main() { var n = parseInt(readLine()); p = readLine().split(' '); p = p.map(Number); x = readLine().split(' '); x = x.map(Number); var m = parseInt(readLine()); y = readLine().split(' '); y = y.map(Number); r = readLine().split(' '); r = r.map(Number); var result = maximumPeople(p, x, y, r); process.stdout.write("" + result + "\n"); }