#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a - b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template <typename T>
inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v) {
    _in >> _i;
  }
  return _in;
}
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int a[2 * nv], b[2 * nv];
int inline solve() {
  ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
  ;
  int n;
  cin >> n;
  int x = 0, y = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i) {
      a[i - 1] = a[i] - a[i - 1];
    } else {
      x = a[0];
    }
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    if (i) {
      b[i - 1] = b[i] - b[i - 1];
    } else {
      y = b[0];
    }
  }
  if (x != y) return cout << "NO", 0;
  sort(a, a + n - 1);
  sort(b, b + n - 1);
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] != b[i]) return cout << "NO", 0;
  }
  cout << "YES";
  return 0;
}
int32_t main() {
  solve();
  return 0;
}
