import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int remein = 0; long count = 0; for (int i = 0; i < n; i++) { int x = sc.nextInt() + remein; remein = x - 1; count += Math.abs(remein); } System.out.println(count); } }