#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * flag;
}
const long long N = 2e5 + 5;
long long n, a[N], b[N];
bool flag = false;
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = 1; i <= n; i++) b[i] = read();
  if (a[1] != b[1] || a[n] != b[n]) {
    cout << "No" << endl;
    return 0;
  }
  for (long long i = 1; i <= n - 1; i++)
    a[i] = a[i + 1] - a[i], b[i] = b[i + 1] - b[i];
  sort(a + 1, a + n);
  sort(b + 1, b + n);
  for (long long i = 1; i <= n - 1; i++) {
    if (a[i] != b[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
