#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 1000 + 10, mod = 1e9 + 7;
int a[N], b[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  if (a[0] != b[0]) return cout << "No" << endl, 0;
  for (int i = 0; i < n - 1; i++) a[i] = a[i + 1] - a[i];
  for (int i = 0; i < n - 1; i++) b[i] = b[i + 1] - b[i];
  n--;
  sort(a, a + n);
  sort(b, b + n);
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) return cout << "No" << endl, 0;
  cout << "Yes" << endl;
}
