#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int maxm = 2e6 + 5;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
long long li[maxn], ri[maxn];
long long len[maxn], pi[maxn], sum[maxn];
int n;
long long com2(int i, int j) {
  return max(0ll, min(ri[i], ri[j]) - max(li[i], li[j]) + 1);
}
long long com3(int i, int j, int k) {
  return max(0ll,
             min(ri[i], min(ri[j], ri[k])) - max(li[i], max(li[j], li[k])) + 1);
}
long long qpow(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ret;
}
long long getSum(int i) {
  long long ret = sum[n] - (1 - pi[i]);
  if (i >= 2) ret -= (1 - pi[i - 1]);
  if (i < n) ret -= (1 - pi[i + 1]);
  return (ret % mod + mod) % mod;
}
long long getEij(int i) {
  if (i == 1) return ((1 - pi[2]) % mod + mod) % mod;
  long long ret = ((1 - pi[i] - pi[i + 1]) % mod + mod) % mod;
  ret = (ret + com3(i - 1, i, i + 1) *
                   qpow(len[i - 1] * len[i] % mod * len[i + 1] % mod, mod - 2) %
                   mod) %
        mod;
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> li[i];
  for (int i = 1; i <= n; ++i) cin >> ri[i];
  if (n == 1) return cout << "1" << endl, 0;
  len[1] = ri[1] - li[1] + 1;
  for (int i = 2; i <= n; ++i) {
    len[i] = ri[i] - li[i] + 1;
    pi[i] = com2(i, i - 1) * qpow(len[i] * len[i - 1] % mod, mod - 2) % mod;
  }
  for (int i = 1; i <= n; ++i) {
    sum[i] = ((sum[i - 1] + 1 - pi[i]) % mod + mod) % mod;
  }
  long long ans = sum[n];
  for (int i = 1; i < n; ++i) {
    ans = (ans + 2 * getEij(i)) % mod;
  }
  for (int i = 1; i <= n; ++i) {
    ans = ((ans + (1 - pi[i]) * getSum(i) % mod) % mod + mod) % mod;
  }
  cout << ans << endl;
  return 0;
}
