using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long maximumPeople(long[] p, long[] x, long[] y, long[] r) { long cloud_remove = 1, count = 0, tmp_pop = 0, sunny_pop = 0; for(int i = 0; i < p.Length; i++){ for(int j = 0; j < y.Length; j++){ if(y[j]-r[j] == x[i] || y[j]+r[j] == x[i] || y[j] == x[i]){ count++; if(tmp_pop < p[i]){ tmp_pop = p[i]; } } else{ sunny_pop += p[i]; } } } return sunny_pop + tmp_pop; } static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string[] p_temp = Console.ReadLine().Split(' '); long[] p = Array.ConvertAll(p_temp,Int64.Parse); string[] x_temp = Console.ReadLine().Split(' '); long[] x = Array.ConvertAll(x_temp,Int64.Parse); int m = Convert.ToInt32(Console.ReadLine()); string[] y_temp = Console.ReadLine().Split(' '); long[] y = Array.ConvertAll(y_temp,Int64.Parse); string[] r_temp = Console.ReadLine().Split(' '); long[] r = Array.ConvertAll(r_temp,Int64.Parse); long result = maximumPeople(p, x, y, r); Console.WriteLine(result); } }