#include <bits/stdc++.h>
using namespace std;
int n, a[100009], b[100009];
int read() {
  int x = 0;
  char ch = getchar();
  bool flag = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return flag ? -x : x;
}
long long readll() {
  long long x = 0;
  char ch = getchar();
  bool flag = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return flag ? -x : x;
}
void gg() {
  puts("No");
  exit(0);
}
int main() {
  n = read();
  int i;
  for (i = 1; i <= n; i++) a[i] = read();
  for (i = 1; i <= n; i++) b[i] = read();
  if (a[1] != b[1] || a[n] != b[n]) gg();
  for (i = 1; i < n; i++) {
    a[i] = a[i + 1] - a[i];
    b[i] = b[i + 1] - b[i];
  }
  sort(a + 1, a + n);
  sort(b + 1, b + n);
  for (i = 1; i < n; i++)
    if (a[i] != b[i]) gg();
  puts("Yes");
  return 0;
}
