#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, mod = 1e9 + 7, inf = 1e9 + 7;
long long n;
long long a[N], b[N], c[N], d[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    c[i] = a[i] - a[i - 1];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> b[i];
    d[i] = b[i] - b[i - 1];
  }
  sort(d + 2, d + n + 1);
  sort(c + 2, c + n + 1);
  for (long long i = 1; i <= n; i++) {
    if (d[i] != c[i]) return cout << "No", 0;
    ;
  }
  cout << "Yes";
}
