#include <bits/stdc++.h>
using namespace std;
long long s[100005], t[100005];
vector<long long> s1, s2;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> s[i];
    if (i != 0) s1.push_back(s[i] - s[i - 1]);
  }
  for (long long i = 0; i < n; ++i) {
    cin >> t[i];
    if (i != 0) s2.push_back(t[i] - t[i - 1]);
  }
  sort(s1.begin(), s1.end());
  sort(s2.begin(), s2.end());
  long long flag = 0;
  if (s[0] != t[0] || s[n - 1] != t[n - 1]) flag = 1;
  for (long long i = 0; i < n - 1; i++) {
    if (s2[i] != s1[i]) {
      flag = 1;
      break;
    }
  }
  if (flag == 1)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}
