#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e9 + 7;
const long long int mod = 998244353;
long long int mini(long long int a, long long int b) {
  if (a >= b) return b;
  return a;
}
long long int maxi(long long int a, long long int b) {
  if (a >= b) return a;
  return b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long int n;
  cin >> n;
  vector<long long int> C(n + 1), T(n + 1);
  for (long long int i = 1; i <= n; i++) cin >> C[i];
  for (long long int i = 1; i <= n; i++) cin >> T[i];
  vector<long long int> diff1, diff2;
  for (long long int i = 2; i <= n; i++)
    diff1.push_back(C[i] - C[i - 1]), diff2.push_back(T[i] - T[i - 1]);
  sort(diff1.begin(), diff1.end());
  sort(diff2.begin(), diff2.end());
  if (diff1 == diff2 && C[1] == T[1] && C[n] == T[n])
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
