#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 10;
inline int read() {
  int x = 0;
  bool f = true;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = false;
    c = getchar();
  }
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return f ? x : -x;
}
int n, c[N], t[N], a[N], b[N];
int main() {
  n = read();
  for (register int i = 1; i <= n; ++i) c[i] = read();
  for (register int i = 1; i <= n; ++i) t[i] = read();
  for (register int i = 1; i <= n; ++i)
    a[i] = c[i] - c[i - 1], b[i] = t[i] - t[i - 1];
  sort(a + 2, a + n + 1), sort(b + 2, b + n + 1);
  for (register int i = 1; i <= n; ++i)
    if (a[i] != b[i]) return puts("No") & 0;
  puts("Yes");
  return 0;
}
