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