import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int[] sums = new int[n + 1]; HashMap positions = new HashMap<>(); for (int i = 1; i <= n; i++) { int x = sc.nextInt(); sums[i] = x + sums[i - 1]; positions.put(x, i); } int[] limits = new int[n + 1]; for (int i = 1; i <= n; i++) { limits[i] = sc.nextInt(); } TreeSet used = new TreeSet<>(); used.add(0); used.add(n + 1); StringBuilder sb = new StringBuilder(); for (int i = 1; i <= n; i++) { long ans = 0; int base = positions.get(i); int left = used.lower(base); int right = used.higher(base); int current = left; for (int j = base; j < right; j++) { while (current < base && sums[j] - sums[current] > limits[i]) { current++; } ans += base - current; } sb.append(ans).append("\n"); used.add(base); } System.out.print(sb); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }