#include <bits/stdc++.h>
using namespace std;
long long spf[101];
void sieve() {
  spf[1] = 1;
  for (long long i = 2; i < 101; i++) spf[i] = i;
  for (long long i = 4; i < 101; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < 101; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < 101; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
map<long long, long long> getfactor(long long a) {
  map<long long, long long> m;
  while (a > 1) {
    m[spf[a]]++;
    a /= spf[a];
  }
  return m;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
void solve() {
  long long n;
  cin >> n;
  long long ans[n];
  pair<long long, long long> p1[n], p2[n], temp[n];
  for (long long i = 0; i < n; i++) {
    cin >> p1[i].first;
    p1[i].first--;
    p1[i].second = i + 1;
  }
  for (long long i = 0; i < n; i++) {
    cin >> p2[i].first;
    p2[i].first--;
    p2[i].second = i + 1;
    temp[i] = p2[i];
  }
  sort(p1, p1 + n);
  sort(p2, p2 + n);
  multiset<long long> s1, s2;
  for (long long i = 0; i < n; i++) {
    s1.insert(p2[i].second - p1[i].second);
  }
  for (long long i = 0; i < n; i++) {
    long long a = 1e18, b = 1e18, c = 1e18, d = 1e18;
    if (s1.size()) {
      auto it = s1.lower_bound(i);
      if (it != s1.end()) a = *it - i;
      if (it != s1.begin()) {
        it--;
        b = i - *it;
      }
    }
    if (s2.size()) {
      auto it = s2.lower_bound(i);
      if (it != s2.end()) c = *it - i;
      if (it != s2.begin()) {
        it--;
        d = i - *it;
      }
    }
    long long curr = temp[i].first;
    s1.erase(s1.lower_bound(p2[curr].second - p1[curr].second));
    s2.insert(n - p1[curr].second + p2[curr].second);
    ans[i] = min(min(a, b), min(c, d));
  }
  for (long long i = 0; i < n; i++) cout << ans[i] << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
}
