#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  for (auto &c : a) cin >> c;
  for (auto &c : b) cin >> c;
  multiset<ll> d1, d2;
  for (ll i = 1; i < n; i++) d1.insert(a[i] - a[i - 1]);
  for (ll i = 1; i < n; i++) d2.insert(b[i] - b[i - 1]);
  cout << (a[0] == b[0] && d1 == d2 ? "Yes" : "No") << endl;
}
