#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int N, c[MAXN], t[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  int fc = 0;
  int ft = 0;
  for (int i = 0; i < N; i++) {
    cin >> c[i];
    if (i)
      c[i - 1] = c[i] - c[i - 1];
    else
      fc = c[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> t[i];
    if (i)
      t[i - 1] = t[i] - t[i - 1];
    else
      ft = t[i];
  }
  if (ft != fc || c[N - 1] != t[N - 1]) {
    cout << "No";
    return 0;
  }
  sort(c, c + N - 1);
  sort(t, t + N - 1);
  for (int i = 0; i < N - 1; i++) {
    if (c[i] != t[i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}
