#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long a[100005], b[100005];
int main() {
  long long n, k, t, num1, num2;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> k;
    if (i == 0) {
      num1 = k;
      a[i] = k;
    } else
      a[i] = k - t;
    t = k;
  }
  for (int i = 0; i < n; i++) {
    cin >> k;
    if (i == 0) {
      num2 = k;
      b[i] = k;
    } else
      b[i] = k - t;
    t = k;
  }
  sort(a, a + n);
  sort(b, b + n);
  int flag = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      flag = 1;
      break;
    }
  }
  if (flag == 0 && num1 == num2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
