#include <bits/stdc++.h>
using namespace std;
long chafen1[100005] = {0};
long chafen2[100005] = {0};
long chafen3[100005] = {0};
long chafen4[100005] = {0};
int main() {
  int n;
  int i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    long temp = 0;
    cin >> temp;
    chafen1[i] = temp;
  }
  for (i = 1; i <= n; i++) {
    long temp = 0;
    cin >> temp;
    chafen2[i] = temp;
  }
  for (i = 1; i <= n; i++) {
    if (i != 1) chafen3[i] = chafen1[i] - chafen1[i - 1];
  }
  for (i = 1; i <= n; i++) {
    if (i != 1) chafen4[i] = chafen2[i] - chafen2[i - 1];
  }
  if (chafen1[1] != chafen2[1] || chafen1[n] != chafen2[n]) {
    printf("No");
    return 0;
  }
  sort(chafen3 + 2, chafen3 + n + 1);
  sort(chafen4 + 2, chafen4 + n + 1);
  int flag = 1;
  for (i = 2; i <= n; i++) {
    if (chafen3[i] != chafen4[i]) flag = 0;
  }
  if (flag)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
