import java.io.PrintWriter; 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; for (int i = 0; i <= n; ++i) { for (int j = 0; j <= i; ++j) { ans = (ans + a[j] * b[i - j] % MOD) % MOD; } } System.out.println(ans); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }