#include <bits/stdc++.h>
using namespace std;
inline int inn() {
  int x, ch;
  while ((ch = getchar()) < '0' || ch > '9')
    ;
  x = ch ^ '0';
  while ((ch = getchar()) >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ '0');
  return x;
}
const int N = 100010;
int a[N], b[N], c[N], d[N];
int main() {
  int n = inn();
  for (int i = 1; i <= n; i++) a[i] = inn();
  for (int i = 1; i <= n; i++) b[i] = inn();
  if (a[1] != b[1] || a[n] != b[n]) return !printf("No\n");
  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 - 1; i++)
    if (c[i] ^ d[i]) return !printf("No\n");
  return !printf("Yes\n");
}
