#include <bits/stdc++.h>
using namespace std;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e6, M = N;
vector<int> g[N];
int a[N], b[N];
multiset<int> my;
multiset<int>::iterator it;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, n, k, j, x, y, val;
  cin >> n;
  for (i = 0; i < n; i++) cin >> x, a[x] = i;
  for (i = 0; i < n; i++) cin >> b[i], my.insert(i - a[b[i]]);
  for (i = 0; i < n; i++) {
    int ans = n;
    it = my.lower_bound(i);
    if (it != my.end()) ans = min(ans, *it - i);
    if (it != my.begin()) it--, ans = min(ans, -(*it) + i);
    my.erase(my.find(i - a[b[i]]));
    my.insert(n - a[b[i]] + i);
    cout << ans << endl;
  }
  return 0;
}
