#include <bits/stdc++.h>
using namespace std;
int ve[212345], de[212345];
int main() {
  int n, m, k, b;
  scanf("%d", &n);
  vector<int> v, d;
  for (int i = 0; i < n; ++i) {
    scanf("%d", ve + i);
    if (i) v.push_back(ve[i] - ve[i - 1]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", de + i);
    if (i) d.push_back(de[i] - de[i - 1]);
  }
  if (ve[0] != de[0] || ve[n - 1] != de[n - 1]) {
    printf("No");
    return 0;
  }
  sort(v.begin(), v.end());
  sort(d.begin(), d.end());
  for (int i = 0; i < (int)v.size(); ++i) {
    if (v[i] != d[i]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
}
