#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 77;
int n, a[N], b[N], posa[N], posb[N];
multiset<int> S;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    posa[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    posb[b[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    S.insert(posb[i] - posa[i]);
  }
  for (int i = 1; i <= n; i++) {
    int base = i - 1;
    int ans = 1e9;
    auto it = S.lower_bound(base);
    if (it != S.end()) {
      ans = abs(base - *it);
    }
    if (it != S.begin()) {
      it--;
      ans = min(ans, abs(base - *it));
    }
    printf("%d\n", ans);
    S.erase(S.find(i - posa[b[i]]));
    S.insert((n - posa[b[i]] + i));
  }
  return 0;
}
