#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = 1LL * INF * INF;
const int MAX = 1e5 + 7;
const double PI = acos(-1.);
const double EPS = 1e-8;
const int MOD = 1000 * 1000 * 1000 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n), x, y;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i) {
      x.push_back(a[i] - a[i - 1]);
    }
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    if (i) {
      y.push_back(b[i] - b[i - 1]);
    }
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if (a.back() != b.back() || a.front() != b.front() || x != y) {
    cout << "NO";
  } else {
    cout << "YES";
  }
  return 0;
}
