#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> ll;
typedef vector<long long> vl;
typedef vector<ll> vll;
typedef vector<vl> vvl;
template <typename T>
ostream &operator<<(ostream &o, vector<T> v) {
  if (v.size() > 0) o << v[0];
  for (unsigned i = 1; i < v.size(); i++) o << " " << v[i];
  return o << "\n";
}
template <typename U, typename V>
ostream &operator<<(ostream &o, pair<U, V> p) {
  return o << "(" << p.first << ", " << p.second << ") ";
}
template <typename T>
istream &operator>>(istream &in, vector<T> &v) {
  for (unsigned i = 0; i < v.size(); i++) in >> v[i];
  return in;
}
template <typename T>
istream &operator>>(istream &in, pair<T, T> &p) {
  in >> p.first;
  in >> p.second;
  return in;
}
multiset<long long> s;
long long query(long long n) {
  long long ans = LLONG_MAX;
  auto it = s.lower_bound(n);
  if (it != s.end()) ans = min(ans, (*it) - n);
  if (it != s.begin()) {
    it--;
    ans = min(ans, n - (*it));
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(20);
  long long n;
  cin >> n;
  vl a(n), b(n);
  vl pos_a(n), pos_b(n);
  cin >> a >> b;
  for (long long i = (0); i < (long long)n; i++)
    pos_a[a[i] - 1] = i, pos_b[b[i] - 1] = i;
  for (long long i = (0); i < (long long)n; i++) s.insert(pos_a[i] - pos_b[i]);
  for (long long i = (0); i < (long long)n; i++) {
    cout << query(-i) << "\n";
    long long temp = pos_a[b[i] - 1] - pos_b[b[i] - 1];
    s.erase(s.find(temp));
    s.insert(temp - n);
  }
  return 0;
}
