#include <bits/stdc++.h>
using namespace std;
int n;
const int mod = 1e9 + 7;
long long l[200005], r[200005], p[200005], ans, sum;
int read() {
  char c = getchar();
  int x = 0;
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x;
}
long long power(long long a, int b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) l[i] = read();
  for (int i = 1; i <= n; ++i) r[i] = read();
  for (int i = 1; i < n; ++i)
    if (l[i] > r[i + 1] || r[i] < l[i + 1])
      p[i] = 1;
    else {
      long long s = min(r[i], r[i + 1]) - max(l[i], l[i + 1]) + 1;
      p[i] = (1ll -
              s * power(r[i] - l[i] + 1, mod - 2) % mod *
                  power(r[i + 1] - l[i + 1] + 1, mod - 2) % mod +
              mod) %
             mod;
    }
  for (int i = 1; i < n; ++i) {
    ans = (ans + 3ll * p[i] % mod) % mod;
    sum = (sum + p[i]) % mod;
  }
  for (int i = 1; i <= n; ++i)
    ans = (ans + (sum - p[i] - p[i - 1] - p[i + 1]) * p[i] % mod) % mod;
  for (int i = 2; i < n; ++i) {
    long long s = min(r[i], min(r[i - 1], r[i + 1])) -
                  max(l[i], max(l[i - 1], l[i + 1])) + 1;
    long long q = (p[i] + p[i - 1] +
                   max(0ll, s * power(r[i - 1] - l[i - 1] + 1, mod - 2) % mod *
                                power(r[i + 1] - l[i + 1] + 1, mod - 2) % mod *
                                power(r[i] - l[i] + 1, mod - 2) % mod) -
                   1 + mod) %
                  mod;
    ans = (ans + 2ll * q % mod) % mod;
  }
  printf("%lld\n", (ans + 1 + mod) % mod);
}
