#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  scanf("%d", &n);
  vector<int> a(n + 1), b(n + 1);
  map<int, int> cnt;
  set<int> st;
  set<int>::iterator it;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    a[x] = i;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    b[i] = i - a[x];
    st.insert(b[i]);
    cnt[b[i]]++;
  }
  int ans;
  for (int i = 0; i < n; ++i) {
    it = st.lower_bound(i);
    ans = INT_MAX;
    if (it != st.end()) ans = min(ans, *it - i);
    if (it != st.begin()) ans = min(ans, i - *(--it));
    printf("%d\n", ans);
    cnt[b[i]]--;
    if (cnt[b[i]] == 0) st.erase(b[i]);
    cnt[b[i] + n]++;
    st.insert(b[i] + n);
  }
}
