#include <bits/stdc++.h>
using namespace std;
long long n, m, a[100100], b[100100];
int main() {
  long long i, j, k, p, q;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = 1; i <= n; i++) scanf("%lld", &b[i]);
  if (a[1] != b[1] || a[n] != b[n]) {
    puts("No");
    return 0;
  }
  for (i = n; i >= 2; i--) a[i] -= a[i - 1], b[i] -= b[i - 1];
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  for (i = 1; i <= n; i++) {
    if (a[i] != b[i]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}
