#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 5;
int n;
int c[maxN], t[maxN];
int dc[maxN], dt[maxN];
void ReadInput() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    dc[i] = i > 0 ? c[i] - c[i - 1] : 0;
  }
  sort(dc + 1, dc + n);
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    dt[i] = i > 0 ? t[i] - t[i - 1] : 0;
  }
  sort(dt + 1, dt + n);
}
bool Check() {
  for (int i = 1; i < n; i++)
    if (dc[i] != dt[i]) return false;
  return true;
}
void Solve() {
  if (c[0] != t[0]) {
    cout << "No";
    return;
  }
  if (Check())
    cout << "Yes";
  else
    cout << "No";
}
int main() {
  ReadInput();
  Solve();
}
