#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
void test_case() {
  long long n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) cin >> b[i];
  if (a[0] != b[0] || a[n - 1] != b[n - 1]) {
    cout << "No";
    return;
  }
  for (long long i = 0; i < n - 1; i++)
    a[i] = a[i + 1] - a[i], b[i] = b[i + 1] - b[i];
  b[n - 1] = a[n - 1] = 1000000000;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (long long i = 0; i < n - 1; i++)
    if (a[i] != b[i]) {
      cout << "No";
      return;
    }
  cout << "Yes";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    test_case();
  }
  return 0;
}
