#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int t = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    t = (t << 3) + (t << 1) + c - '0';
    c = getchar();
  }
  return t * f;
}
int b[100005], k, a[100005];
int main() {
  k = read();
  for (int i = 1; i <= k; i++) a[i] = read();
  for (int i = 1; i <= k; i++) b[i] = read();
  bool flag = 1;
  for (int i = k; i; i--) a[i] -= a[i - 1], b[i] -= b[i - 1];
  sort(a + 2, a + 1 + k);
  sort(b + 2, b + 1 + k);
  for (int i = 1; i <= k; i++)
    if (a[i] != b[i]) {
      puts("No");
      return 0;
    }
  puts("Yes");
  return 0;
}
