Problem:
Score : 200 points

Problem Statement

You are given a string S of length N.
Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.

Here, a subsequence of a string is a concatenation of one or more characters from the string without changing the order.

Constraints

1 \leq N \leq 100000

S consists of lowercase English letters.

|S|=N

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the number of the subsequences such that all characters are different, modulo 10^9+7.

Sample Input 1

4
abcd

Sample Output 1

15

Since all characters in S itself are different, all its subsequences satisfy the condition.

Sample Input 2

3
baa

Sample Output 2

5

The answer is five: b, two occurrences of a, two occurrences of ba. Note that we do not count baa, since it contains two as.

Sample Input 3

5
abcab

Sample Output 3

17

Solution in C (Clang 3.8.0) (judge verdict: Wrong Answer)

#include<stdio.h>
#include<stdlib.h>

int search(char str[],char sear) {
	int i;
	int num = 0;

	for (i = 0;i < 1100000;i++) {
		if (str[i] == sear) {
			num++;
		}
	}
	return num;
}

int main() {
	int i, j, k, f = 0, n, t, m;
	int a, b, c, d, e;
	int x, y, z;
	char s[1100000];
	int b0[30];
	char a0[30];

	scanf("%d", &n);
	scanf("%s", s);

	i = 0;
	a0[i] = 'a';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'b';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'c';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'd';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'e';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'f';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'g';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'h';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'i';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'j';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'k';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'l';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'm';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'n';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'o';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'p';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'q';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'r';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 's';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 't';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'u';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'v';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'w';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'x';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'y';
	b0[i] = search(s, a0[i])+1;
	i++;
	a0[i] = 'z';
	b0[i] = search(s, a0[i])+1;


	x = 1;

	for (i = 0;i < 26;i++) {
		x = x * b0[i];
	}


	x = x - 1;
	x = x % 1000000007;
	printf("%d", x);

	return 0;
}