#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int nm = 0, fh = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') fh = -1;
  for (; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
  return nm * fh;
}
int n, a[100020], b[100020], c[100020], d[100020];
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) b[i] = read();
  if ((a[1] ^ b[1]) || (a[n] ^ b[n])) {
    puts("No");
    return 0;
  }
  for (int i = 1; i < n; i++) c[i] = a[i + 1] - a[i], d[i] = b[i + 1] - b[i];
  sort(c + 1, c + n), sort(d + 1, d + n);
  for (int i = 1; i < n; i++)
    if (c[i] ^ d[i]) {
      puts("No");
      return 0;
    }
  puts("Yes");
  return 0;
}
