#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 25;
const int MOD = (int)1e9 + 7;
int f[N], g[N], pref[N], suff[N];
int l[N], r[N];
inline int quickPow(int a, int b) {
  int ans = 1, base = a;
  while (b) {
    if (b & 1) {
      ans = (long long)ans * base % MOD;
    }
    base = (long long)base * base % MOD;
    b >>= 1;
  }
  return ans;
}
inline int solve(int n) {
  f[1] = pref[1] = 1;
  for (int i = 2; i <= n; i++) {
    f[i] = (1 -
            (long long)max(0, min(r[i], r[i - 1]) - max(l[i], l[i - 1])) *
                quickPow((long long)(r[i] - l[i]) * (r[i - 1] - l[i - 1]) % MOD,
                         MOD - 2) %
                MOD +
            MOD) %
           MOD;
    pref[i] = (pref[i - 1] + f[i]) % MOD;
    g[i] = (MOD - 1LL + f[i] + f[i - 1] +
            (long long)max(0, min(r[i], min(r[i - 1], r[i - 2])) -
                                  max(l[i], max(l[i - 1], l[i - 2]))) *
                quickPow((long long)(r[i] - l[i]) * (r[i - 1] - l[i - 1]) %
                             MOD * (r[i - 2] - l[i - 2]) % MOD,
                         MOD - 2) %
                MOD) %
           MOD;
  }
  for (int i = n; i >= 1; i--) {
    suff[i] = (suff[i + 1] + f[i]) % MOD;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i - 2 >= 0) {
      ans = (ans + (long long)(pref[i - 2] + suff[i + 2] + 1) * f[i] % MOD +
             g[i] + g[i + 1]) %
            MOD;
    } else {
      ans =
          (ans + (long long)(suff[i + 2] + 1) * f[i] % MOD + g[i] + g[i + 1]) %
          MOD;
    }
  }
  return ans;
}
int main() {
  int n;
  while (~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]++;
    }
    printf("%d\n", solve(n));
  }
}
