#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
int n, a[N], b[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  if (a[0] != b[0] || a[n - 1] != b[n - 1]) return !(cout << "No" << endl);
  vector<int> l, r;
  for (int i = 1; i < n; i++)
    l.push_back(a[i] - a[i - 1]), r.push_back(b[i] - b[i - 1]);
  sort(l.begin(), l.end());
  sort(r.begin(), r.end());
  if (l == r)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
