#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10, mod = 1e9 + 7;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = 0;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return f ? x : -x;
}
int Pow(int x, int p) {
  int r = 1;
  while (p) {
    if (p & 1) r = (long long)x * r % mod;
    x = (long long)x * x % mod;
    p >>= 1;
  }
  return r;
}
int l[maxn], r[maxn], q[maxn];
int main() {
  int n = read();
  for (int i = 1; i <= n; ++i) l[i] = read();
  for (int i = 1; i <= n; ++i) r[i] = read();
  q[1] = 1;
  long long sum = 1;
  for (int i = 2; i <= n; ++i)
    q[i] = max(0LL, (long long)(min(r[i], r[i - 1]) - max(l[i], l[i - 1]) + 1) *
                        Pow((long long)(r[i] - l[i] + 1) *
                                (r[i - 1] - l[i - 1] + 1) % mod,
                            mod - 2) %
                        mod),
    q[i] = mod + 1 - q[i], (sum += q[i]) %= mod;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    int tmp = sum;
    if (i > 1) (tmp -= q[i - 1]) %= mod;
    (tmp -= q[i]) %= mod;
    if (i < n) (tmp -= q[i + 1]) %= mod;
    (tmp += 1) %= mod;
    (ans += (long long)tmp * q[i] % mod) %= mod;
    if (i > 1) {
      if (i == 2)
        (ans += (long long)q[i - 1] * q[i] % mod) %= mod;
      else
        (ans += -1 + q[i] + q[i - 1] +
                max(0LL, (long long)(min(r[i - 2], (min(r[i - 1], r[i]))) -
                                     max(l[i - 2], max(l[i - 1], l[i])) + 1) *
                             Pow((long long)(r[i - 2] - l[i - 2] + 1) *
                                     (r[i - 1] - l[i - 1] + 1) % mod *
                                     (r[i] - l[i] + 1) % mod,
                                 mod - 2) %
                             mod)) %= mod;
    }
    if (i < n) {
      if (i == 1)
        (ans += (long long)q[i] * q[i + 1] % mod) %= mod;
      else
        (ans += -1 + q[i] + q[i + 1] +
                max(0LL, (long long)(min(r[i - 1], (min(r[i], r[i + 1]))) -
                                     max(l[i - 1], max(l[i], l[i + 1])) + 1) *
                             Pow((long long)(r[i - 1] - l[i - 1] + 1) *
                                     (r[i] - l[i] + 1) % mod *
                                     (r[i + 1] - l[i + 1] + 1) % mod,
                                 mod - 2) %
                             mod)) %= mod;
    }
  }
  cout << (ans + mod) % mod << endl;
  return 0;
}
