#include <bits/stdc++.h>
using namespace std;
long long n;
long long l[200005], r[200005];
long long Ef[200005];
long long modpow(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2) {
    return ((a % 1000000007) * (modpow(a, n - 1) % 1000000007)) % 1000000007;
  } else {
    return modpow((a * a) % 1000000007, n / 2) % 1000000007;
  }
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> l[i];
  for (int i = 1; i <= n; i++) cin >> r[i];
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 1; i <= n - 1; i++) {
    long long ll = max(l[i], l[i + 1]), rr = min(r[i], r[i + 1]);
    long long len = max(0LL, rr - ll + 1) % 1000000007;
    long long base = (r[i] - l[i] + 1) * (r[i + 1] - l[i + 1] + 1) % 1000000007;
    Ef[i] = len * modpow(base, 1000000007 - 2) % 1000000007;
  }
  long long Efsum = 0, Ef2sum = 0, Efsum2;
  for (int i = 1; i <= n - 1; i++) Efsum += Ef[i], Efsum %= 1000000007;
  for (int i = 1; i <= n - 1; i++)
    Ef2sum += Ef[i] * Ef[i] % 1000000007, Ef2sum %= 1000000007;
  Efsum2 = Efsum * Efsum % 1000000007;
  long long ans = n * n % 1000000007;
  ans += 1000000007 - 2 * n % 1000000007 * Efsum % 1000000007,
      ans %= 1000000007;
  ans += Efsum2, ans %= 1000000007;
  ans += 1000000007 - Ef2sum, ans %= 1000000007;
  ans += Efsum, ans %= 1000000007;
  for (int i = 1; i <= n - 2; i++)
    ans += 1000000007 - 2 * Ef[i] % 1000000007 * Ef[i + 1] % 1000000007,
        ans %= 1000000007;
  for (int i = 1; i <= n - 2; i++) {
    long long ll = max(l[i], max(l[i + 1], l[i + 2])),
              rr = min(r[i], min(r[i + 1], r[i + 2]));
    long long len = max(0LL, rr - ll + 1) % 1000000007;
    long long base = (r[i] - l[i] + 1) * (r[i + 1] - l[i + 1] + 1) %
                     1000000007 * (r[i + 2] - l[i + 2] + 1) % 1000000007;
    ans += 2 * len % 1000000007 * modpow(base, 1000000007 - 2) % 1000000007,
        ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}
