#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int gakki = 5 + 2 + 1 + 19880611 + 1e9;
const int MAXN = 2e5 + 5, MAXM = 2e5 + 5;
long long c[100005], t[100005];
long long cha1[100005], cha2[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  if (n == 2) {
    if (c[1] != t[1] || c[n] != t[n]) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
    return 0;
  }
  if (c[1] != t[1] || c[n] != t[n]) {
    cout << "No" << endl;
    return 0;
  }
  bool flag = 1;
  for (int i = 1; i <= n; i++) {
    if (c[i] != t[i]) {
      flag = 0;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
    return 0;
  }
  for (int i = 2; i <= n; i++) {
    cha1[i - 1] = c[i] - c[i - 1];
    cha2[i - 1] = t[i] - t[i - 1];
  }
  sort(cha1 + 1, cha1 + n);
  sort(cha2 + 1, cha2 + n);
  flag = 1;
  for (int i = 1; i <= n - 1; i++) {
    if (cha1[i] != cha2[i]) {
      flag = 0;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
