#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long INF = 1e9 + 10;
void source() {
  long long n;
  cin >> n;
  vector<long long> a(n + 1), b(n + 1), arr1, arr2;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    arr1.push_back(a[i] - a[i - 1]);
  }
  for (long long i = 1; i <= n; i++) {
    cin >> b[i];
    arr2.push_back(b[i] - b[i - 1]);
  }
  sort((arr1).begin(), (arr1).end());
  sort((arr2).begin(), (arr2).end());
  cout << ((a[1] == b[1] && arr1 == arr2) ? "Yes" : "No");
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  source();
  return 0;
}
