#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
int c[N], t[N];
vector<int> x, y;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  for (int i = 1; i < n; i++) {
    x.push_back(c[i] - c[i - 1]);
    y.push_back(t[i] - t[i - 1]);
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if (c[0] != t[0] || c[n - 1] != t[n - 1] || x != y) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
  return 0;
}
