#include <bits/stdc++.h>
using namespace std;
int n;
int a[111111];
int b[111111];
map<int, int> s;
int dist[111111];
int pos[111111];
int main(void) {
  istream_iterator<int> in(cin);
  n = *in++;
  for (int i = 1; i <= n; i++) a[i] = *in++;
  for (int i = 1; i <= n; i++) b[i] = *in++;
  for (int i = 1; i <= n; i++) pos[b[i]] = i;
  for (int i = 1; i <= n; i++) {
    dist[a[i]] = pos[a[i]] - i;
    if (s.find(dist[a[i]]) == s.end()) {
      s.insert(make_pair(dist[a[i]], 1));
    } else {
      s[dist[a[i]]]++;
    }
  }
  for (int i = 0; i < n; i++) {
    int ans = 1 << 29;
    map<int, int>::iterator j = s.lower_bound(i);
    if (j == s.end()) {
      j--;
      ans = min(ans, abs(j->first - i));
    } else {
      ans = min(ans, abs(j->first - i));
      if (j != s.begin()) {
        j--;
        ans = min(ans, abs(j->first - i));
      }
    }
    cout << ans << "\n";
    if (s[dist[b[i + 1]]] == 1)
      s.erase(dist[b[i + 1]]);
    else
      s[dist[b[i + 1]]]--;
    dist[b[i + 1]] += n;
    s[dist[b[i + 1]]]++;
  }
  return 0;
}
