namespace AtCoder; #nullable enable using System.Numerics; static class Extensions { public static T[] Repeat(this int time, Func F) => Enumerable.Range(0, time).Select(_ => F()).ToArray(); } class AtCoder { object? Solve() { var n = Int(); var az = n.Repeat(() => Int() - 1); var sz = new int[n + 1]; for (var i = 1; i <= n; i++) sz[i] = sz[i - 1] + az[i - 1]; var m = az.Max(); var u = (m + 1) * n * 2 + 1; var ans = (long)n * (n - 1) / 2 + 1; var mods = new int[u * 2]; mods[u]++; for (var v = 0; v <= m; v++) { var lc = 0; for (var i = 1; i <= n; i++) { var k = sz[i] - v * i; var ku = k + u; if (az[i - 1] == v) { ans -= lc; lc++; } else { lc = mods[ku]; } mods[ku]++; } for (var i = 1; i <= n; i++) { var k = sz[i] - v * i; var ku = k + u; mods[ku]--; } } return ans; } public static void Main() => new AtCoder().Run(); public void Run() { var res = Solve(); if (res != null) { if (res is bool yes) res = yes ? "Yes" : "No"; sw.WriteLine(res); } sw.Flush(); } string[] input = Array.Empty(); int iter = 0; readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false }; string String() { while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Trim().Split(' '), 0); return input[iter++]; } T Input() where T : IParsable => T.Parse(String(), null); int Int() => Input(); void Out(object? x, string? separator = null) { separator ??= Environment.NewLine; if (x is System.Collections.IEnumerable obj and not string) { var firstLine = true; foreach (var item in obj) { if (!firstLine) sw.Write(separator); firstLine = false; sw.Write(item); } } else sw.Write(x); sw.WriteLine(); } }