#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int maxn = 1e5 + 10;
int n;
int c[maxn], t[maxn];
int arr[maxn], brr[maxn];
bool solve() {
  if (c[1] != t[1] || c[n] != t[n]) return false;
  for (int i = 2; i <= n; ++i)
    arr[i] = c[i] - c[i - 1], brr[i] = t[i] - t[i - 1];
  sort(arr + 2, arr + 1 + n);
  sort(brr + 2, brr + 1 + n);
  for (int i = 2; i <= n; ++i)
    if (arr[i] != brr[i]) return false;
  return true;
}
void RUN() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; ++i) scanf("%d", c + i);
    for (int i = 1; i <= n; ++i) scanf("%d", t + i);
    puts(solve() ? "Yes" : "No");
  }
}
int main() {
  RUN();
  return 0;
}
