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