using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long PartialRemoval(long[] p, long[] x, long[] y, long[] r, int start) { long sum = 0; for(int i = 0;i < p.Length;i ++) { double coef = 0; for(int j = start;j < y.Length;j ++) { if(y[j] - r[j] < x[i] + 1) { double newCoef; if(y[j] - r[j] <= x[i] - 1) newCoef = 0; else newCoef = 0.5; if(newCoef > coef) coef = newCoef; } } if(coef != 0) sum += p[i] / 2; else sum += p[i]; } return sum; } static long maximumPeople(long[] p, long[] x, long[] y, long[] r) { long sum = 0; for(int i = 1;i <= y.Length;i ++) { long newSum = PartialRemoval(p, x, y, r, i); if(newSum > sum) sum = newSum; } return sum; // Return the maximum number of people that will be in a sunny town after removing exactly one cloud. } 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); } }