#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class c>
struct rge {
  c h, n;
};
template <class c>
rge<c> range(c h, c n) {
  return rge<c>{h, n};
}
template <class c, class F>
struct rgm {
  c h, n;
  F f;
};
template <class c, class F>
rgm<c, F> map_range(c b, c e, F f) {
  return rgm<c, F>{b, e, f};
}
template <class c, class F>
rgm<typename c::const_iterator, F> map_range(const c &x, F f) {
  return map_range(x.begin(), x.end(), f);
}
template <class c>
auto dud(c *r) -> decltype(cerr << *r);
template <class c>
char dud(...);
struct muu {
  template <class c>
  muu &operator<<(const c &) {
    return *this;
  }
  muu &operator()() { return *this; }
};
template <class c>
void mini(c &a, c b) {
  if (a > b) a = b;
}
template <class c>
void maxi(c &a, c b) {
  if (a < b) a = b;
}
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
ull get_hash(int n) {
  ull state = 0;
  int last;
  scanf("%d", &last);
  for (int _ = 0; _ < n - 1; ++_) {
    int x;
    scanf("%d", &x);
    ull diff = last - x;
    for (int i = 0; i < 10; ++i) diff ^= 12345ull * (diff % 123456789);
    state ^= diff;
    last = x;
  }
  return state * 143142303ull ^ last;
}
int main() {
  int n;
  scanf("%d", &n);
  if (get_hash(n) == get_hash(n))
    printf("Yes\n");
  else
    printf("No\n");
}
