#include <bits/stdc++.h>
using namespace std;
long long n, c[200100], t[200100], d = 0;
set<long long> s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  vector<long long> a, b;
  for (int i = 1; i < n; i++) {
    a.push_back(c[i] - c[i - 1]);
    b.push_back(t[i] - t[i - 1]);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (c[0] != t[0] or c[n - 1] != t[n - 1] or a != b) {
    cout << "No";
    return 0;
  }
  cout << "Yes";
}
