Spirit Circle Observation
题号:NC239327
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

Potassium, a genius who masters soul conversion, is observing the world line of Potas. The world line can be divided into n parts and represented as an n-digit decimal number s (may have leading zeros) that reveals the property of time in the past and future of Potas.

For convenience, let denote the concatenation of digits a, b, c, so the world line can be expressed as . When observing, Potassium focuses on the era, which consists of continuous parts in the world line. An era beginning from part l to r can be denoted as (), and may also have leading zeros.

When two eras are quite similar, Potassium can observe one from another by Spirit Circle. More specifically, an era can be observed from another era by Spirit Circle if and only if the following two conditions are satisfied, regardless of where A and B locate in s originally.

1. A and B have the same length, i.e. ;
2. B is greater than A by exactly 1, i.e. .

Potassium is wondering: how many different pairs (A, B) can be found in s that he can observe era B from era A. Note that two eras having the same representations but differing in the original location in s are considered as different eras.

输入描述:

The first line contains one integer n (), denoting the number of parts in the world line of Potas.

The second line contains an n-digit decimal number s, denoting the representation of the world line of Potas.

输出描述:

Print an integer in a single line, denoting the number of different pairs (A, B) in s that Potassium can observe era B from era A by Spirit Circle.
示例1

输入

复制
5
10998

输出

复制
5
示例2

输入

复制
6
001100

输出

复制
11

备注:

In the first example, Potassium can choose 5 different (A, B) pairs:

1. Choose ;
2. Choose ;
3. Choose ;
4. Choose ;
5. Choose .