#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  deque<long long> pos, a, b;
  set<pair<long long, long long> > l, r, left;
  cin >> n;
  pos.resize(n);
  a.resize(n);
  b.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
    pos[a[i]] = i;
  }
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
    b[i]--;
    long long d = pos[b[i]] - i;
    if (d >= 0) {
      l.insert({d, b[i]});
      left.insert({n - 1 - pos[b[i]] + i + 1, b[i]});
    } else {
      r.insert({abs(d), b[i]});
      left.insert({abs(d), b[i]});
    }
  }
  long long ptr = -1;
  for (long long i = 0; i < n; i++) {
    if (ptr >= 0) {
      long long x = b[ptr];
      l.erase({pos[x] - ptr, x});
      r.insert({n - 1 - pos[x] + ptr + 1, x});
    }
    ptr++;
    while (left.size() && (*left.begin()).first == i) {
      pair<long long, long long> fir = (*left.begin());
      left.erase(left.begin());
      r.erase(fir);
      fir.first *= -1;
      l.insert(fir);
    }
    long long mn = 1e18;
    if (l.size()) mn = min(mn, (*l.begin()).first + i);
    if (r.size()) mn = min(mn, (*r.begin()).first - i);
    cout << mn << "\n";
  }
  return 0;
}
