using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long maximumPeople(long[] population, long[] townloc, long[] cloudloc, long[] cloudrange) { return population.Where(x => cloudloc.Any(y => cloudrange.Any(z => townloc[Array.IndexOf(population, x)] != y + z && townloc[Array.IndexOf(population, x)] != y - z))).Sum(); } static void Main(String[] args) { int towns = Convert.ToInt32(Console.ReadLine()); string[] p_temp = Console.ReadLine().Split(' '); long[] population = Array.ConvertAll(p_temp, Int64.Parse); string[] x_temp = Console.ReadLine().Split(' '); long[] townloc = Array.ConvertAll(x_temp, Int64.Parse); int clouds = Convert.ToInt32(Console.ReadLine()); string[] y_temp = Console.ReadLine().Split(' '); long[] cloudloc = Array.ConvertAll(y_temp, Int64.Parse); string[] r_temp = Console.ReadLine().Split(' '); long[] cloudrange = Array.ConvertAll(r_temp, Int64.Parse); long max = 0; for(int i = 0; i < cloudloc.Length; i++) { long cloudtemp = cloudrange[i]; cloudrange[i] = 0; long maxtemp = maximumPeople(population, townloc, cloudloc, cloudrange); if (maxtemp > max) max = maxtemp; cloudrange[i] = cloudtemp; } Console.WriteLine(max); } }