#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
vector<int> V1, V2;
int t[N], c[N];
int main() {
  ios::sync_with_stdio(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];
  for (int i = 1; i < n; i++)
    V1.push_back(c[i + 1] - c[i]), V2.push_back(t[i + 1] - t[i]);
  sort(V1.begin(), V1.end());
  sort(V2.begin(), V2.end());
  if (c[1] != t[1]) return puts("No"), 0;
  for (int i = 0; i < V1.size(); i++)
    if (V1[i] != V2[i]) return puts("No"), 0;
  return puts("Yes"), 0;
}
