https://www.acmicpc.net/problem/2012
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] expectRank = new int[n]; // ์์ ๋ฑ์๋ฅผ ๋ด์ ๋ฐฐ์ด
long disSat = 0; // ์ต์ ๋ถ๋ง๋์ ํฉ
for (int i = 0; i < n; i++) {
expectRank[i] = sc.nextInt();
}
Arrays.sort(expectRank); // ์์ ๋ฑ์๋ฅผ ์ค๋ฆ์ฐจ์ ์ ๋ ฌ
for (int i = 0; i < n; i++) {
disSat += Math.abs(expectRank[i] - (i+1)); // (|A - B|) ๋ถ๋ง๋์ ์ด ํฉ์ ์ต์๋ก ํ๊ธฐ
}
System.out.println(disSat);
}
}