#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const long long MOD = 1000000007;
const long long INF = (long long)1e9 + 5;
long long mod_inv(long long a) {
  long long pw = MOD - 2, res = 1;
  a %= MOD;
  while (pw) {
    if (pw & 1) res = res * a % MOD;
    pw >>= 1;
    a = a * a % MOD;
  }
  return res;
}
pair<long long, long long> intersect(pair<long long, long long> a,
                                     pair<long long, long long> b) {
  return {max(a.first, b.first), min(a.second, b.second)};
}
long long len(pair<long long, long long> x) {
  return max(x.second - x.first + 1, 0LL);
}
long long sq(long long x) {
  x %= MOD;
  return x * x % MOD;
}
int N;
long long prob[MAXN], sum;
pair<long long, long long> intv[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> intv[i].first;
  }
  for (int i = 1; i <= N; i++) {
    cin >> intv[i].second;
    if (i != 1) {
      pair<long long, long long> inter = intersect(intv[i], intv[i - 1]);
      long long l1 = len(intv[i]), l2 = len(intv[i - 1]), x = len(inter);
      prob[i] = (1 - x * mod_inv(l1 * l2)) % MOD;
    } else {
      prob[i] = 1;
    }
    sum = (sum + prob[i]) % MOD;
  }
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    long long indep = sum - prob[i];
    ans = (ans + prob[i]) % MOD;
    if (i > 1) {
      indep -= prob[i - 1];
      if (i == 2) {
        ans = (ans + prob[i]) % MOD;
      } else {
        pair<long long, long long> in1 = intersect(intv[i - 2], intv[i - 1]);
        pair<long long, long long> in2 = intersect(intv[i - 1], intv[i]);
        pair<long long, long long> in3 = intersect(in1, in2);
        long long l1 = len(intv[i - 2]), l2 = len(intv[i - 1]),
                  l3 = len(intv[i]);
        ans = ans + 1;
        ans = ans - (1 - prob[i - 1]) % MOD;
        ans = ans - (1 - prob[i]);
        ans = ans + len(in3) % MOD * mod_inv(l1 * l2 % MOD * l3) % MOD;
        ans %= MOD;
      }
    }
    if (i < N) {
      indep -= prob[i + 1];
      if (i == 1) {
        ans = ans + prob[i + 1];
        ans %= MOD;
      } else {
        pair<long long, long long> in1 = intersect(intv[i - 1], intv[i]);
        pair<long long, long long> in2 = intersect(intv[i], intv[i + 1]);
        pair<long long, long long> in3 = intersect(in1, in2);
        long long l1 = len(intv[i - 1]), l2 = len(intv[i]),
                  l3 = len(intv[i + 1]);
        ans = ans + 1;
        ans = ans - (1 - prob[i]) % MOD;
        ans = ans - (1 - prob[i + 1]) % MOD;
        ans = ans + len(in3) % MOD * mod_inv(l1 * l2 % MOD * l3) % MOD;
        ans %= MOD;
      }
    }
    indep %= MOD;
    ans = (ans + indep * prob[i]) % MOD;
  }
  cout << (ans % MOD + MOD) % MOD << '\n';
  return 0;
}
