#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  write(a);
  puts("");
}
inline void wri(long long a) {
  write(a);
  putchar(' ');
}
long long t, n, nl[100010], ml[100010], nll[100010], mll[100010];
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    nl[i] = read();
  }
  for (int i = 1; i <= n; i++) {
    ml[i] = read();
  }
  for (int i = 1; i < n; i++) {
    nll[i] = nl[i + 1] - nl[i];
    mll[i] = ml[i + 1] - ml[i];
  }
  sort(nll + 1, nll + n);
  sort(mll + 1, mll + n);
  int pd = 0;
  for (int i = 1; i < n; i++) {
    if (nll[i] != mll[i]) pd = 1;
  }
  if (pd == 0 && nl[1] == ml[1] && nl[n] == ml[n]) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}
