#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ar1[n], ar2[n];
  for (int i = 0; i < n; i++) cin >> ar1[i];
  for (int i = 0; i < n; i++) cin >> ar2[i];
  bool flag = true;
  if (ar1[0] != ar2[0] || ar1[n - 1] != ar1[n - 1]) flag = false;
  std::vector<int> ar1_dif, ar2_dif;
  for (int i = 1; i < n; i++) {
    ar1_dif.push_back(ar1[i] - ar1[i - 1]);
    ar2_dif.push_back(ar2[i] - ar2[i - 1]);
  }
  sort(ar1_dif.begin(), ar1_dif.end());
  sort(ar2_dif.begin(), ar2_dif.end());
  if (ar1_dif != ar2_dif) flag = false;
  if (!flag)
    cout << "No";
  else
    cout << "Yes";
  cout << endl;
}
