#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, a[N], b[N], x[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i]);
    if (i > 1) a[i - 1] = x[i] - x[i - 1];
  }
  int st = x[1], ed = x[n];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i]);
    if (i > 1) b[i - 1] = x[i] - x[i - 1];
  }
  if (x[1] != st || x[n] != ed) {
    puts("No");
    return 0;
  }
  sort(a + 1, a + n);
  sort(b + 1, b + n);
  for (int i = 1; i < n; i++)
    if (a[i] != b[i]) {
      puts("No");
      return 0;
    }
  puts("Yes");
  return 0;
}
