#include <bits/stdc++.h>
const int INF = ~0U >> 1;
using namespace std;
int a[100005], b[100005], C[100005];
multiset<int> s;
multiset<int>::iterator iter;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, rem;
  cin >> n;
  for (int i = 0; i != n; i++) {
    cin >> a[i];
    C[a[i]] = i;
  }
  for (int i = 0; i != n; ++i) {
    cin >> b[i];
    s.insert(i - C[b[i]]);
  }
  for (int i = 0; i != n; ++i) {
    iter = s.lower_bound(i);
    rem = INF;
    if (iter != s.end()) rem = min(rem, (*iter) - i);
    if (iter != s.begin()) rem = min(rem, i - (*(--iter)));
    cout << rem << endl;
    m = b[i];
    s.erase(s.find(i - C[m]));
    s.insert((i + n) - C[m]);
  }
  return 0;
}
