#include <bits/stdc++.h>
using namespace std;
long long powi(long long a, long long b) {
  if (!b) return 1;
  long long p = powi(a, b / 2);
  p = (p * p) % 1000000007;
  if (b & 1) p = (p * a) % 1000000007;
  return p;
}
long long mmi(long long x) { return powi(x, 1000000007 - 2); }
long long lft[200005], rht[200005];
long long pp[200005], qq[200005];
long long getP2(int i, int j) {
  long long x = max(lft[i], lft[j]), y = min(rht[i], rht[j]);
  long long len = max(y - x + 1, 0LL);
  long long l1 = rht[j] - lft[j] + 1, l2 = rht[i] - lft[i] + 1;
  long long p = (l1 * l2) % 1000000007;
  p = mmi(p);
  p = (p * len) % 1000000007;
  return p;
}
long long getP3(int i, int j, int k) {
  long long p1 = getP2(i, j);
  long long p2 = getP2(j, k);
  long long x = max(lft[i], max(lft[j], lft[k])),
            y = min(rht[i], min(rht[j], rht[k]));
  long long len = max(y - x + 1, 0LL);
  long long l1 = rht[j] - lft[j] + 1, l2 = rht[i] - lft[i] + 1,
            l3 = rht[k] - lft[k] + 1;
  long long p = (l1 * l2) % 1000000007;
  p = (p * l3) % 1000000007;
  p = mmi(p);
  p = (p * len) % 1000000007;
  return (p1 + p2 - p + 1000000007) % 1000000007;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", lft + i);
  for (int i = 1; i <= n; i++) scanf("%lld", rht + i);
  for (int i = 1; i <= n; i++)
    pp[i] = (1 - getP2(i, i - 1) + 1000000007) % 1000000007;
  for (int i = 1; i < n; i++)
    qq[i] = (1 - getP3(i - 1, i, i + 1) + 1000000007) % 1000000007;
  long long tot = 0;
  for (int i = 1; i <= n; i++) tot += pp[i];
  tot %= 1000000007;
  long long ans = tot;
  for (int i = 1; i < n; i++) ans += 2 * qq[i];
  ans %= 1000000007;
  for (int i = 1; i <= n; i++) {
    long long p = tot;
    p -= pp[i] + pp[i - 1] + pp[i + 1];
    p += 3LL * 1000000007, p %= 1000000007;
    ans += p * pp[i], ans %= 1000000007;
  }
  printf("%lld\n", ans);
  return 0;
}
