Back to School '16: Dodgeball

View as PDF

Submit solution

Points:7 (partial)
Time limit:2.0s
Memory limit:256M

Problem type

Today in gym class, your class decided to play dodgeball, and aurpine is selected as one of the team captains! N students are lined up in a row, waiting to be put on teams. aurpine is allowed to pick multiple students as long as they are adjacent to one another, and the first letter of each of their names are the same (case insensitive).

As an assistant to aurpine, help him decide what his first choice should be by writing a program to determine all the possible choices he could make!

Input Specification

The first line contains the integer N (1 \le N \le 10^5), representing the total number of students.

The second line contains N space separated strings, each representing the name of the i^{\text{th}} student in line. Each name will be no longer than 20 characters and only contain letters from the English alphabet.

Output Specification

Output one integer, representing the total number of choices aurpine can make. Since this number can be very large, output it modulo 1\,000\,000\,007.

Sample Input

Sarah Timmy Turner Betty Bob

Sample Output


Explanation for Sample Input

The possible groups of people that aurpine could choose are:

  • Sarah
  • Timmy
  • Turner
  • Betty
  • Bob
  • Timmy, Turner
  • Betty, Bob


  • 0
     commented on Sept. 18, 2016

    What is output for: 7 cdedc dbbec deaec dacea eabbd bacba ddcda Is it 11 ?

    • 1
       commented on Sept. 18, 2016


  • -8
     commented on Sept. 16, 2016 edited
    Sample Input