using System; class Program { static void Main() { int n = int.Parse(Console.ReadLine()) + 1; ulong[] a = new ulong[n]; ulong[] b = new ulong[n]; ulong bAccumulation = 0; ulong Remainder = 1000000007; for (int i = 0; i < n; i++) { b[i] = ulong.Parse(Console.ReadLine()); bAccumulation += b[i]; bAccumulation %= Remainder; } for (int i = 0; i < n; i++) { a[i] = ulong.Parse(Console.ReadLine()); } ulong Sum = 0; for(int i = 0; i < n; i++) { Sum += a[i] * bAccumulation; Sum %= Remainder; if (bAccumulation < b[b.Length - i - 1]) { bAccumulation += Remainder; bAccumulation -= b[b.Length - i - 1]; } else { bAccumulation -= b[b.Length - i - 1]; } } Console.WriteLine(Sum); } }