#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long arr1[n];
  for (int i = 0; i < n; i++) {
    cin >> arr1[i];
  }
  long long arr2[n];
  for (int i = 0; i < n; i++) {
    cin >> arr2[i];
  }
  vector<long long> p;
  vector<long long> q;
  for (int i = 1; i < n; i++) {
    p.push_back(arr1[i] - arr1[i - 1]);
    q.push_back(arr2[i] - arr2[i - 1]);
  }
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  if (p == q && arr1[0] == arr2[0] && arr1[n - 1] == arr2[n - 1]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
