#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int b[maxn];
bool change(int x, int y, int n) {
  if (x == n - 1) {
    return (y == a[n - 1]);
  } else {
    if (y == a[x])
      return true;
    else {
      int t = y - a[x - 1] + a[x];
      if (change(x + 1, t, n)) {
        a[x] = y;
        return true;
      } else
        return false;
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  if (a[0] != b[0] || a[n - 1] != b[n - 1]) {
    cout << "No";
    return 0;
  }
  vector<int> vt;
  vector<int> vt1;
  for (int i = 1; i < n; i++) {
    vt.push_back(a[i] - a[i - 1]);
    vt1.push_back(b[i] - b[i - 1]);
  }
  sort(vt.begin(), vt.end());
  sort(vt1.begin(), vt1.end());
  cout << ((vt == vt1) ? "Yes" : "No");
  return 0;
}
