#include <bits/stdc++.h>
using namespace std;
int N, a[1000001], b[1000001], c[1000001];
multiset<int> preQ;
void read() {
  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];
    preQ.insert(i - c[b[i]]);
  }
}
void process() {
  int res;
  for (int i = 0; i < N; i++) {
    multiset<int>::iterator it = preQ.lower_bound(i);
    res = 1000001;
    if (it != preQ.end()) res = min(res, (*it) - i);
    if (it != preQ.begin()) res = min(res, i - (*(--it)));
    cout << res << endl;
    int t = b[i];
    preQ.erase(preQ.find(i - c[t]));
    preQ.insert((i + N) - c[t]);
  }
}
int main() {
  read();
  process();
  return 0;
}
