#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
int p[MAX], b[MAX];
multiset<int> s;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    p[val] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    s.insert(i - p[b[i]]);
  }
  for (int i = 0; i < n; i++) {
    multiset<int>::iterator now = s.lower_bound(i);
    multiset<int>::iterator prev = now;
    if (now == s.end()) now--;
    if (prev == s.begin()) prev = s.end();
    prev--;
    cout << min(abs(i - *prev), abs(i - *now)) << endl;
    s.erase(s.find(i - p[b[i]]));
    s.insert(n + i - p[b[i]]);
  }
  return 0;
}
