import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } long MOD = 1_000_000_000 + 7; void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] a = new long[n + 1]; long[] b = new long[n + 1]; for (int i = 0; i < a.length; ++i) { a[i] = sc.nextLong(); } for (int i = 0; i < b.length; ++i) { b[i] = sc.nextLong(); } long ans = 0; long tmp = 0; for (int i = n; i >= 0; --i) { tmp = (tmp + b[n - i]) % MOD; ans = (ans + a[i] * tmp % MOD) % MOD; } System.out.println(ans); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }