#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n), b(n), idxs(n + 1), ans(n, n);
  multiset<long long> s1, s2;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    idxs[a[i]] = i;
  }
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
    if (idxs[b[i]] < i) {
      s1.insert(i - idxs[b[i]]);
    } else {
      s2.insert(idxs[b[i]] - i);
    }
  }
  for (long long i = 0; i < n; i++) {
    while (s1.size() && *s1.begin() == i) {
      s2.insert(-i);
      s1.erase(s1.find(i));
    }
    if (s1.size()) {
      ans[i] = min(ans[i], *s1.begin() - i);
    }
    if (s2.size()) {
      ans[i] = min(ans[i], i + *s2.begin());
    }
    assert(s2.count(idxs[b[i]] - i));
    s2.erase(s2.find(idxs[b[i]] - i));
    s1.insert(n - idxs[b[i]] + i);
  }
  for (long long i = 0; i < n; i++) cout << ans[i] << '\n';
  return 0;
}
