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 (GCC 5.4.1) (judge verdict: Runtime Error)

/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// gcd(a,b)
int gcd(int a,int b){
	if(a == 0) return b;
	else if(b == 0) return a;
	else return gcd(b,a % b);
}

// lcm(a,b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// nCr(n,r) & utility
int nCrVal[5003][5003];
int nCrSetUp(int n){
	for(int i = 0; i <= n; ++i){
		for(int j = 0; j <= i / 2 + 1; ++j){
			if(j == 0)  nCrVal[i][j] = 1;
			else  nCrVal[i][j] = nCrVal[i - 1][j - 1] + nCrVal[i - 1][j];
			nCrVal[i][i - j] = nCrVal[i][j];
 		}
	}
}

int nCr(int n, int r){
	if(nCrVal[n][r] == 0)	nCrSetUp(n + 1);
	return nCrVal[n][r];
}

// swap(&a, &b);
void swap(int *a,int *b){
	int tmp;
	tmp = *a;	*a = *b;	*b = tmp;
	return;
}

// qsort(array, size, sizeof(int),comp);
int ASC(const int *a,const int *b){
	return (*a - *b);
}

int DESC(const int *a,const int *b){
	return (*b - *a);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

int main(int argc, char const *argv[])
{
	int n;
	char s[100003];
	TLong ans = 1, charcnt[26] = { 0 };

	scanf("%d", &n);
	scanf("%s", s);
	for (int i = 0; i < n; ++i)	++charcnt[(int)(s[i] - 'a')];
	for (int i = 0; i < n; ++i)	++charcnt[i];
	for (int i = 0; i < n; ++i)	ans *= charcnt[i];

	printf("%lld\n", (ans - 1) % TBMod);
	return 0;
}