#include <bits/stdc++.h>
using namespace std;
int A[1 << 20];
int B[1 << 20];
int F(priority_queue<int> Q[], int n) {
  while (!Q[0].empty() && !Q[1].empty() && Q[0].top() == Q[1].top()) {
    Q[0].pop();
    Q[1].pop();
  }
  if (Q[0].empty()) return 4 * n;
  return -Q[0].top();
}
int main() {
  int n;
  scanf("%d", &n);
  int i;
  for (i = (0); i < (n); ++i) {
    int a;
    scanf("%d", &a);
    B[a - 1] = n - 1 - i;
  }
  for (i = (0); i < (n); ++i) {
    int a;
    scanf("%d", &a);
    A[a - 1] = n - 1 - i;
  }
  vector<pair<pair<int, int>, pair<int, int> > > v;
  for (i = (0); i < (n); ++i) {
    if (A[i] < B[i]) {
      v.push_back(
          make_pair(pair<int, int>(0, 0), pair<int, int>(B[i] - A[i], -1)));
      v.push_back(make_pair(pair<int, int>(B[i] - A[i], 1),
                            pair<int, int>(B[i] - A[i], -1)));
      v.push_back(make_pair(pair<int, int>(B[i] - A[i], 0),
                            pair<int, int>(A[i] - B[i], 1)));
      v.push_back(make_pair(pair<int, int>(n - A[i], 1),
                            pair<int, int>(A[i] - B[i], 1)));
      v.push_back(make_pair(pair<int, int>(n - A[i], 0),
                            pair<int, int>(n + B[i] - A[i], -1)));
      v.push_back(
          make_pair(pair<int, int>(n, 1), pair<int, int>(n + B[i] - A[i], -1)));
    } else {
      v.push_back(
          make_pair(pair<int, int>(0, 0), pair<int, int>(A[i] - B[i], 1)));
      v.push_back(make_pair(pair<int, int>(n - A[i], 1),
                            pair<int, int>(A[i] - B[i], 1)));
      v.push_back(make_pair(pair<int, int>(n - A[i], 0),
                            pair<int, int>(n + B[i] - A[i], -1)));
      v.push_back(make_pair(pair<int, int>(n + B[i] - A[i], 1),
                            pair<int, int>(n + B[i] - A[i], -1)));
      v.push_back(make_pair(pair<int, int>(n + B[i] - A[i], 0),
                            pair<int, int>(-(n + B[i] - A[i]), 1)));
      v.push_back(make_pair(pair<int, int>(n, 1),
                            pair<int, int>(-(n + B[i] - A[i]), 1)));
    }
  }
  sort((v).begin(), (v).end());
  priority_queue<int> Q[2][2];
  int pos = 0;
  for (i = (0); i < (n); ++i) {
    while (pos < int((v).size()) && v[pos].first.first <= i) {
      Q[(v[pos].second.second + 1) / 2][v[pos].first.second].push(
          -v[pos].second.first);
      ++pos;
    }
    int a = F(Q[0], n) - i;
    int b = F(Q[1], n) + i;
    printf("%d\n", min(a, b));
  }
  return 0;
};
