#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
const long long MOD = 1e9 + 7;
const long double pi = 3.14159265359;
long long n, d[N], u[N];
multiset<long long> s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> d[i];
  for (long long i = 0; i < n; i++) cin >> u[i];
  for (long long i = 1; i < n; i++) s.insert(d[i] - d[i - 1]);
  for (long long i = 1; i < n; i++) {
    if (s.find(u[i] - u[i - 1]) != s.end()) s.erase(s.find(u[i] - u[i - 1]));
  }
  cout << (d[0] == u[0] && d[n - 1] == u[n - 1] && s.size() == 0 ? "Yes"
                                                                 : "No");
  return 0;
}
