#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n;
int ar[N], tar[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> tar[i];
  }
  if (ar[1] != tar[1] || ar[n] != tar[n]) {
    cout << "No" << '\n';
    return 0;
  }
  map<int, int> cnt;
  for (int i = 1; i < n; i++) {
    cnt[ar[i + 1] - ar[i]]++;
    cnt[tar[i + 1] - tar[i]]--;
  }
  for (auto x : cnt) {
    if (x.second) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';
  return 0;
}
