#include <bits/stdc++.h>
using namespace std;
int A[100000 + 5], n;
int B[100000 + 5];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  for (int i = 0; i < n; i++) scanf("%d", &B[i]);
  vector<int> a, b;
  for (int i = 0; i < n - 1; i++) {
    a.push_back(A[i + 1] - A[i]);
    b.push_back(B[i + 1] - B[i]);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a != b || A[0] != B[0] || A[n - 1] != B[n - 1])
    cout << "NO\n";
  else
    cout << "YES\n";
  return 0;
}
