#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
int n, a[MAXN], b[MAXN], A, B;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (i == 1) A = a[1];
  }
  for (int i = n; i; --i) {
    a[i] = a[i] - a[i - 1];
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &b[i]);
    if (i == 1) B = b[1];
  }
  for (int i = n; i; --i) {
    b[i] = b[i] - b[i - 1];
  }
  sort(a + 1, a + 1 + n);
  sort(b + 1, b + 1 + n);
  bool flag = true;
  for (int i = 1; i <= n; ++i) {
    if (a[i] != b[i]) {
      flag = false;
    }
  }
  if (flag && A == B) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}
