n = io.read("*n") t = {} for i = 1, n do t[i] = io.read("*n") end table.sort(t) len = 0 for i = 1, n do len = len + math.abs(t[i] - i) end print(len)