#include <bits/stdc++.h>
template <typename A, typename B>
inline char SMAX(A &a, const B &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename A, typename B>
inline char SMIN(A &a, const B &b) {
  return b < a ? a = b, 1 : 0;
}
template <typename I>
inline void read(I &x) {
  int f = 0, c;
  while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
  x = c & 15;
  while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
  f ? x = -x : 0;
}
const int N = 1e5 + 7;
int n, m, c[N], t[N];
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) read(c[i]);
  for (int i = 1; i <= n; ++i) read(t[i]);
  if (c[1] != t[1] || c[n] != t[n]) return puts("No");
  for (int i = n; i > 1; --i) c[i] = c[i] - c[i - 1];
  for (int i = n; i > 1; --i) t[i] = t[i] - t[i - 1];
  std::sort(c + 2, c + n + 1);
  std::sort(t + 2, t + n + 1);
  if (!memcmp(c + 2, t + 2, sizeof(int) * (n - 1)))
    puts("Yes");
  else
    puts("No");
}
