#include <bits/stdc++.h>
using namespace std;
const long long sz = 1e6 + 5;
void solve() {
  int n;
  cin >> n;
  long long a[n], b[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  if (a[0] != b[0] or a[n - 1] != b[n - 1]) {
    cout << "No\n";
    return;
  }
  vector<long long> d1, d2;
  for (int i = 0; i < n - 1; i++) {
    d1.push_back(a[i + 1] - a[i]);
    d2.push_back(b[i + 1] - b[i]);
  }
  sort(d1.begin(), d1.end());
  sort(d2.begin(), d2.end());
  if (d1 == d2)
    cout << "Yes";
  else
    cout << "No";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
