#include <bits/stdc++.h>
using namespace std;
int A[150010], B[150010], Da[150010], Db[150010], N, i;
int main() {
  cin >> N;
  for (i = 1; i <= N; ++i) scanf("%d", &A[i]);
  for (i = 1; i <= N; ++i) scanf("%d", &B[i]);
  if (A[1] != B[1] || A[N] != B[N]) return puts("No"), 0;
  for (i = 2; i <= N; ++i) Da[i] = A[i] - A[i - 1];
  for (i = 2; i <= N; ++i) Db[i] = B[i] - B[i - 1];
  sort(Da + 2, Da + N + 1), sort(Db + 2, Db + N + 1);
  for (i = 2; i <= N; ++i)
    if (Da[i] != Db[i]) return puts("No"), 0;
  puts("Yes");
}
