#include <bits/stdc++.h>
using namespace std;
int n;
int a[110000];
int b[110000];
int a1[110000];
int b1[110000];
multiset<int> s;
int f(int x) {
  int ans = n + n;
  multiset<int>::iterator it = s.lower_bound(x);
  if (it != s.end()) ans = min(ans, *it - x);
  if (it != s.begin()) it--, ans = min(ans, x - *it);
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i], a[i]--, a1[a[i]] = i;
  for (int j = 0; j < n; ++j) cin >> b[j], b[j]--, b1[b[j]] = j;
  for (int i = 0; i < n; ++i) s.insert(a1[i] - b1[i]);
  for (int i = 0; i < n; ++i) {
    cout << f(-i) << "\n";
    int p = a1[b[i]] - b1[b[i]];
    s.erase(s.find(p));
    s.insert(p - n);
  }
}
