You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: 519D.go
    path of file: ./repos/codeforces-go/main/500-599
    
    the code of the file until where you have to start completion: package main

import (
	"bufio"
	. "fmt"
	"io"
)

// github.com/EndlessCheng/codeforces-go
func CF519D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	a := [26]int64{}
	for i := range a {
		Fscan(in, &a[i])
	}
	var s []byte
	Fscan(in, &s)
	v
    
func CF519D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	a := [26]int64{}
	for i := range a {
		Fscan(in, &a[i])
	}
	var s []byte
	Fscan(in, &s)
	var sum, ans int64
	cnt := map[int64][26]int{}
	for i, v := range s[:len(s)-1] {
		v -= 'a'
		w := s[i+1] - 'a'
		if v == w {
			ans++
		}
		sum += a[v]
		c := cnt[sum]
		ans += int64(c[w])
		c[v]++
		cnt[sum] = c
	}
	Fprint(out, ans)
}