#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long n, a[N], b[N];
vector<long long> da, db;
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]) {
    cout << "No";
    return 0;
  }
  for (int i = 0; i + 1 < n; i++) {
    da.push_back(a[i + 1] - a[i]);
    db.push_back(b[i + 1] - b[i]);
  }
  sort(da.begin(), da.end());
  sort(db.begin(), db.end());
  if (da == db)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
