#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T& x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  x *= f;
}
template <typename T, typename... Args>
void read(T& x, Args&... args) {
  read(x), read(args...);
}
template <typename T>
void write(T x) {
  if (x < 0) putchar('-'), write(-x);
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const long long maxn = 100200;
long long a[maxn], b[maxn], n;
map<long long, long long> t;
signed main() {
  read(n);
  for (long long i = 1; i <= n; ++i) read(a[i]);
  for (long long i = 1; i <= n; ++i) read(b[i]);
  for (long long i = 1; i < n; ++i) {
    t[abs(a[i] - a[i + 1])]++;
    t[abs(b[i] - b[i + 1])]--;
  }
  if (a[1] != b[1] || a[n] != b[n]) {
    puts("No");
    return 0;
  }
  for (auto g : t) {
    if (g.second != 0) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}
