#include <bits/stdc++.h>
using namespace std;
long long n, c[100005], t[100005];
int main() {
  cin >> n;
  long long last;
  for (long long i = 1; i <= n; i++) {
    cin >> c[i];
    if (i == 1) last = c[i];
    c[i - 1] = c[i] - c[i - 1];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> t[i];
    if (i == 1 && t[i] != last) {
      cout << "No";
      return 0;
    }
    t[i - 1] = t[i] - t[i - 1];
  }
  if (t[n] != c[n]) {
    cout << "No";
    return 0;
  }
  sort(c + 1, c + n);
  sort(t + 1, t + n);
  for (long long i = 1; i < n; i++) {
    if (c[i] != t[i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
