#include <bits/stdc++.h>
using namespace std;
int A[(100100)], Ai[(100100)];
int B[(100100)], Bi[(100100)];
int N;
void ler(int *v, int *vi) {
  for (int i = 0; i < N; i++) {
    scanf(" %d", v + i);
    v[i]--;
  }
  for (int i = 0; i < N; i++) {
    vi[v[i]] = i;
  }
}
multiset<int> S1, S2;
int minimo(int i) {
  int a = (S1.size() > 0 ? (*S1.begin()) : (1 << 30));
  int b = (S2.size() > 0 ? (*S2.begin()) : (1 << 30));
  return min(a + i, b - i);
}
int main() {
  scanf(" %d", &N);
  ler(A, Ai);
  ler(B, Bi);
  S1.clear();
  S2.clear();
  for (int i = 0; i < N; i++) {
    if (Bi[i] <= Ai[i]) {
      S1.insert(Ai[i] - Bi[i]);
    } else {
      S2.insert(Bi[i] - Ai[i]);
    }
  }
  for (int i = 0; i < N; i++) {
    printf("%d\n", minimo(i));
    while (S2.size() > 0 && ((*S2.begin()) == i)) {
      S2.erase(S2.begin());
      S1.insert(-i);
    }
    int x = B[i];
    S1.erase(S1.find(Ai[x] - i));
    S2.insert(N - Ai[x] + i);
  }
  return 0;
}
