#include <bits/stdc++.h>
using namespace std;
long long int c[1000005], t[1000005];
vector<long long int> C, T;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= n; i++) cin >> t[i];
  if (c[1] != t[1] || c[n] != t[n]) {
    cout << "NO";
    return 0;
  }
  for (int i = 1; i <= n - 1; i++) {
    C.push_back(c[i + 1] - c[i]);
    T.push_back(t[i + 1] - t[i]);
  }
  sort(C.begin(), C.end());
  sort(T.begin(), T.end());
  for (int i = 0; i <= n - 2; i++) {
    if (C[i] != T[i]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
