#include <bits/stdc++.h>
using namespace std;
long long a[100010], b[100010], d1[100010], d2[100010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) cin >> a[i];
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) cin >> b[i];
  for (int i = 1, ThxDem = n; i < ThxDem; ++i) d1[i - 1] = a[i] - a[i - 1];
  for (int i = 1, ThxDem = n; i < ThxDem; ++i) d2[i - 1] = b[i] - b[i - 1];
  sort(d1, d1 + n);
  sort(d2, d2 + n);
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
    if (d1[i] != d2[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (a[0] == b[0] && a[n - 1] == b[n - 1])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
