#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n), b(n), da(n - 1), db(n - 1);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if (i) da[i - 1] = a[i] - a[i - 1];
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
    if (i) db[i - 1] = b[i] - b[i - 1];
  }
  sort(da.begin(), da.end());
  sort(db.begin(), db.end());
  puts(da == db && a[0] == b[0] && a[n - 1] == b[n - 1] ? "Yes" : "No");
  return 0;
}
