#include <bits/stdc++.h>
using namespace std;
const long long A = 100000000000000LL, N = 100228;
multiset<long long>::iterator p;
multiset<long long> g;
long long i, j, n, o, m, a[N], b[N], c[N];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i], c[a[i]] = i;
  for (i = 1; i <= n; i++) cin >> b[i], g.insert(i - c[b[i]]);
  for (i = 1; i <= n; i++) {
    p = g.lower_bound(i - 1);
    o = (*p) - (i - 1);
    if (p != g.begin()) o = min(o, (i - 1) - (*(--p)));
    cout << o << "\n";
    g.erase(g.find(i - c[b[i]]));
    g.insert((n + i) - c[b[i]]);
  }
}
