#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, i, j;
  cin >> n;
  int c[n], t[n];
  for (i = 0; i < n; ++i) cin >> c[i];
  for (i = 0; i < n; ++i) cin >> t[i];
  if (c[0] != t[0]) {
    cout << "No";
    return 0;
  }
  if (c[n - 1] != t[n - 1]) {
    cout << "No";
    return 0;
  }
  vector<int> cd, td;
  for (i = 1; i < n; ++i) {
    cd.push_back(c[i] - c[i - 1]);
  }
  for (i = 1; i < n; ++i) {
    td.push_back(t[i] - t[i - 1]);
  }
  sort(cd.begin(), cd.end());
  sort(td.begin(), td.end());
  if (cd != td)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
