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