#include <bits/stdc++.h>
using namespace std;
const long long sz = 1e5 + 10;
multiset<int> lst;
long long a[sz], b[sz], posa[sz], posb[sz];
int main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    posa[a[i]] = i;
  }
  for (long long i = 1; i <= n; ++i) {
    scanf("%lld", &b[i]);
    posb[b[i]] = i;
    long long diff = posa[b[i]] - posb[b[i]];
    lst.insert(diff);
  }
  long long cyc = 0;
  for (long long i = 1; i <= n; ++i) {
    long long ans = (1LL << 61);
    auto it = lst.lower_bound(0);
    if (it != lst.end()) ans = min(ans, abs(*it + cyc));
    it = lst.lower_bound(-cyc);
    if (it != lst.end()) ans = min(ans, abs(*it + cyc));
    if (it != lst.begin()) ans = min(ans, abs(*(--it) + cyc));
    printf("%lld\n", ans);
    cyc++;
    long long diff = posa[b[i]] - posb[b[i]];
    lst.erase(lst.find(diff));
    diff = (posa[b[i]] - n) - cyc;
    lst.insert(diff);
  }
  return 0;
}
