#include <bits/stdc++.h>
using namespace std;
const int Max = INT_MAX;
const long long INF = 0x3f3f3f3f;
int s[100005], a[100005];
multiset<int> sq;
int main() {
  int n, x;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    s[x] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    int ju = i - s[a[i]];
    sq.insert(ju);
  }
  for (int i = 0; i < n; i++) {
    multiset<int>::iterator it = sq.lower_bound(i);
    int minn = 200005;
    if (it != sq.end()) minn = min(minn, (*it) - i);
    if (it != sq.begin()) minn = min(minn, i - (*(--it)));
    sq.erase(sq.find(i - s[a[i]]));
    sq.insert((i + n) - s[a[i]]);
    cout << minn << endl;
  }
  return 0;
}
