#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <typename T>
void chmax(T &x, const T &y) {
  if (x < y) x = y;
}
int read() {
  char c;
  while ((c = getchar()) < '-')
    ;
  if (c == '-') {
    int x = (c = getchar()) - '0';
    while ((c = getchar()) >= '0') x = x * 10 + c - '0';
    return -x;
  }
  int x = c - '0';
  while ((c = getchar()) >= '0') x = x * 10 + c - '0';
  return x;
}
const int N = 1e5 + 5;
int a[N], b[N];
int main() {
  int n = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  for (int i = 1; i <= n; ++i) b[i] = read();
  for (int i = n; i >= 1; --i) a[i] -= a[i - 1];
  for (int i = n; i >= 1; --i) b[i] -= b[i - 1];
  sort(a + 2, a + n + 1);
  sort(b + 2, b + n + 1);
  for (int i = 1; i <= n; ++i)
    if (a[i] != b[i]) {
      puts("No");
      exit(0);
    }
  puts("Yes");
}
