#include <bits/stdc++.h>
using namespace std;
const int INF = 100100l;
multiset<int> v;
int n, i, t, x, a[INF], c[INF];
int main() {
  cin >> n;
  for (i = 0; i < n && cin >> x; a[x] = i++)
    ;
  for (i = 0; i < n && cin >> c[i]; ++i) v.insert(i - a[c[i]]);
  for (i = 0; i < n; ++i) {
    auto it = v.lower_bound(i);
    int u = INF;
    if (it != v.end()) u = min(u, *it - i);
    if (it != v.begin()) u = min(u, i - *(--it));
    cout << u << '\n';
    v.erase(v.find(t = i - a[c[i]]));
    v.insert(t + n);
  }
  return 0;
}
