#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, x, y;
  vector<int> a, b, c, d;
  cin >> n >> x;
  c.push_back(x);
  for (i = 1; i < n; i++) {
    cin >> y;
    a.push_back(y - x);
    x = y;
  }
  c.push_back(x);
  cin >> x;
  d.push_back(x);
  for (i = 1; i < n; i++) {
    cin >> y;
    b.push_back(y - x);
    x = y;
  }
  d.push_back(x);
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a == b && c == d)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
