#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, A[N], B[N], rev[N];
multiset<int> S;
void Del(int val) {
  auto it = S.lower_bound(val);
  if ((*it) == val) S.erase(it);
}
int Get(int base) {
  int Mn = N;
  auto it = S.lower_bound(base);
  if (it != S.end()) Mn = min(Mn, (*it) - base);
  if (it != S.begin()) it--, Mn = min(Mn, base - (*it));
  return (Mn);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]), rev[A[i]] = i;
  for (int i = 0; i < n; i++) scanf("%d", &B[i]), S.insert(i - rev[B[i]]);
  for (int i = 0; i < n; i++) {
    printf("%d\n", Get(i));
    Del(i - rev[B[i]]);
    S.insert(n - 1 - rev[B[i]] + i + 1);
  }
  return (0);
}
