using System; using System.Collections.Generic; namespace test { static class Program { static void Main() { long n = long.Parse(Console.ReadLine()); string[] astr = Console.ReadLine().Split(' '); long[] a = new long[n]; for(int i = 0; i < n; i++) { a[i] = long.Parse(astr[i]); } long l = 0; long r = 0; long kosuu = 0; while (true) { if(l == a.Length) { break; } if (l == r) { if (l == a.Length - 1) { break; } else { if (a[l] + 1 == a[l + 1]) { r++; } else { l++; r++; } } } else { if (r+1 < a.Length && a[r] + 1 == a[r + 1]) { r++; } else { kosuu += (r - l+1) * (r - l ) / 2; if(r == a.Length) { break; } l = r+1; r = l; } } } Console.WriteLine(kosuu); } } }