#include <bits/stdc++.h>
using namespace std;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;
const int INF = 2 * 1e9;
long long c[100005], t[100005];
vector<long long> v[5];
int main() {
  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= n; i++) cin >> t[i];
  if (c[1] != t[1])
    cout << "No";
  else {
    bool x = 0;
    for (int i = 1; i <= n - 1; i++)
      v[0].push_back(c[i + 1] - c[i]), v[1].push_back(t[i + 1] - t[i]);
    sort(v[0].begin(), v[0].end());
    sort(v[1].begin(), v[1].end());
    for (int i = 0; i < n - 1; i++)
      if (v[0][i] != v[1][i]) x = 1;
    if (!x)
      cout << "Yes";
    else
      cout << "No";
  }
}
