import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long mod = (long)Math.pow(10, 9) + 7; long[] a = new long[n + 1]; long[] bsum = new long[n + 1]; for(int i = 0; i < n + 1; i++) { a[i] = sc.nextLong(); } bsum[0] = sc.nextLong(); for(int i = 1; i < n + 1; i++) { long t = sc.nextLong(); bsum[i] = (bsum[i - 1] + t) % mod; } long ans = 0; for(int i = 0; i < n + 1; i++) { long t = (a[i] * bsum[n - i]) % mod; ans = (ans + t) % mod; } System.out.println(ans); } }