#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
int n;
int a[100005], b[100005], reva[100005], revb[100005];
multiset<int> s;
int srch(int k) {
  int res = INF;
  multiset<int>::iterator it = s.lower_bound(k);
  if (it != s.end()) res = (*it) - k;
  if (it != s.begin()) {
    --it;
    res = min(res, k - (*it));
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]), --a[i], reva[a[i]] = i;
  for (int i = 0; i < n; ++i) scanf("%d", &b[i]), --b[i], revb[b[i]] = i;
  for (int i = 0; i < n; ++i) s.insert(reva[i] - revb[i]);
  for (int i = 0; i < n; ++i) {
    int tmp = srch(-i);
    s.erase(s.find(reva[b[i]] - i));
    s.insert(reva[b[i]] - i - n);
    printf("%d\n", tmp);
  }
  return 0;
}
