Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)

n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

def cal(n, S):
    if n == 1:
        return sum(S)
    else:
        ans = 0
        for i in range(len(S) - n + 1):
            cross = cal(n-1, S[i+1:])
            ans += S[i] * cross
            ans %= 10 ** 9 + 7
        return ans % (10 ** 9 + 7)

ans = 0
for i in range(n):
    ans += cal(i+1, S)

ans %= 10 ** 9 + 7
print(ans)



Fixed submission:
n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

ans = 1
for i in S:
    ans *= i + 1
    ans %= 10 ** 9 + 7

print(ans - 1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)

n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

def cal(n, S):
    if n == 1:
        return sum(S)
    ans = 0
    if n == 2:
        for i in range(len(S) - 1):
            for j in range(i+1, len(S)):
                ans += S[i] * S[j]
    else:
        for i in range(len(S) - n + 1):
            cross = cal(n-1, S[i+1:])
            cross %= 10 ** 9 + 7
            ans += S[i] * cross
            ans %= 10 ** 9 + 7
    return ans % (10 ** 9 + 7)

ans = 0
for i in range(n):
    ans += cal(i+1, S)

ans %= 10 ** 9 + 7
print(ans)



Fixed submission:
n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

ans = 1
for i in S:
    ans *= i + 1
    ans %= 10 ** 9 + 7

print(ans - 1)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

def cal(n, S):
    if n == 1:
        return sum(S)
    ans = 0
    if n == 2:
        for i in range(len(S) - 1):
            for j in range(i+1, len(S)):
                ans += S[i] * S[j]
    else:
        for i in range(len(S) - n + 1):
            cross = cal(n-1, S[i+1:])
            cross %= 10 ** 9 + 7
            ans += S[i] * cross
            ans %= 10 ** 9 +7
        return ans % 10 ** 9 + 7

ans = 0
for i in range(n):
    ans += cal(i+1, S)

ans %= 10 ** 9 + 7
print(ans)



Fixed submission:
n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

ans = 1
for i in S:
    ans *= i + 1
    ans %= 10 ** 9 + 7

print(ans - 1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)

n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

def cal(n, S):
    if n == 1:
        return sum(S)
    if n == 2:
        ans = 0
        for i in range(len(S) - 1):
            for j in range(i+1, len(S)):
                ans += S[i] * S[j]
                ans %= 10 ** 9 + 7
        return ans
    else:
        ans = 0
        for i in range(len(S) - n + 1):
            cross = cal(n-1, S[i+1:])
            cross %= 10 ** 9 + 7
            ans += S[i] * cross
            ans %= 10 ** 9 +7
        return ans

ans = 0
for i in range(n):
    ans += cal(i+1, S)

ans %= 10 ** 9 + 7
print(ans)



Fixed submission:
n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

ans = 1
for i in S:
    ans *= i + 1
    ans %= 10 ** 9 + 7

print(ans - 1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)

n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

def cal(n, S):
    if n == 1:
        return sum(S)
    if n == 2:
        ans = 0
        for i in range(len(S) - 1):
            for j in range(i+1, len(S)):
                ans += S[i] * S[j]
                ans %= 10 ** 9 + 7
        return ans
    else:
        ans = 0
        for i in range(len(S) - n + 1):
            ans += S[i] * cal(n-1, S[i+1:])
            ans %= 10 ** 9 +7
        return ans

ans = 0
for i in range(n):
    ans += cal(i+1, S)

ans %= 10 ** 9 + 7
print(ans)



Fixed submission:
n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

ans = 1
for i in S:
    ans *= i + 1
    ans %= 10 ** 9 + 7

print(ans - 1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)

n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

def cal(n, S):
    if n == 1:
        return sum(S)
    if n == 2:
        ans = 0
        for i in range(len(S) - 1):
            for j in range(i+1, len(S)):
                ans += S[i] * S[j]
            ans %= 10 ** 9 + 7
        return ans
    else:
        ans = 0
        for i in range(len(S) - n + 1):
            ans += S[i] * cal(n-1, S[i+1:])
            #ans %= 10 ** 9 +7
        return ans

ans = 0
for i in range(n):
    ans += cal(i+1, S)

ans %= 10 ** 9 + 7
print(ans)



Fixed submission:
n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

ans = 1
for i in S:
    ans *= i + 1
    ans %= 10 ** 9 + 7

print(ans - 1)