#include <bits/stdc++.h>
using namespace std;
map<long long, int> mp;
int a[100001], b[100001];
int main() {
  int n, i;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) cin >> b[i];
  if (a[1] != b[1] || a[n] != b[n]) {
    cout << "No";
    return 0;
  }
  for (i = 1; i < n; i++) mp[b[i + 1] - b[i]]++;
  for (i = 1; i < n; i++)
    if (!mp[a[i + 1] - a[i]]--) {
      cout << "No";
      return 0;
    }
  cout << "Yes";
}
