#!/usr/bin/env ruby n=gets.chomp.to_i a=gets.split.map(&:to_i) a=a.sort c=0 a.each.with_index(1) do |e, i| c+=(e-i).abs end puts c