jiahuimbzuai/CoQuIR huggingface dataset:
//  [javascript]
function Main(input){
  input = input.split("\n");
  //山の数Ｎを格納する
  inputStr = input[0].split(" ");
  const N = Number.parseInt(inputStr[0]);
  //数値変換しつつ配列D_arrとしてダムに溜まった水を格納する
  var D_arr = input[1].split(" ");
  //山に降った雨の量を計算。配列A_arrに溜め込む
  var A_arr = [];
  for( i1=0; i1 < N ;i1++){
    A_arr.push(0);
  }
  //計算する  
  for( var i2 = 0; i2 < N ; i2++){
　　//自分の山に半分
    A_arr[i2] += D_arr[i2]/2;
    if(i2===N-1){
      A_arr[0] += D_arr[i2]/2;
    } else {
      A_arr[i2+1] += D_arr[i2]/2;
    }
  }
  //ここまでだと降水量に奇数と成り得る為ダムの水量を見ながら補正計算
  
  //結果を出力
  console.log(A_arr.join(" "));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	S := 0
	P := 0
	for i := 0; i < N; i++ {
		S += A[i]
		if i%2 == 1 {
			P += A[i]
		}
	}

	X := make([]int, N)

	X[0] = S - 2*P
	for i := 1; i < N; i++ {
		X[i] = 2*A[i-1] - X[i-1]
	}
	PrintI(X...)
}

func mapToString(arr []int) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.Itoa(arr[i])
	}
	return ret
}

func PrintI(args ...int) {
	fmt.Println(strings.Join(mapToString(args), " "))
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}
//  [go]
package main

import (
	"bufio"
	// "fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func nextInt() int {
	i, e := strconv.Atoi(nextString())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInt64() int64 {
	i, e := strconv.ParseInt(nextString(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func putInt64(i int64) {
	wr.WriteString(strconv.FormatInt(i, 10))
	// wr.Flush()
}
func putString(s string) {
	wr.WriteString(s)
	// wr.Flush()
}

func main() {
	sc.Buffer(make([]byte, 0), 1000000009)
	sc.Split(bufio.ScanWords)

	var n int
	n = nextInt()

	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	var ans int64

	for i := 0; i < n; i++ {
		ans += int64(a[i])
		if i%2 == 1 {
			ans -= 2 * int64(a[i])
		}
	}

	for i := 0; i < n; i++ {
		putInt64(ans)
		ans = 2*int64(a[i]) - ans
		if i == n-1 {
			putString("\n")
		} else {
			putString(" ")
		}
	}
	wr.Flush()
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, n)
	x := 0
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		x += a[i]
	}

	for i := 2; i < n; i += 2 {
		x -= 2 * a[i-1]
	}
	fmt.Print(x)

	wr := bufio.NewWriter(os.Stdout)
	for i := 0; i < n-1; i++ {
		x = a[i]*2 - x
		wr.WriteString(" " + strconv.Itoa(x))
	}
	wr.WriteString("\n")
	wr.Flush()
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`
									`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n := nextInt()
	a := make([]int, n)
	all := 0

	for i := 0; i < n; i++ {
		a[i] = nextInt()
		all += a[i]
	}

	ans := make([]string, n)

	for i := 0; i < n; i++ {
		la := all
		for j := i % 2; j < i; j += 2 {
			la -= 2 * a[j]
		}
		for j := i + 1; j < n; j += 2 {
			la -= 2 * a[j]
		}
		ans[i] = strconv.Itoa(la)
	}

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, strings.Join(ans, " "))
}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`
									`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n := nextInt()
	a := make([]int, n)
	all := 0

	for i := 0; i < n; i++ {
		a[i] = nextInt()
		all += a[i]
	}

	ans := make([]string, n)

	for i := 0; i < n; i++ {
		la := all
		for j := 0; j < n; j++ {
			if i < j && (j-i)%2 == 1 {
				la -= 2 * a[j]
			} else if i > j && (j-i)%2 == 0 {
				la -= 2 * a[j]
			}
		}
		ans[i] = strconv.Itoa(la)
	}

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, strings.Join(ans, " "))
}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}
//  [ruby]
N,*as=$<.read.split.map(&:to_i)

n = 0
as.each do |a|
    n = a - n
end

n = n / 2
ret = [n*2]
as[0..-2].each do |a|
    n = a - n
    ret << n*2
end

puts ret.join(' ')
//  [ruby]
n = gets.to_i
a = gets.split.map(&:to_i)

x = a.inject{|r, v| v - r} / 2
ans = []

n.times do |i|
    ans << 2 * x
    x = a[i] - x
end

puts ans.join(" ")
//  [ruby]
n = gets.to_i
as = gets.split.map(&:to_i)

sum = 0
s = 1
n.times do |i|
  sum += s * as[i]
  s *= -1
end

bs = []

0.upto(n-1) do |i|
  bs << sum
  sum = 2 * as[i] - sum
end

puts bs.join(' ')
//  [ruby]
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
s = a.inject(:+) / 2
res = Array.new(n, 0)

n.times do |i|
  ((n + 1) / 2).times do |j|
    res[i] += a[(i + 2 * j) % n]
  end
end

puts res.map {|x| (x - s) * 2 }.join(" ")
//  [ruby]
require 'matrix'

n = gets.to_i
a = gets.split.map(&:to_i)
b = a * 2
ma = Matrix.rows([a])
mb = Matrix.rows([b])
1.upto(n - 1) do |i|
  if i.even?
    ma += mb.minor(0, 1, i, n)
  else
    ma -= mb.minor(0, 1, i, n)
  end
end
puts ma.to_a.flatten.join(' ')
//  [ruby]
def gauss_elim(a, b, n_a, n_b_col)
  (n_a - 1).times do |j|
    partial_pivoting(a, b, n_a, n_b_col, j)
    (j + 1).upto(n_a - 1) do |i|
      r = a[i][j].to_f / a[j][j].to_f
      j.upto(n_a - 1) do |k|
        a[i][k] = a[i][k].to_f - a[j][k].to_f * r
      end
      b[i] = b[i].to_f - b[j].to_f * r
    end
  end

  (n_a - 1).downto(0) do |i|
    r = b[i].to_f
    (i + 1).upto(n_a - 1) do |k|
      r = r - a[i][k].to_f * b[k].to_f
    end
    b[i] = r / a[i][i].to_f
  end
end

def partial_pivoting(a, b, n_a, n_b_col, j)
  amax = a[j][j].to_f.abs
  imax = j

  (j + 1).upto(n_a - 1) do |i|
    r = a[i][j].to_f.abs
    if r > amax
      amax = r
      imax = i
    end
  end

  return if j == imax
  n_a.times do |k|
    r = a[imax][k]
    a[imax][k] = a[j][k]
    a[j][k] = r
  end
end

n = gets.to_i
a = []
n.pred.times do |i|
  a[i] = [0] * i + [1] * 2 + [0] * (n - i - 2)
end
a << [1] + [0] * (n - 2) + [1]
b = gets.split.map(&:to_i)

n_a = n
n_b_col = 1

gauss_elim(a, b, n_a, n_b_col)

n.times do |i|
  printf("%d\s", b[i] * 2)
end
//  [rust]
use std::io::BufRead;

fn main() {
    let mut input = String::new();
    let stdin = std::io::stdin();
    let mut handle = stdin.lock();
    handle.read_line(&mut input).unwrap();
    let mut an: Vec<u32> = handle
        .split(b' ')
        .map(|n| {
            n.unwrap()
                .iter()
                .map(|n| *n as char)
                .collect::<String>()
                .parse()
                .unwrap()
        })
        .collect::<Vec<_>>();
    let mut mn = an.iter().fold(0, |acc, n| n - acc);
    print!("{}", mn);
    an.pop();
    for a in an.iter() {
        mn = 2 * a - mn;
        print!(" {}", mn)
    }
}
//  [swift]
import Foundation

extension String {
    
    func toStrList() -> [String] {
        return self.map{String($0)}
    }
    
    func toIntList() -> [Int] {
        return self.map{Int(String($0))!}
    }
    
    func toSepDoubleList() -> [Double]{
        return self.split(separator: " ").map{Double($0)!}
    }

    func toSepIntList() -> [Int] {
        return self.split(separator: " ").map{Int($0)!}
    }

    func toSepStrList() -> [String] {
        return self.split(separator: " ").map{String($0)}
    }
    
    func zFill(n:Int) -> String {
        return String(format: "%0\(n)d", Int(self)!)
    }
    
    func count(c:Character) -> Int{
        var result = 0

        for e in self{
            if e == c{
                result += 1
            }
        }
        return result
    }

    func counter() -> Dictionary<Character, Int>{
        var result:[Character:Int] = [:]
        
        for c in self{
            guard let _ = result.index(forKey: c) else {
                result[c] = 1
                continue
            }
            result[c]! += 1
        }
        return result
    }
}

extension Int {
    func toBin() -> String {
        return String(self, radix: 2)
    }
    
    func toNBin(_ radix:Int) -> String{
        return String(self, radix: radix)
    }
    
    func toD() -> Double {
        return Double(self)
    }
}

extension Double {
    func toI() -> Int {
        return Int(self)
    }
}

extension Array where Element: Equatable{
    func count(n:Self.Element) -> Int{
        var result = 0
        for e in self{
            if e == n{
                result += 1
            }
        }
        return result
    }
}

extension Array {
    func dump(){
        for x in 0..<self.count-1{
            print(self[x], terminator: " ")
        }
        print(self.last!)
    }
}

func pow(_ base:Int,_ exp:Int) -> Int{
    let d = pow(base.toD(), exp.toD())
    return Int(d)
}

func distance(p1:CGPoint, p2:CGPoint) -> Double {
    let diffp = CGPoint(x:p1.x - p2.x, y:p1.y - p2.y)
    return Double(sqrt(diffp.x*diffp.x + diffp.y * diffp.y))
}

func distance(p1:[Double], p2:[Double]) -> Double{
    let diff = [p1[0] - p2[0], p1[1] - p2[1]]
    return sqrt(diff[0] * diff[0] + diff[1] * diff[1])
    
}

func lotate(theta:Double, point:[Double]) -> [Double] {
    let matrix = [
        [cos(theta), -sin(theta)],
        [sin(theta), cos(theta)]
    ]
    let x = point[0]
    let y = point[1]
    
    let rx = matrix[0][0]*x + matrix[0][1]*y
    let ry = matrix[1][0]*x + matrix[1][1]*y
    
    return [rx, ry]
}


func abc133c(){
    let N = Int(readLine()!)!
    let A = readLine()!.toSepIntList()
    var X = Array(repeating: 0, count: N)
    let total = A.reduce(0, +)
    var sum = 0
    for i in stride(from: 1, to: N, by: 2){
        sum += A[i]
    }
    X[0] = total - 2*sum
    
    for i in 1..<N {
        X[i] = 2*A[i-1] - X[i-1]
    }
    X.dump()
}


abc133c()
//  [swift]
let N = Int(readLine()!)!
let A = readLine()!.characters.split(" ").map{Int(String($0))!}
//let sum = A.reduce(0){$0+$1}
let ans = (0..<N).map{A[($0+N-1)%N] + A[$0] - A[($0+1)%N]}
ans.forEach{print($0, terminator: " ")}
print()
//  [swift]
let N = readInt()!
let A = readIntSplit(by: " ")
//let sum = A.reduce(0){$0+$1}
let ans = (0..<N).map{A[($0+N-1)%N] + A[$0] - A[($0+1)%N]}
ans.forEach{print($0, terminator: " ")}
print()
//  [typescript]
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

let reader: Reader = new Reader();
let N = reader.readInt();
/**
 *
 * D[1]/2+D[2]/2=A[1]
 * D[2]/2+D[3]/2=A[2]
 * D[3]/2+D[1]/2=A[3]
 * D[1]=A[1]-A[2]+A[3]
 *
 */
let A = reader.readInts();
let D: number[] = new Array(N).fill(0);
let S = 0, sign = 1;
for(let i=0; i<N; i++) {
	S += sign*A[i];
	sign = -sign;
}
D[0] = S;
D[N-1] = 2*A[N-1]-D[0]
for(let i=1; i<N-1; i++) {
	D[i] = 2*A[i-1]-D[i-1];
}
console.log(D.map((value) => value.toString()).join(" "));
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const a = input[1].split(" ").map(n => Number(n));
  const arr = [0];
  for (let i = 1; i < n; i++) {
    const num = a[i-1]*2 - arr[arr.length -1];
    arr.push(num);
  }
  const dif = (a[a.length-1]*2 - (arr[0] + arr[arr.length -1]))/2;
  const result = [dif];
  for (let i = 1; i < n; i++) {
    result.push(a[i-1]*2 - result[result.length -1]);
  }
  console.log(result.join(" "));
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const n: number = parseInt(tmp[0]);
    const a: number[] = tmp[1].split(" ").slice(0, n).map(t => parseInt(t));
    let prevM: number = 0;
    let t: number = 1;
    for (let i = 0; i < n; ++i) {
      prevM += t * a[i];
      t *= -1;
    }
    const result: number[] = [];
    result.push(prevM);
    for (let i = 0; i < n - 1; ++i) {
      const m: number = (a[i] - prevM / 2) * 2;
      result.push(m);
      prevM = m;
    }
    return `${result.join(" ")}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const a = input[1].split(" ").map(n => Number(n));
  const arr = [0];
  for (let i = 1; i < n; i++) {
    const num = a[i] - arr[arr.length -1];
    arr.push(num);
  }
  const dif = a[a.length-1]*2 - (arr[0] + arr[arr.length -1]);
  const result = arr.map(num => num + (dif/2));
  console.log(result.join(" "));
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
N = int(input())
S = input()
ans = 1
for c in [chr(ord('a') + i) for i in range(26)]:
    ans = (ans * (S.count(c) + 1)) % (10**9 + 7)
ans = (ans - 1) % (10**9 + 7)
print(ans)
//  [python]
import sys
input = sys.stdin.readline

def main():
	N = int(input())
	S = input().rstrip()
	M = 10**9 + 7
	
	# a     (0)+1
	# ab    (1)+1+1
	# abc   (3)+3+1
	# abca  (7)+1+2+1
	# abcab (11)+1+3+2
	# abcabc (17)+1+4+3
	A = ord("a")
	res = 1
	for i in range(26):
		q = chr(i+A)
		qc = S.count(q)
		res = res * (qc+1) % M
		
	print((res-1) % M)
	
main()
//  [python]
n=int(input())
S=input()
a='abcdefghijklmnopqrstuvwxyz'
ans=1
for i in range(26):
  cnt=S.count(a[i])
  ans=ans*(cnt+1)
ans-=1
ans=ans%(10**9+7)
print(int(ans))
//  [python]
import sys, math, re
from functools import lru_cache
sys.setrecursionlimit(10**9)
import numpy as np
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    S = input()
    d = {}
    for i in range(N):
        if not S[i] in d:
            d[S[i]] = 1
        d[S[i]] += 1

    a = np.array(list(d.values()))
    ans = np.multiply.reduce(a)-1
    print(ans)


if __name__ == "__main__":
    main()
//  [python]
n = int(input())
s = input()
dic = {}
for si in s:
  if si not in dic:
    dic[si] = 0
  dic[si] += 1
ans = 1
for k, v in dic.items():
  ans *= (v+1)
print(ans-1)
//  [python]
from collections import defaultdict
N = int(input())
S = input()

mod = 10**9+7
char_done = defaultdict(int)
# dp[i] := 左から0文字目(1-idx)まで見たときの答え
# 一旦空文字列も含む
dp = [0] * (N+1)
dp[0] = 1
for i in range(1,N+1):
    #print(i,'---')
    if char_done[S[i-1]] == 0:
        #print("not done",dp[i-1])
        dp[i] = 2*dp[i-1]
    else:
        dp[i] = dp[i-1]//2 + dp[i-1]
        
    #print(dp[i])
    dp[i] %= mod
    char_done[S[i-1]] = 1

print((dp[-1]-1)%mod)
//  [java]

import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long N=gi();
	    String S= gs();
	    int[] K=new int[26];
	    for(int i=0;i<N;i++) {
	    	char c=S.charAt(i);
	    	K[c-97]++;
	    }
	    int a=1;
	    for(int i=0;i<K.length;i++) {
	    	if(K[i]==0) continue;
	    	a*=K[i]+1;
	    	a=a%1000000007;
	    }
	    a=(a+1000000006)%1000000007;
//	    if (k>k2) {
//	    	System.out.println("NO");
//	    } else {
//	    	System.out.println("YES");
//	    }
	    System.out.println(a);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}
//  [java]


import java.util.Scanner;

public class Main
{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		char[] str = sc.next().toCharArray();

		int alpha[][] = new int[n][26];

		for(int i = n - 2; i >= 0; i--){
			for(int j = 0; j < 26; j++){
				alpha[i][j] = alpha[i + 1][j];
			}

			alpha[i][str[i + 1] - 'a']++;
		}

		//debug
//		for(int i = 0; i < 26; i++){
//			for(int j = 0; j < n; j++){
//				System.out.print(alpha[j][i]+" ");
//			}
//			System.out.println();
//		}

		long result = 0;
		int mod = 1_000_000_007;
		for(int i = 0; i < n; i++){
			long tmp = 1;

			for(int j = 0; j < 26; j++){
				if(alpha[i][j] == 0 || j == str[i] - 'a'){
					continue;
				}

				tmp *= (alpha[i][j] + 1);
				tmp %= mod;
			}

			result += tmp;
		}

		System.out.println(result);
	}
}
//  [java]

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		char[] str = sc.next().toCharArray();

		int alpha[][] = new int[n][26];

		for(int i = n - 2; i >= 0; i--){
			for(int j = 0; j < 26; j++){
				alpha[i][j] = alpha[i + 1][j];
			}

			alpha[i][str[i + 1] - 'a']++;
		}

		//debug
//		for(int i = 0; i < 26; i++){
//			for(int j = 0; j < n; j++){
//				System.out.print(alpha[j][i]+" ");
//			}
//			System.out.println();
//		}

		long result = 0;
		int mod = 1_000_000_007;
		for(int i = 0; i < n; i++){
			long tmp = 1;

			for(int j = 0; j < n; j++){
				if(alpha[i][j] == 0 || j == str[i] - 'a'){
					continue;
				}

				tmp *= (alpha[i][j] + 1);
				tmp %= mod;
			}

			result += tmp;
		}

		System.out.println(result);
	}
}
//  [cpp]
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
#define MO 1000000007
#define LL long long
int n,cnt[26];
char s[MAXN];
int main()
{
	scanf("%d%s",&n,s);
	for(int i=0;i<n;i++) cnt[s[i]-'a']++;
	LL t1=0,t2=0;
	for(int i=0;i<8192;i++)
	{
		LL tmp1=1,tmp2=1;
		for(int j=0;j<13;j++)
			if((i>>j)&1) (tmp1*=cnt[j])%=MO,(tmp2*=cnt[j+13])%=MO;
		(t1+=tmp1)%=MO;(t2+=tmp2)%=MO;
	}
	t1=(t1*t2%MO-1+MO)%MO;
	printf("%lld\n",t1);
}
//  [cpp]
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100005;
const int mod=1e9+7;
char s[N];
int cnt[26];
int n;
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)
		cnt[s[i]-'a']++;
	int ans=1;
    for(int i=0;i<26;i++)
		ans=1ll*ans*(cnt[i]+1)%mod;
    ans=(ans-1+mod)%mod;
    printf("%d\n",ans);
}
//  [cpp]
#include <stdio.h>
int main(void){
    int d;
    scanf("%d",&d);
    int a[30];
    for(int i=0;i<30;i++)a[i]=0;
    char c[100005];
    scanf("%s",c);
    for(int i=0;i<d;i++){
        a[c[i]-'a']++;
    }
    long long p=1000000007;
    long long ans=1;
    for(int i=0;i<26;i++){
        ans*=a[i]+1;
        ans%=p;
    }
    printf("%lld\n",(ans-1+p)%p);
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector <int> table(26,1);

    rep(i,n){
        char tmp = s[i];
        int tmp1 = tmp - 97;
        table[tmp1] ++;
    }

    long long ans = 1;
    rep(i,26){
        ans *= table[i];
    }
    ans --;

    cout << ans << endl;

}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;


  const int MAX = 510000;
  
  ll fac[MAX], finv[MAX], inv[MAX];
  
  // テーブルを作る前処理
  //ここO(n)
  void COMinit() {
      fac[0] = fac[1] = 1;
      finv[0] = finv[1] = 1;
      inv[1] = 1;
      for (int i = 2; i < MAX; i++){
          fac[i] = fac[i - 1] * i % MOD;
          //すごいことしてO(1)で求めてる
          inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
          finv[i] = finv[i - 1] * inv[i] % MOD;
      }
  }
  
  // 二項係数計算
  ll COM(int n, int k){
      if (n < k) return 0;
      if (n < 0 || k < 0) return 0;
      return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
  }

int main() {
    int n;
    string s;
    cin >> n >> s;
    //重複を調べる
    vector<int> table(26);
    rep(i,n){
        table[s[i]-'a']++;
    }
    COMinit();
    ll all = 0;
    for(int i=1;i<=n;i++){
        all += COM(n,i);
        all %= MOD;
    }
    // cout << all << endl;
    int sum=0;
    int cnt = 0;
    rep(i,26){
        ll cur = 0;
        ll mu = 0;
        if(table[i]>1){
            cnt++;
            for(int j=0;j<=n-table[i];j++){
                cur += COM(n-table[i],j);
                cur %= MOD;
            }
            for(int j=2;j<=table[i];j++){
                mu+=COM(table[i],j);
                mu %= MOD;
            }
            sum+=table[i];
        }
        // cout << cur << endl;
        // cout << mu << endl;
        cur *= mu;
        cur %=MOD;
        all -= cur;
        if(all<0)
            all+=MOD;
    }
    int add = 0;
    if(cnt>1){
        for(int i=0;i<=n-sum;i++){
            add += COM(n-sum,i);
            add %= MOD;
        }
    }
    all+=add;
    if(add>MOD)
        add %= MOD;
    cout << all << endl;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;


  const int MAX = 510000;
  
  ll fac[MAX], finv[MAX], inv[MAX];
  
  // テーブルを作る前処理
  //ここO(n)
  void COMinit() {
      fac[0] = fac[1] = 1;
      finv[0] = finv[1] = 1;
      inv[1] = 1;
      for (int i = 2; i < MAX; i++){
          fac[i] = fac[i - 1] * i % MOD;
          //すごいことしてO(1)で求めてる
          inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
          finv[i] = finv[i - 1] * inv[i] % MOD;
      }
  }
  
  // 二項係数計算
  ll COM(int n, int k){
      if (n < k) return 0;
      if (n < 0 || k < 0) return 0;
      return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
  }

int main() {
    int n;
    string s;
    cin >> n >> s;
    //重複を調べる
    vector<int> table(26);
    rep(i,n){
        table[s[i]-'a']++;
    }
    COMinit();
    ll all = 0;
    for(int i=1;i<=n;i++){
        all += COM(n,i);
        all %= MOD;
    }
    // cout << all << endl;
    int sum=0;
    int cnt = 0;
    rep(i,26){
        ll cur = 0;
        if(table[i]>1){
            cnt++;
            for(int j=0;j<=n-table[i];j++){
                cur += COM(n-table[i],j);
                cur %= MOD;
            }
            sum+=table[i];
        }
        all -= cur;
        if(all<0)
            all+=MOD;
    }
    int add = 0;
    if(cnt>1){
        for(int i=0;i<=n-sum;i++){
            add += COM(n-sum,i);
            add %= MOD;
        }
    }
    all+=add;
    if(add>MOD)
        add %= MOD;
    cout << all << endl;
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int N;
	char S[100001];
	scanf("%d", &N);
	scanf("%s", S);

	int i, count[26] = {};
	long long total = 1;
	for (i = 0; S[i] != 0; i++) count[S[i] - 'a']++;
	for (i = 0; i < 26; i++) total = total * (count[i] + 1) % 1000000007;

	printf("%lld\n", (total + 1000000006) % 1000000007);
	fflush(stdout);
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define N 100009
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; }//1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; }//8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; }//a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); }//aaa,aab
//temmie_のsnippet

int main() {
	int a[27],n;char s[N];LL ans=1;
	rep(i,26)a[i]=1;
	scanf("%d%s",&n,s);
	rep(i,n)a[s[i]-97]++;
	rep(i,26){ans*=a[i];ans%=MOD;}
	printf("%lld",ans-1);
	return 0;
}
//  [c]
#include <stdio.h>

#define MOD 1000000007

int main()
{
    int n,bucket[26] = {0},i,j;
    char s[100001];

    scanf("%d %s",&n,s);
    for (i = 0; i < n; i++)
    {
        bucket[s[i] - 'a']++;
    }

    long long ans = 1;

    for (i = 0; i < 26; i++)
    {
        ans *= bucket[i] + 1;
        ans %= MOD;
    }
    
    printf("%lld",ans - 1);
}
//  [c]
#include<stdio.h>

#define MOD 1000000007

int mod_multi(int a,int b){
    long long int ret;
    ret = a*b;
    if(ret>MOD)ret %= MOD;
    return ret;
}

int main(void){
    int n;
    scanf("%d",&n);
    char str[n];
    scanf("%s",str);
    int ans = 1;
    int cc[26] = {};
    for(int i = 0;i < n;i++)cc[str[i]-'a']++;
    for(int i = 0;i < 26;i++)ans = mod_multi(ans,cc[i]+1);
    printf("%d",ans-1);
    return 0;
}
//  [c]
#include<stdio.h>

int main(void){
  char S[100001];
  int n;
  long long int ans = 1,mod = 1000000007,c[26] = {0};
  
  scanf("%d",&n);
  scanf("%s",S);
  
  for(int i = 0;i<n;i++){
    c[S[i] - 'a']++;
  }
  
  for(int i = 0;i<26;i++){
    ans *= ((c[i] + 1) % mod);
  }
  printf("%lld",ans - 1);
}
//  [c]
#include<stdio.h>

int main(void){
  char S[100001];
  int n;
  long long int ans = 1,mod = 1000000007,c[26] = {0};
  
  scanf("%d",&n);
  scanf("%s",S);
  
  for(int i = 0;i<n;i++){
    c[S[i] - 'a']++;
  }
  
  for(int i = 0;i<26;i++){
    ans *= (c[i] + 1) % mod;
  }
  printf("%lld",ans - 1);
}
//  [javascript]
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
MOD = Math.pow(10, 9) + 7 
N = inp.shift() * 1
S = inp.shift()
o = {}
for (i=0; i<N; i++) {
    o[S[i]] = (o[S[i]] || 0) + 1
}
ans = 1
for (var k in o) {
    ans *= o[k] + 1
    ans = ans % MOD
}
console.log(ans - 1)
//  [javascript]
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = myconv(next(),1);
  var s = next();
  var count = {};
  var output = 1;
  var mod = 1000000007;
  for(var i = 0; i < N; i++){
    if(count[s[i]] == null){
       count[s[i]] = 1;
    }else{
       count[s[i]]++;
    }
  }
  var keys = Object.keys(count);
  for(var i = 0; i < keys.length; i++){
    output = (output * (count[keys[i]] + 1)) % mod;
  }
  myout(output - 1);
}
//  [javascript]
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), S = cin.getStr();
    let C = {};
    for (let n = 0; n < S.length; n++) {
        let c = C[S[n]] || 0;
        C[S[n]] = ++c;
    }
    const MOD = 1e9 + 7;
    let ans = 1;
    for (let n in C) {
        ans = (ans * (C[n] + 1)) % MOD;
    }
    ans = (ans - 1 + MOD) % MOD;
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
var lines = [];
var MOD = Math.pow(10, 9) + 7
var result = 1;

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]);
    var S = lines[1].split("");

    S.sort((a, b) => a.charCodeAt(0) - b.charCodeAt(0));

    var counter = []; var cnt = 1;
    for (var i = 1; i < N; i++) {
        if (S[i - 1] !== S[i]) { counter.push(cnt); cnt = 0; }
        cnt++;
    }

    counter.push(cnt);

    for (var i = 0; i < counter.length; i++) {
        result *= counter[i] + 1;
    }

    console.log(result - 1);
});
//  [javascript]
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var MOD = Math.pow(10, 9) + 7;

    var N = lines[0];
    var S = lines[1].split("");

    var alphabet = {};

    // 余事象で解く
    var result = 1;

    // baa   = 2C1 * 3C1 - 1 =  5
    // baaa  = 2C1 * 4C1 - 1 = 7
    // bcaaa = 2C1 * 2C1 * 4C1 -1 = 15
    // aabbc = 3C1 * 3C1 * 2C1 -1 = 17


    for (var i = 0; i < N; i++) { alphabet[S[i]] === undefined ? alphabet[S[i]] = 1 : alphabet[S[i]]++ }
    Object.keys(alphabet).forEach(function (key) {
        result *= nCm(alphabet[key] + 1, 1);
    });
    console.log(result - 1);

});
function nPm(n, m) {
    var result = 1; var counter = 0;

    while (counter < m) {
        result *= n
        n -= 1; counter++;
    }
    return (result);
}

function nCm(n, m) {
    return (nPm(n, m) / nPm(m, m));
}
//  [javascript]
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var MOD = Math.pow(10,9)+7;

    var N = lines[0];
    var S = lines[1].split("");
    var result = 1;
    var alphabet = {};

    for (var i = 0; i < N; i++) {
        if ((alphabet[S[i]]) === undefined) {
            alphabet[S[i]] = 0;
        }
        alphabet[S[i]]++;
    }

    for (var i = 0; i < Object.keys(alphabet).length; i++) {
        result = result * (alphabet[S[i]] + 1);
        result = result % MOD;
    }
    console.log((result - 1) % MOD);
});
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	s := getNextString(scanner)
	mod := int64(1e9 + 7)
	cc := make([]int64, 26)

	for i := 0; i < n; i++ {
		cc[s[i]-'a']++
	}

	ans := int64(1)
	for i := 0; i < 26; i++ {
		ans *= (cc[i] + 1)
		ans %= mod
	}
	ans--
	ans = ((ans % mod) + mod) % mod
	fmt.Fprintln(writer, ans)
	writer.Flush()
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

const mod = 1e9 + 7

func main() {
	b := [26 + 'a']int{}
	rd := bufio.NewReader(os.Stdin)
	var (
		by  byte
		err error
	)
	for err != io.EOF {
		by, err = rd.ReadByte()
		b[by]++
	}

	r := 1
	for i := 'a'; i < 26+'a'; i++ {
		r = r * (b[i] + 1) % mod
	}
	fmt.Println(r - 1)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var N int

func main() {
	N = nextInt()
	S := nextString()
	div := int(math.Pow10(9) + 7)
	alpha := make([]int, 26)
	for i := 0; i < 26; i++ {
		alpha[i] = 1
	}
	for i := 0; i < N; i++ {
		alpha[int(S[i])-97] += 1
	}
	result := 1
	for i := 0; i < 26; i++ {
		result = result * alpha[i]
		result = result % div
	}
	fmt.Printf("%v", result-1)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func MinIn4Values(a int, b int, c int, d int) int {
	e := MinIn2Values(a, b)
	f := MinIn2Values(c, d)
	return MinIn2Values(e, f)
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}
//  [ruby]
n=gets.to_i
s=gets.chomp
l=[]
26.times do |i|
  l[i]=s.count((i+"a".ord).chr)+1
end
puts (l.inject(:*)-1)%(10**9+7)
//  [ruby]
N=gets.to_i
S=gets.chomp
mod = 10**9+7
b = 1
(?a..?z).each do |c|
    cnt = S.count(c)
    b *= cnt+1
end

puts (b-1) % mod
//  [ruby]
n = gets.to_i
s = gets.chomp
mod = 10 ** 9 + 7

puts ("a".."z").to_a.inject(1){|r,i| r * (s.count(i) + 1) % mod} - 1
//  [ruby]
n=gets.to_i
s=gets.chomp
l=[1]*26
s.each_char do |c|
  l[c.ord-"a".ord]+=1
end
puts l.inject(:*)-1
//  [ruby]
n = gets.chomp.to_i
s = gets.chomp
h  = Hash.new(0)

n.times do |i|
  h[s[i]] += 1
end

MOD = 10**9 + 7
ans = 1
h.each do |k,v|
  ans *= (v + 1) % MOD
end

puts ans - 1
//  [ruby]
n = gets.to_i
h = Hash.new(0)
gets.chomp.each_char { |c| h[c] += 1 }
ret = 0
mod = 10**9 + 7

1.upto(h.size) do |i|
  h.keys.combination(i) do |arr|
    ret += arr.map { |e| h[e] }.inject { |i, j| i * j % mod }
  end
end

puts ret % mod
//  [rust]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim_right().to_owned()
    }};
}

fn main() {
    let m = 1_000_000_007u64;
    read_line!();
    let s = read_line!();
    let mut ab = vec![0u64; 26];
    for c in s.bytes() {
        ab[(c - 'a' as u8) as usize] += 1;
    }
    let mut ans = 1u64;
    for c in 0..26 {
        ans = (ans * (ab[c] + 1)) % m;
    }
    ans = (ans + m - 1) % m;
    println!("{}", ans);
}
//  [rust]
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = unsafe { _read_value!(_scanned, $t) };
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

const M: u64 = 1_000_000_007;

fn main() {
    input! {
        _n: usize,
        s: _bytes,
    }
    let mut kinds = [0; 27];
    for c in s {
        kinds[(c - b'a') as usize] += 1;
    }
    let ret = kinds.iter().map(|&n| n + 1).fold(1, |a, b| (a * b) % M) - 1;
    println!("{}", ret);
}
//  [rust]
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let m = 1000_000_000 + 7;
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let mut map = HashMap::new();
    let mut ret = 1;
    for c in s.iter() {
        let count = map.entry(c).or_insert(0);
        *count += 1;
    }
    for (_, value) in map {
        ret *= value + 1;
        ret %= m;
    }
    println!("{}", (ret + m - 1) % m);
}
//  [rust]
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let m = 1000_000_000 + 7;
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let mut map = HashMap::new();
    let mut ret = 1;
    for c in s.iter() {
        let count = map.entry(c).or_insert(0);
        *count += 1;
    }
    for (_, value) in map {
        ret *= value + 1;
        ret %= m;
    }
    println!("{}", ret - 1);
}
//  [rust]
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        _n: usize,
        s: Chars,
    }
    let res = 1_000_000_007;
    let mut ans = 1;
    let mut count = vec![0; 26];
    for &c in &s {
        count[c as usize - 'a' as usize] += 1;
    }
    for i in 0..26 {
        if count[i] != 0 {
            ans *= (count[i] + 1) % res as u64;
        }
    }
    ans -= 1;
    println!("{}", ans);
}
//  [swift]
let N = Int(readLine()!)!
let S = readLine()!.characters
var cnt = [Character: Int]()
for c in S {
    cnt[c] = (cnt[c] ?? 0) + 1
}
print(cnt.values.reduce(1){$0*($1+1)%1000000007}-1)
//  [swift]
let N = Int(readLine()!)!
let S = readLine()!.characters
var cnt = [Character: Int]()
for c in S {
    cnt[c] = (cnt[c] ?? 0) + 1
}
print(cnt.values.reduce(1){$0*($1+1)%1000000007})
//  [swift]
let N = Int(readLine()!)!
let S = readLine()!
var cnt = [Character: Int]()
for c in S.characters {
    cnt[c] = (cnt[c] ?? 0) + 1
}
print(cnt.values.reduce(1){$0*($1+1%1000000007)})
//  [typescript]
const base: number = Math.pow(10, 9) + 7;
export class Main {
  static main(input): string {
    const [n, s]: string[] = input.split("\n");
    const count: {[key: string]: number} = {};
    for (let i: number = 0, len = Number(n); i < len; i++) {
      const char: string = s.charAt(i);
      if (count[char] === undefined) {
        count[char] = 0;
      }
      count[char] += 1;
    }
    let result = 1;
    Object.keys(count).forEach(key => {
      result = (result * (count[key] + 1)) % base;
    })
    return `${result > 0 ? (result - 1) : (base - 1)}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

let reader = new Reader();
let N = reader.readInt();
let S = reader.readLine();
let counter: Map<string, number> = new Map();
let alphabet = "abcdefghijklmnopqrstuvwxyz";

for(let c of alphabet) {
	counter.set(c, 0);
}

let answer = 0,
	modulo = 1000000007;
for(let c of S) {
	let sum = 1;
	counter.forEach((value, key) => {
		if (key != c)
			sum = (sum*(value+1))%modulo;
	});
	answer = (answer+sum)%modulo;
	counter.set(c, counter.get(c)+1);
}

console.log(answer);
//  [typescript]
import { readFileSync } from 'fs'

const mod = 10 ** 9 + 7

function main(input: string) {
  const [, S] = input.split('\n')

  // 各文字の数を集計
  const counts = Array.from(S).reduce(
    (acc, v) => ({ ...acc, [v]: (acc[v] || 0) + 1 }),
    {} as Record<string, number>
  )

  // 組み合わせを計算
  const pattern = Object.keys(counts).reduce((acc, key) => {
    const result = acc * (counts[key] + 1)
    return result % mod
  }, 1)

  // 0文字選択のパターンを排除
  const result = (pattern - 1 + mod) % mod

  console.log(result)
}

main(readFileSync('/dev/stdin', 'utf8').trim())
//  [typescript]
import fs = require('fs');
if(process.argv[1].match(/Main.js$/)) { console.log(main(fs.readFileSync('/dev/stdin', 'utf8').split(/[\r\n\t ]/))); }

export function main(strings: string[]): string {
	const ret: any[] = [];
	const str = strings[1];

	const answers = xxx('', str);
	ret.push(answers.length % (10**9+7))

	return ret.join('\n') + '\n';
}

function xxx(s1: string, s2: string, ret: string[] = []): string[] {
	if(s2.length === 1) {
		if(s1.length) {
			if(s1.includes(s2[0]) === false) {
				Array.prototype.push.apply(ret, [s1 + s2]);
			}
			Array.prototype.push.apply(ret, [s1     ]);
			return ret;
		} else {
			Array.prototype.push.apply(ret, [s2]     );
			return ret
		}
	}
	if(s1.includes(s2[0]) === false) {
		Array.prototype.push.apply(xxx(s1 + s2[0], s2.substr(1), ret));
	}
	Array.prototype.push.apply(xxx(s1        , s2.substr(1), ret));
	return ret;
}