#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
std::pair<T, U> operator+(const std::pair<T, U>& l, const std::pair<T, U>& r) {
  return {l.first + r.first, l.second + r.second};
}
typedef void (*callback_function)(void);
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const long double PI = acos(-1.0L);
const long double EPS = static_cast<long double>(1e-9);
long long inv(long long a, long long b) {
  if (a != 1) {
    return b - (inv(b % a, a) * b) / a;
  }
  return 1;
}
inline int Pow(int a, int k) {
  int s = 1;
  for (; k; k >>= 1) {
    k& 1 ? s = 1LL * s * a % MOD : 0;
    a = 1LL * a * a % MOD;
  }
  return s;
}
const int N = 2e5 + 7;
int n;
int L[N];
int R[N];
void input() {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) {
    scanf("%d", &L[i]);
  }
  for (int i = (0); i < (n); i++) {
    scanf("%d", &R[i]);
    R[i]++;
  }
}
int norm(int a) {
  while (a >= MOD) {
    a -= MOD;
  }
  while (a < 0) {
    a += MOD;
  }
  return a;
}
int mul(int a, int b) { return int(a * 1LL * b % MOD); }
int binPow(int a, int k) {
  int ans = 1;
  for (; k > 0; k >>= 1) {
    if (k & 1) {
      ans = mul(ans, a);
    }
    a = mul(a, a);
  }
  return ans;
}
int inv(int a) {
  int b = binPow(a, MOD - 2);
  assert(mul(a, b) == 1);
  return b;
}
int p[N];
int minR(int start, int len) {
  return *min_element(R + start, R + start + len);
}
int maxL(int start, int len) {
  return *max_element(L + start, L + start + len);
}
int calcInterval(int start, int len) {
  int cnt = max(0, minR(start, len) - maxL(start, len));
  int div = 1;
  for (int i = (start); i < (start + len); i++) {
    div = mul(div, R[i] - L[i]);
  }
  return mul(cnt, inv(div));
}
int calcEq(int i0) {
  int i1 = i0 + 1;
  int pSame = 0;
  if (i0 > 0) {
    pSame = calcInterval(i0 - 1, 3);
  }
  return norm(1 - norm(2 - p[i0] - p[i1]) + pSame);
}
void solve() {
  p[0] = 1;
  for (int i = (1); i < (n); i++) {
    p[i] = norm(1 - calcInterval(i - 1, 2));
  }
  int sum = 0;
  for (int i = (0); i < (n); i++) {
    sum = norm(sum + p[i]);
  }
  int ans = 0;
  for (int i = (0); i < (n); i++) {
    ans = norm(ans + p[i]);
    int curS = sum;
    for (int j = (max(0, i - 1)); j < (min(n, i + 2)); j++) {
      curS = norm(curS - p[j]);
    }
    ans = norm(ans + mul(p[i], curS));
    if (i > 0) {
      ans = norm(ans + calcEq(i - 1));
    }
    if (i + 1 < n) {
      ans = norm(ans + calcEq(i));
    }
  }
  printf("%d\n", ans);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  {
    input();
    solve();
  }
  return 0;
}
