#include <bits/stdc++.h>
using namespace std;
int L[200010], R[200010];
int len[200010];
int s[200010];
int inter(int u, int v) {
  return max(0, min(R[u], R[v]) - max(L[u], L[v]) + 1);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> L[i];
  for (int i = 1; i <= n; i++) cin >> R[i];
  L[0] = R[0] = 0;
  for (int i = 0; i <= n; i++) len[i] = R[i] - L[i] + 1;
  for (int i = 1; i <= n; i++) {
    s[i] = ((long long)len[i] * len[i - 1] - inter(i, i - 1)) % 1000000007 *
           power((long long)len[i] * len[i - 1] % 1000000007, 1000000007 - 2,
                 1000000007) %
           1000000007;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += s[i];
  ans %= 1000000007;
  ans = ans * ans % 1000000007;
  for (int i = 1; i <= n; i++) {
    ans += s[i];
    ans -= (long long)s[i] * s[i] % 1000000007;
    ans %= 1000000007;
  }
  ans = ans % 1000000007 + 1000000007;
  ans %= 1000000007;
  for (int i = 1; i <= n - 1; i++) {
    ans -= (long long)2 * s[i] * s[i + 1] % 1000000007;
    long long tot =
        (long long)len[i - 1] * len[i] % 1000000007 * len[i + 1] % 1000000007;
    tot -= (long long)inter(i - 1, i) * len[i + 1] % 1000000007 +
           (long long)inter(i, i + 1) * len[i - 1] % 1000000007;
    tot += max(0, min(min(R[i - 1], R[i]), R[i + 1]) -
                      max(max(L[i - 1], L[i + 1]), L[i]) + 1);
    tot = tot % 1000000007 *
          power((long long)len[i - 1] * len[i] % 1000000007 * len[i + 1] %
                    1000000007,
                1000000007 - 2, 1000000007) %
          1000000007;
    if (tot < 0) tot += 1000000007;
    ans += 2 * tot;
    ans %= 1000000007;
  }
  ans %= 1000000007;
  if (ans < 0) ans += 1000000007;
  cout << ans << endl;
  return 0;
}
