#include <bits/stdc++.h>
using namespace std;
long long powmod(long long base, long long exp, long long MOD) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % MOD;
    base = (base * base) % MOD;
    exp /= 2;
  }
  return (res % MOD);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<long long> c(n), t(n);
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++) cin >> t[i];
  bool flag = 1;
  if (t[0] != c[0] || t[n - 1] != c[n - 1]) flag = 0;
  vector<int> x, y;
  for (int i = 0; i < n - 1; i++) {
    c[i] = c[i + 1] - c[i];
    t[i] = t[i + 1] - t[i];
  }
  sort(c.begin(), c.end());
  sort(t.begin(), t.end());
  if (t != c) flag = 0;
  if (flag == 0)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
