#include <bits/stdc++.h>
const long long base = 311, mod = 1e9 + 7, N = 2e5 + 11,
                inf = 0x3f3f3f3f3f3f3f3fLL;
using ull = unsigned long long;
using namespace std;
long long ans, n, a[N], id[N], b[N];
multiset<long long> s;
multiset<long long>::iterator it;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    id[a[i]] = i;
  }
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
    s.insert(i - id[b[i]]);
  }
  for (long long i = 0; i < n; i++) {
    ans = n;
    it = s.lower_bound(i);
    if (it != s.end()) {
      ans = min(ans, *it - i);
    }
    if (it != s.begin()) {
      it--;
      ans = min(ans, i - *it);
    }
    cout << ans << endl;
    it = s.find(i - id[b[i]]);
    s.erase(it);
    s.insert(i - id[b[i]] + n);
  }
}
