#include <bits/stdc++.h>
using namespace std;
multiset<int> s;
multiset<int>::iterator it;
int a[100010], b[100010];
int loc[100010];
int main() {
  int N, ans;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", a + i);
  for (int i = 0; i < N; i++) scanf("%d", b + i);
  for (int i = 0; i < N; i++) loc[a[i]] = i;
  for (int i = 0; i < N; i++) {
    s.insert(i - loc[b[i]]);
  }
  for (int i = 0; i < N; i++) {
    it = s.lower_bound(i);
    ans = 1000000000;
    if (it != s.end()) ans = min(ans, (*it) - i);
    if (it != s.begin()) {
      it--;
      ans = min(ans, i - (*it));
    }
    printf("%d\n", ans);
    it = s.find(i - loc[b[i]]);
    s.erase(it);
    s.insert(N - 1 - loc[b[i]] + i + 1);
  }
  return 0;
}
