n = int(eval(input()))

s = eval(input())

d1 = set()

d2 = set()

d3 = set()

for c in s:

    for t in d2:

        d3.add(t + c)

    for t in d1:

        d2.add(t + c)

    d1.add(c)

print((len(d3)))

from bisect import bisect



n = int(eval(input()))

s = eval(input())

location = [[] for _ in range(10)]

for i, c in enumerate(map(int, s)):

    location[c].append(i)

location = [loc for loc in location if loc]

last_indices = [loc[-1] for loc in location]



ans = 0

for loc_x in location:

    i = loc_x[0]

    for loc_y in location:

        ji = bisect(loc_y, i)

        if ji >= len(loc_y):

            continue

        j = loc_y[ji]

        ans += sum(j < li for li in last_indices)

print(ans)

n = int(eval(input()))
s = eval(input())
d1 = set()
d2 = set()
d3 = set()
for c in s:
    for t in d2:
        d3.add(t + c)
    for t in d1:
        d2.add(t + c)
    d1.add(c)
print((len(d3)))

from bisect import bisect

n = int(eval(input()))
s = eval(input())
location = [[] for _ in range(10)]
for i, c in enumerate(map(int, s)):
    location[c].append(i)
location = [loc for loc in location if loc]
last_indices = [loc[-1] for loc in location]
ans = 0
for loc_x in location:
    i = loc_x[0]
    for loc_y in location:
        ji = bisect(loc_y, i)
        if ji >= len(loc_y):
            continue
        j = loc_y[ji]
        ans += sum(j < li for li in last_indices)
print(ans)

+from bisect import bisect + -d1 = set() -d2 = set() -d3 = set() -for c in s: -    for t in d2: -        d3.add(t + c) -    for t in d1: -        d2.add(t + c) -    d1.add(c) -print((len(d3))) +location = [[] for _ in range(10)] +for i, c in enumerate(map(int, s)): +    location[c].append(i) +location = [loc for loc in location if loc] +last_indices = [loc[-1] for loc in location] +ans = 0 +for loc_x in location: +    i = loc_x[0] +    for loc_y in location: +        ji = bisect(loc_y, i) +        if ji >= len(loc_y): +            continue +        j = loc_y[ji] +        ans += sum(j < li for li in last_indices) +print(ans)