#include <bits/stdc++.h>
using namespace std;
const int mo = 1e9 + 7;
int fpow(int a, int b) {
  int r = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mo)
    if (b & 1) r = 1ll * r * a % mo;
  return r;
}
int inv(int x) { return fpow(x, mo - 2); }
const int N = 2e5 + 11;
int a[N], b[N], n;
int f[N], s[N];
int C(int i, int j) {
  int l = max(a[i], a[j]);
  int r = min(b[i], b[j]);
  if (r < l) r = l - 1;
  return r - l + 1;
}
int cal(int i, int j) {
  int ret = 1ll * (b[i] - a[i] + 1) * (b[j] - a[j] + 1) % mo;
  int tmp = 1ll * (ret - C(i, j)) * inv(ret) % mo;
  return tmp;
}
int cal(int i, int j, int k) {
  int l = max(a[i], a[j]);
  l = max(l, a[k]);
  int r = min(b[i], b[j]);
  r = min(r, b[k]);
  if (r < l) r = l - 1;
  int ret =
      1ll * (b[i] - a[i] + 1) * (b[j] - a[j] + 1) % mo * (b[k] - a[k] + 1) % mo;
  int tmp = 1ll *
            (ret - 1ll * C(i, j) * (b[k] - a[k] + 1) -
             1ll * C(j, k) * (b[i] - a[i] + 1) + (r - l + 1)) %
            mo * inv(ret) % mo;
  return tmp;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = (1), i_end = (n); i <= i_end; ++i) cin >> a[i];
  for (int i = (1), i_end = (n); i <= i_end; ++i) cin >> b[i];
  long long ans = 0, tmp = 1, tot = 1;
  for (int i = (2), i_end = (n); i <= i_end; ++i) {
    f[i - 1] = (f[i - 2] + tmp) % mo;
    tmp = cal(i - 1, i);
    ;
    ans = (ans + tmp * f[i - 2]) % mo;
    tot = (tot + tmp) % mo;
    ans = (ans + cal(i - 2, i - 1, i)) % mo;
  }
  ans = (2 * ans + tot) % mo;
  if (ans < 0) ans += mo;
  cout << ans << endl;
}
