// Arup Guha
// 1/11/2024
// Solution to Kattis Problem bst.
// https://open.kattis.com/problems/bst
// Used to illustrate use of TreeMap.

import java.util.*;
import java.io.*;

public class bst {

	public static void main(String[] args) throws Exception {
	
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(stdin.readLine());

		// Set up map. Will map value --> depth in tree.
		TreeMap<Integer,Integer> map = new TreeMap<Integer,Integer>();
		
		StringBuffer sb = new StringBuffer();
		
		// Get first item. Its depth is 0.
		int root = Integer.parseInt(stdin.readLine());
		map.put(root, 0);
		sb.append("0\n");
		long res = 0;
		
		// Process rest.
		for (int i=0; i<n-1; i++) {
		
			// Get next.
			int value = Integer.parseInt(stdin.readLine());
			
			// Try both immediate neighbors.
			Integer low = map.lowerKey(value);
			Integer high = map.higherKey(value);
			int newd = -1;
			
			// high is parent.
			if (low == null) 
				newd = map.get(high) + 1;
				
			// low is parent
			else if (high == null) 
				newd = map.get(low) + 1;

			// Get node further down.
			else  
				newd = Math.max(map.get(low), map.get(high)) + 1;

			// Update result, add to buffer and add entry to map.
			res += newd;
			map.put(value, newd);
			sb.append(res+"\n");
		}
		
		// Ta da!
		System.out.print(sb);
	}
}