#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void ckmin(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void ckmax(T &a, U b) {
  if (a < b) a = b;
}
int N;
pair<long long, long long> arr[200013];
long long prob[200013];
long long ans;
long long expo(long long a, long long e) {
  if (e == 0) return 1;
  return expo(a * a % 1000000007, e >> 1) * (e & 1 ? a : 1) % 1000000007;
}
long long siz(pair<long long, long long> p) {
  return max(0ll, p.second - p.first + 1);
}
pair<long long, long long> overlap(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 modinv(long long x) { return expo(x, 1000000007 - 2); }
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  for (auto i = (0); i < (N); i++) cin >> arr[i].first;
  for (auto i = (0); i < (N); i++) cin >> arr[i].second;
  for (auto i = (1); i < (N); i++) {
    prob[i - 1] = siz(overlap(arr[i - 1], arr[i])) * modinv(siz(arr[i - 1])) %
                  1000000007 * modinv(siz(arr[i])) % 1000000007;
  }
  N--;
  ans = 1ll * (N + 1) * (N + 1);
  for (auto i = (0); i < (N); i++) {
    ans -= 2 * (N + 1) * prob[i];
    ans %= 1000000007;
    if (ans < 0) ans += 1000000007;
  }
  long long sum = 0;
  for (auto i = (0); i < (N); i++) {
    sum += prob[i];
    sum %= 1000000007;
  }
  for (auto i = (0); i < (N); i++) {
    long long tmp = sum;
    if (i) tmp -= prob[i - 1];
    tmp -= prob[i];
    if (i != N - 1) tmp -= prob[i + 1];
    ans += prob[i] * tmp;
    ans %= 1000000007;
    if (ans < 0) ans += 1000000007;
  }
  for (auto i = (0); i < (N); i++) {
    ans += prob[i];
    ans %= 1000000007;
  }
  for (auto i = (1); i < (N); i++) {
    long long num = siz(overlap(arr[i], overlap(arr[i - 1], arr[i + 1])));
    ans += 2 * num * modinv(siz(arr[i - 1])) % 1000000007 *
           modinv(siz(arr[i])) % 1000000007 * modinv(siz(arr[i + 1]));
    ans %= 1000000007;
  }
  cout << ans << '\n';
  return 0;
}
