#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n;
int a[N], b[N];
vector<int> v1, v2;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  if (a[1] != b[1] || a[n] != b[n]) {
    cout << "No\n";
    return 0;
  }
  for (int i = 2; i <= n; i++) {
    v1.push_back(a[i] - a[i - 1]);
    v2.push_back(b[i] - b[i - 1]);
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  if (v1 != v2)
    cout << "NO\n";
  else
    cout << "YES\n";
}
