#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
const long long mod = (long long)1e9 + 7;
const long long MOD = (long long)998244353;
const long long INF = (long long)1e18;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << endl;
  err(++it, args...);
}
void solve() {
  long long n;
  cin >> n;
  long long a[n], b[n];
  vector<long long> A, B;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    if (i) A.push_back(abs(a[i] - a[i - 1]));
  }
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    cin >> b[i];
    if (i) B.push_back(abs(b[i] - b[i - 1]));
  }
  sort((A).begin(), (A).end());
  sort((B).begin(), (B).end());
  cout << (a[0] == b[0] and A == B ? "Yes" : "No");
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  solve();
  return 0;
}
