#K2016. Adjacent Pairs Sum

    ID: 24643 Type: Default 1000ms 256MiB

Adjacent Pairs Sum

Adjacent Pairs Sum

Given an integer (n) and a string (s) of lowercase English letters, compute the Adjacent Pairs Sum (APS). For every adjacent pair of characters ((s_i, s_{i+1})) with (1 \le i < n), their contribution is (\text{value}(s_i) + \text{value}(s_{i+1})), where (\text{value}(c) = \text{ord}(c) - \text{ord}('a') + 1). If (n < 2), the APS is defined as 0. In formula, [ \text{APS} = \sum_{i=1}^{n-1} \Big(\text{value}(s_i) + \text{value}(s_{i+1})\Big)] Read input from standard input (stdin) and write output to standard output (stdout).

inputFormat

The input consists of two lines. The first line contains an integer (n), representing the length of the string. The second line contains the string (s) composed of exactly (n) lowercase English letters.

outputFormat

Output a single integer representing the Adjacent Pairs Sum (APS) of the string.## sample

5
abcde
24

</p>