#include <bits/stdc++.h>
using namespace std;
const long long BINF = 9e18, LINF = 2e9, mod = 998244353, P = 179,
                Q = 1791791791;
const long long MAXN = 2e5 + 7;
long long a[MAXN], b[MAXN];
map<long long, long long> ma, mb;
void solve() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
    ma[a[i] - a[i - 1]]++;
  }
  for (long long i = 1; i <= n; ++i) {
    cin >> b[i];
    mb[b[i] - b[i - 1]]++;
  }
  if (ma == mb && a[1] == b[1] && a[n] == b[n])
    cout << "Yes";
  else
    cout << "No";
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cout.precision(40);
  solve();
  return 0;
}
