#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 3;
int n, a[2][N], x, y;
void get(int oi) {
  scanf("%d", &x);
  a[oi][1] = x;
  for (int i = 2; i <= n; ++i) {
    scanf("%d", &y);
    a[oi][i] = y - x;
    swap(x, y);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= 1; ++i) get(i);
  if (a[0][1] != a[1][1]) {
    printf("No");
    return 0;
  }
  for (int i = 0; i <= 1; ++i) sort(a[i] + 1, a[i] + 1 + n);
  for (int i = 1; i <= n; ++i)
    if (a[0][i] != a[1][i]) {
      printf("No");
      return 0;
    }
  printf("Yes");
  return 0;
}
