#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
const long long MOD = 1e9 + 7;
int n;
long long l[N], r[N], f[N], g[N];
long long mpow(long long a, long long x) {
  if (x == 0) return 1;
  long long t = mpow(a, x >> 1);
  if (x % 2 == 0) return t * t % MOD;
  return t * t % MOD * a % MOD;
}
long long cac(int pos) {
  long long tot = (r[pos - 1] - l[pos - 1] + 1) * (r[pos] - l[pos] + 1) % MOD *
                  (r[pos + 1] - l[pos + 1] + 1) % MOD;
  long long s12 =
      max(0LL, min(r[pos], r[pos - 1]) - max(l[pos], l[pos - 1]) + 1);
  long long s23 =
      max(0LL, min(r[pos], r[pos + 1]) - max(l[pos], l[pos + 1]) + 1);
  long long s123 = max(0LL, min(min(r[pos], r[pos + 1]), r[pos - 1]) -
                                max(max(l[pos], l[pos + 1]), l[pos - 1]) + 1);
  tot += s123 - s12 * (r[pos + 1] - l[pos + 1] + 1) -
         s23 * (r[pos - 1] - l[pos - 1] + 1);
  return tot = (tot % MOD + MOD) % MOD;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &l[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &r[i]);
  }
  long long M = 1;
  for (int i = 1; i <= n; i++) {
    M = M * (r[i] - l[i] + 1) % MOD;
  }
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    f[i] = 1LL * (r[i] - l[i] + 1) * (r[i - 1] - l[i - 1] + 1) % MOD;
    long long x = max(0LL, min(r[i], r[i - 1]) - max(l[i], l[i - 1]) + 1);
    g[i] = f[i] = ((f[i] - x) % MOD + MOD) % MOD;
    f[i] = f[i] *
           mpow(1LL * (r[i] - l[i] + 1) * (r[i - 1] - l[i - 1] + 1) % MOD,
                MOD - 2) %
           MOD;
    sum = (sum + f[i]) % MOD;
  }
  long long ans = sum * sum;
  for (int i = 1; i <= n; i++) {
    ans = (ans - f[i] * f[i] % MOD - 2 * f[i] * f[i - 1] % MOD);
    ans = (ans % MOD + MOD) % MOD;
  }
  for (int i = 1; i <= n; i++) {
    ans = (ans + f[i]) % MOD;
  }
  for (int i = 1; i < n; i++) {
    ans = (ans + 2 * cac(i) *
                     mpow(1LL * (r[i] - l[i] + 1) * (r[i - 1] - l[i - 1] + 1) %
                              MOD * (r[i + 1] - l[i + 1] + 1) % MOD,
                          MOD - 2)) %
          MOD;
  }
  cout << ans << endl;
}
