#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7f7f7f7f;
const int mo = 1e9 + 7;
template <typename _T>
_T Fabs(_T x) {
  return x < 0 ? -x : x;
}
template <typename _T>
void read(_T &x) {
  _T f = 1;
  x = 0;
  char s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while ('0' <= s && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
int n, l[200005], r[200005], E[200005], q[200005], sum, ans;
int qkpow(int a, int s) {
  int t = 1;
  while (s) {
    if (s & 1) t = 1ll * a * t % mo;
    a = 1ll * a * a % mo;
    s >>= 1;
  }
  return t;
}
int add(int x, int y) { return x + y < mo ? x + y : x + y - mo; }
int work(int x, int y, int z) {
  int R = min(r[x], min(r[y], r[z])), L = max(l[x], max(l[y], l[z]));
  return max(0LL, 1ll * (R - L) *
                      qkpow(1ll * (r[x] - l[x]) * (r[y] - l[y]) % mo *
                                (r[z] - l[z]) % mo,
                            mo - 2) %
                      mo);
}
int calc(int x) {
  int res = 0;
  if (x > 1) res = work(x - 1, x, x + 1);
  return add(1 + res, mo - add(q[x], q[x + 1]));
}
signed main() {
  read(n);
  for (int i = 1; i <= n; i++) read(l[i]), l[i]--;
  for (int i = 1; i <= n; i++) read(r[i]);
  for (int i = 1; i <= n; i++) {
    int R = min(r[i], r[i - 1]), L = max(l[i], l[i - 1]);
    q[i] = max(0LL, 1ll * (R - L) *
                        qkpow(1ll * (r[i] - l[i]) * (r[i - 1] - l[i - 1]) % mo,
                              mo - 2) %
                        mo);
    E[i] = add(1, mo - q[i]);
    sum = add(sum, E[i]);
  }
  for (int i = 1; i <= n; i++) {
    int tmp = sum;
    for (int j = max(1, i - 1); j <= min(n, i + 1); j++)
      tmp = add(tmp, mo - E[j]);
    ans = add(ans, 1ll * E[i] * tmp % mo);
    if (i > 1) ans = add(ans, calc(i - 1));
    if (i < n) ans = add(ans, calc(i));
  }
  printf("%d\n", add(ans, sum));
  return 0;
}
