#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 5;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
int arumin[maxN];
pair<int, int> P[maxN];
int len(pair<int, int> X) { return max(0, X.second - X.first); }
pair<int, int> intersect(pair<int, int> A, pair<int, int> B) {
  pair<int, int> C;
  C.first = max(A.first, B.first);
  C.second = min(A.second, B.second);
  return C;
}
int modP(int a, int b = MOD - 2) {
  if (!b) return 1;
  int c = modP(a, b >> 1);
  c = (1ll * c * c) % MOD;
  if (b & 1) c = (1ll * a * c) % MOD;
  return c;
}
int main() {
  time_t START = clock();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &P[i].first);
  for (int i = 0; i < n; i++) {
    scanf("%d", &P[i].second);
    P[i].second++;
  }
  int res = 0, sum = 1;
  arumin[0] = 1;
  for (int i = 1; i < n; i++) {
    int num = len(intersect(P[i - 1], P[i]));
    int den = 1ll * len(P[i - 1]) * len(P[i]) % MOD;
    arumin[i] = (1 + MOD - 1ll * num * modP(den) % MOD) % MOD;
    sum = (sum + arumin[i]) % MOD;
  }
  res = sum;
  for (int i = 0; i < n; i++) {
    int tmp = 0;
    for (int k = -1; k < 2; k++)
      if (i + k >= 0 && i + k < n) tmp = (tmp + arumin[i + k]) % MOD;
    tmp = (sum + MOD - tmp) % MOD;
    res = (0ll + res + 1ll * arumin[i] * tmp % MOD) % MOD;
  }
  for (int i = 1; i < n - 1; i++) {
    int num = len(intersect(intersect(P[i - 1], P[i + 1]), P[i]));
    int den = (1ll * len(P[i - 1]) * len(P[i + 1]) % MOD) * len(P[i]) % MOD;
    int tmp = 1ll * num * modP(den) % MOD;
    tmp = (-1ll + tmp + arumin[i] + arumin[i + 1]) % MOD;
    res = (0ll + res + 2ll * tmp % MOD) % MOD;
  }
  res = (res + 2ll * arumin[1] % MOD) % MOD;
  printf("%d\n", res);
  time_t FINISH = clock();
  cerr << "Execution time: "
       << (long double)(FINISH - START) / CLOCKS_PER_SEC * 1000.0
       << " milliseconds.\n";
  return 0;
}
