#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long a[100005], b[100005], l[100005], l2[100005];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) cin >> b[i];
  for (long long i = 2; i <= n; i++) {
    l[i] = a[i - 1] - a[i];
    l2[i] = b[i - 1] - b[i];
  }
  sort(l + 2, l + n + 1);
  sort(l2 + 2, l2 + n + 1);
  for (long long i = 2; i <= n; i++) {
    if (l[i] != l2[i]) {
      cout << "No";
      return 0;
    }
  }
  if (a[1] != b[1] || a[n] != b[n]) {
    cout << "No";
  } else
    cout << "Yes";
  return 0;
}
