#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int INF = 1 << 29;
int a[N], b[N], x[N], y[N];
map<int, int> m;
int query(int x) {
  int ans = INF;
  __typeof((m).begin()) it = m.lower_bound(x);
  if (it != m.end()) ans = it->first - x;
  if (it != m.begin()) --it, ans = min(ans, x - it->first);
  return ans;
}
int main() {
  int n, t;
  cin >> n;
  for (int i = 0; i < (int)(n); ++i) cin >> t, --t, a[i] = t, x[t] = i;
  for (int i = 0; i < (int)(n); ++i) cin >> t, --t, b[i] = t, y[t] = i;
  for (int i = 0; i < (int)(n); ++i) ++m[y[i] - x[i]];
  for (int i = 0; i < (int)(n); ++i) {
    cout << query(i) << endl;
    t = y[b[i]] - x[b[i]];
    if (--m[t] == 0) m.erase(t);
    ++m[t + n];
  }
}
