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