#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
inline void read(int &x) {
  char ch = getchar();
  int f = 1;
  x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
int n, c[200050], t[200050];
int main() {
  read(n);
  for (register int i = 1; i <= n; ++i) read(c[i]);
  for (register int i = 1; i <= n; ++i) read(t[i]);
  if (c[1] != t[1]) return printf("No"), 0;
  for (register int i = n; i >= 1; --i) c[i] = c[i] - c[i - 1];
  for (register int i = n; i >= 1; --i) t[i] = t[i] - t[i - 1];
  sort(c + 1, c + n + 1), sort(t + 1, t + n + 1);
  for (register int i = 1; i <= n; ++i)
    if (c[i] != t[i]) return printf("No"), 0;
  printf("Yes");
  return 0;
}
