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