#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int> > c(2, vector<int>(n));
  for (int x = 0; x < 2; x++) {
    for (int i = 0; i < n; i++) cin >> c[x][i];
    for (int i = n - 1; i >= 1; i--) c[x][i] -= c[x][i - 1];
    sort(c[x].begin() + 1, c[x].end());
  }
  cout << (c[0] == c[1] ? "Yes" : "No") << endl;
}
