#include <bits/stdc++.h>
using namespace std;
int n, l[200000 + 5], r[200000 + 5];
int p[200000 + 5], q[200000 + 5], sum;
long long add(long long a, long long b) { return (a + b) % 1000000007; }
long long mul(long long a, long long b) { return 1LL * a * b % 1000000007; }
long long dec(long long a, long long b) {
  return (a - b + 1000000007) % 1000000007;
}
int fst_pow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
int val(int i) {
  int ans = 1;
  ans = dec(ans, p[i]), ans = dec(ans, p[i + 1]);
  int L = max(l[i - 1], max(l[i], l[i + 1])),
      R = min(r[i - 1], min(r[i], r[i + 1]));
  if (L < R)
    ans = add(ans, mul(R - L, fst_pow(mul(mul(r[i] - l[i], r[i - 1] - l[i - 1]),
                                          r[i + 1] - l[i + 1]),
                                      1000000007 - 2)));
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &l[i]);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &r[i]);
    r[i]++;
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    int L = max(l[i], l[i - 1]), R = min(r[i], r[i - 1]);
    if (L < R)
      p[i] = mul(R - L, fst_pow(mul(r[i] - l[i], r[i - 1] - l[i - 1]),
                                1000000007 - 2));
    q[i] = dec(1, p[i]);
    sum = add(sum, q[i]);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = add(ans, q[i]);
    int ps = dec(sum, q[i]);
    if (i > 2) ans = add(ans, val(i - 1)), ps = dec(ps, q[i - 1]);
    if (i < n) ans = add(ans, val(i)), ps = dec(ps, q[i + 1]);
    ans = add(ans, mul(q[i], ps));
  }
  printf("%d", ans);
}
