using static System.Math; using System.Collections.Generic; using System.Linq; using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); getAns(n, a); } static void getAns(int n, int[] a) { var b = new List(); var tc = 0; for (int i = 1; i < n; i++) { if (a[i] - a[i - 1] == 1) tc++; else { if (tc > 0) b.Add(tc); tc = 0; } } if (tc > 0) b.Add(tc); var ans = 0L; foreach (var x in b) ans += (long)x * (x + 1) / 2L; Console.WriteLine(ans); } }