#include <bits/stdc++.h>
const int Inf = 2e9;
long long LINF = (long long)4e18;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> b(n);
  for (auto &x : a) cin >> x;
  for (auto &x : b) cin >> x;
  vector<long long> t1, t2;
  for (int i = 1; i < n; i++) {
    t1.emplace_back(a[i] - a[i - 1]);
  }
  for (int i = 1; i < n; i++) {
    t2.emplace_back(b[i] - b[i - 1]);
  }
  sort((t1).begin(), (t1).end());
  sort((t2).begin(), (t2).end());
  if (t1 == t2 && a[0] == b[0] && a.back() == b.back())
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
