#include <bits/stdc++.h>
using namespace std;
int n, a[100005], b[100005], a2[100005], b2[100005];
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (i > 1) a2[i - 1] = a[i] - a[i - 1];
  }
  for (register int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    if (i > 1) b2[i - 1] = b[i] - b[i - 1];
  }
  if (a[1] != b[1] || a[n] != b[n]) {
    printf("No");
    return 0;
  }
  sort(a2 + 1, a2 + n), sort(b2 + 1, b2 + n);
  for (register int i = 1; i < n; i++)
    if (a2[i] != b2[i]) {
      printf("No");
      return 0;
    }
  printf("Yes");
}
