#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int md = (int)1e9 + 7;
int n;
int l[N], r[N];
long long p[N];
long long add(long long a, long long b) {
  a += b;
  if (a >= md) a -= md;
  return a;
}
long long sub(long long a, long long b) {
  a -= b;
  if (a < 0) a += md;
  return a;
}
long long mul(long long a, long long b) { return a * b % md; }
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
long long inv(long long a) {
  a %= md;
  if (a < 0) a += md;
  long long b = md, u = 0, v = 1;
  while (a) {
    long long t = b / a;
    b -= t * a;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
long long norm(long long a) {
  while (a >= md) a -= md;
  while (a < 0) a += md;
  return a;
}
long long calcEq(int i) {
  int j = i + 1;
  long long pSame = 0;
  if (i > 0) {
    long long cnt = max(
        0LL, 1LL * (min({r[i], r[i - 1], r[j]}) - max({l[i], l[i - 1], l[j]})));
    pSame =
        mul(cnt, inv(mul(mul(r[i] - l[i], r[i - 1] - l[i - 1]), r[j] - l[j])));
  }
  return add(sub(1, add(sub(1, p[i]), sub(1, p[j]))), pSame);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> l[i];
  for (int i = 0; i < n; i++) {
    cin >> r[i];
    r[i]++;
  }
  p[0] = 1;
  for (int i = 1; i < n; i++) {
    long long cnt = max(0LL, 1LL * (min(r[i], r[i - 1]) - max(l[i], l[i - 1])));
    p[i] = sub(1, mul(cnt, inv(mul(r[i] - l[i], r[i - 1] - l[i - 1]))));
  }
  long long sum = 0;
  for (int i = 0; i < n; i++) sum = add(sum, p[i]);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long curS = sum;
    for (int j = max(0, i - 1); j < min(n, i + 2); j++) curS = sub(curS, p[j]);
    ans = add(ans, mul(curS, p[i]));
    ans = add(ans, p[i]);
    if (i > 0) ans = add(ans, calcEq(i - 1));
    if (i + 1 < n) ans = add(ans, calcEq(i));
  }
  cout << ans << '\n';
  return 0;
}
