#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int N;
long long c[maxn], t[maxn];
unordered_map<long long, int> cnt1, cnt2;
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%lld", &c[i]);
  }
  for (int i = 1; i <= N; ++i) {
    scanf("%lld", &t[i]);
  }
  if (c[1] != t[1] || c[N] != t[N]) {
    printf("No\n");
    return 0;
  }
  for (int i = 1; i < N; ++i) {
    ++cnt1[c[i] - c[i + 1]];
    ++cnt2[t[i] - t[i + 1]];
  }
  bool ok = 1;
  for (auto& e : cnt1) {
    if (cnt2[e.first] != e.second) {
      ok = 0;
    }
  }
  if (ok) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}
