#include <bits/stdc++.h>
using namespace std;
const int maxn = 200001;
int n, a[maxn], b[maxn], init[maxn];
multiset<int> s;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    init[a[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &b[i]);
    init[b[i]] = i - init[b[i]];
    s.insert(init[b[i]]);
  }
  for (int i = 1; i <= n; ++i) {
    multiset<int>::iterator it = s.lower_bound(i - 1);
    int result = ~0U >> 2;
    if (it != s.end()) {
      result = min(result, *it - i + 1);
    }
    if (it != s.begin()) {
      --it;
      result = min(result, -(*it - i + 1));
    }
    s.erase(s.find(init[b[i]]));
    init[b[i]] += n;
    s.insert(init[b[i]]);
    printf("%d\n", result);
  }
  return 0;
}
