#include <bits/stdc++.h>
using namespace std;
const int nMax = 100010;
int n;
int a[nMax], b[nMax], c[nMax], d[nMax];
multiset<int> S;
int main() {
  int i, j, k, ans;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", a + i);
    c[a[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    scanf("%d", b + i);
    d[b[i]] = i;
  }
  S.clear();
  for (i = 1; i <= n; i++) S.insert(d[i] - c[i]);
  for (i = 0; i < n; i++) {
    multiset<int>::iterator it = S.lower_bound(i);
    ans = n;
    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(d[b[i + 1]] - c[b[i + 1]]));
    d[b[i + 1]] = n + i + 1;
    S.insert(d[b[i + 1]] - c[b[i + 1]]);
  }
  return 0;
}
