#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int N;
int A[MAXN], B[MAXN];
int ans[MAXN];
vector<int> ops[MAXN];
int main() {
  if (fopen("input.txt", "r")) {
    freopen("input.txt", "r", stdin);
  }
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 1, x; i <= N; i++) {
    cin >> x;
    A[x] = i;
  }
  for (int i = 1, x; i <= N; i++) {
    cin >> x;
    B[x] = i;
  }
  multiset<int> st;
  for (int i = 1; i <= N; i++) {
    st.insert(B[i] - A[i]);
    ops[B[i] - 1].push_back(B[i] - A[i]);
  }
  for (int i = 0; i < N; i++) {
    int ans = N;
    auto it = st.lower_bound(i);
    if (it != st.end()) {
      ans = min(ans, *it - i);
    }
    if (it != st.begin()) {
      it--;
      ans = min(ans, i - *it);
    }
    cout << ans << '\n';
    for (int x : ops[i]) {
      st.erase(st.find(x));
      st.insert(x + N);
    }
  }
}
