#include <bits/stdc++.h>
using namespace std;
const int maxn = 200003, mod = 1000000007;
int Plus(int x, int y) { return (x += y) >= mod ? x - mod : x; }
int Minus(int x, int y) { return Plus(x, mod - y); }
void PlusEqual(int &x, int y) {
  if ((x += y) >= mod) x -= mod;
}
int mul(long long x, int y) { return x * y % mod; }
int qpow(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = mul(ans, x);
    x = mul(x, x);
    y >>= 1;
  }
  return ans;
}
int Div(int x, int y) { return mul(x, qpow(y, mod - 2)); }
int n, l[maxn], r[maxn], p[maxn];
int f(int i) {
  if (i >= 2 && i <= n)
    return Plus(Plus(p[i], Minus(p[i - 1], 1)),
                i == 2 ? 0
                       : Div(max(min(min(r[i - 2], r[i - 1]), r[i]) -
                                     max(max(l[i - 2], l[i - 1]), l[i]) + 1,
                                 0),
                             mul(mul(r[i] - l[i] + 1, r[i - 1] - l[i - 1] + 1),
                                 r[i - 2] - l[i - 2] + 1)));
  else
    return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", l + i);
  for (int i = 1; i <= n; i++) scanf("%d", r + i);
  int sum = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    p[i] =
        (i == 1
             ? 1
             : Minus(1,
                     Div(max(min(r[i - 1], r[i]) - max(l[i - 1], l[i]) + 1, 0),
                         mul(r[i] - l[i] + 1, r[i - 1] - l[i - 1] + 1))));
    PlusEqual(sum, p[i]);
  }
  for (int i = 1; i <= n; i++) {
    PlusEqual(
        ans,
        Plus(Plus(Plus(p[i], mul(p[i], Minus(Minus(Minus(sum, p[i]), p[i - 1]),
                                             p[i + 1]))),
                  f(i)),
             f(i + 1)));
  }
  printf("%d\n", ans);
  return 0;
}
