Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#AGC 013 C - Ants on a Circle
N,L,T = map(int, input().split())
X = [0]*N
W = [0]*N
for n in range(N):
    X[n],W[n] = map(int, input().split())

for t in range(T):
    #print('now is ',t)
    for n in range(N):
        if n == N-1:
            if X[N-1]%L == X[0] and W[N-1] == 1 and W[0] == 2:
                W[N-1] = 2
                W[0] =1
                X[0] +=1
            else:
                X[N-1] += (-1)**(W[N-1]+1)
                X[N-1] %= L
                if X[N-1] == X[0]:
                	W[N-1] = 2
                	W[0] = 1
        else:
            if X[n] == X[n+1]:
                W[n] = 2
                W[n+1] = 1
                X[n] += (-1)**(W[n]+1)
                X[n] %= L
            elif (X[n]+1)%L == X[n+1] and W[n] == 1 and W[n+1] == 2:
                W[n] = 2
                W[n+1] =1
                X[n+1] -=1
            else:
                X[n] += (-1)**(W[n]+1)
                X[n] %= L
    #for n in range(N):
        #print(X[n],' ',W[n])
for n in range(N):
    print(X[n])

### FIXED CODE ###

N,L,T = map(int, input().split())
X = [0]*N
W = [0]*N
for n in range(N):
    X[n],W[n] = map(int, input().split())
index = 0
#after T
for n in range(N):
    X[n] += ((-1)**(W[n]+1))*T
    index += X[n]//L
    X[n] %= L
index %= N
X.sort()
X = X[index:] + X[:index] #No.1 wo hajimeni mottekuru.
for n in range(N):
    print(X[n])
### BUGGY CODE ###

N,M=map(int,input().split())
l=1
r=N
dis=[]
if N%2==1:
    for i in range(M):
        print(l,r)
        l=l+1
        r=r-1
else:
    for _ in range(M):
        print(l,r)
        a,b=r-l,N+l-r
        dis.append(a)
        dis.append(b)
        l=l+1
        r=r-1
        if r-l in dis or N+l-r in dis or r-l==N+l-r:
            r=r-1

### FIXED CODE ###

N,M=map(int,input().split())
l=1
r=N
dis=set()
if N%2==1:
    for i in range(M):
        print(l,r)
        l=l+1
        r=r-1
else:
    for _ in range(M):
        print(l,r)
        a,b=r-l,N+l-r
        dis.add(a)
        dis.add(b)
        l=l+1
        r=r-1
        if r-l in dis or N+l-r in dis or r-l==N+l-r:
            r=r-1
### BUGGY CODE ###

import bisect

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
ans = sum(A)

for _ in range(M):
    b, c = map(int, input().split())
    if c <= A[0]:
        continue
    index = bisect.bisect_left(A, c)
    index = min(index, b)
    for i in range(index):
        ans += c - A[i]
        A[i] = c
    if index > 0:
        A = sorted(A)

print(ans)



### FIXED CODE ###

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))

bc = [list(map(int, input().split())) for _ in range(M)]

ans = sum(A)

bc = sorted(bc, key=lambda i: i[1], reverse=True)

i = 0
for b, c in bc:
    for _ in range(b):
        if A[i] > c:
            break
        ans += c - A[i]
        i += 1
        if i >= N:
            break
    else:
        continue
    break

print(ans)
### BUGGY CODE ###

import math
# ????????§??????????????????????????????
def fact(n):
    sum = 0
    for i in range(1,n+1):
        sum += math.log(i)
    return math.exp(sum)
# ????????????????????§??????
def fact2(n):
    return math.sqrt(2*math.pi*n)*(n/math.exp(1))**n

def mfactorial(n, _factcache={}):
  if n not in _factcache:
    _factcache[n] = math.factorial(n)
  return _factcache[n]


n = []
while True:
    try:
        tmp = int(input())
        if tmp == 0:
            break
        else:
            n.append(tmp)
    except EOFError:
        break

for i in range(len(n)):
    f = mfactorial(n[i])
    k = 0
    while True:
        if f % (10 ** k) != 0:
            print(k-1)
            break
        else:
            k += 1

### FIXED CODE ###

n = []
while True:
    try:
        tmp = int(input())
        if tmp == 0:
            break
        else:
            n.append(tmp)
    except EOFError:
        break

for i in range(len(n)):
    c = 0
    d = 5
    for j in range(1,n[i]+1):
        while d <= n[i]:
            c += (n[i]//d)
            d *= 5
    print(c)
### BUGGY CODE ###

a, b, c = map(int, input().split())
ab = abs(a-b)
bc = abs(b-c)

if a == b == c:
  if a % 2 == 0:
    print(-1)
  else:
    print(0)

count = 0

while True:
  if ab % 2 != 0 or bc % 2 != 0:
    break
  else:
    ab = ab // 2
    bc = bc // 2
    count += 1

print(count)

### FIXED CODE ###

a, b, c = map(int, input().split())
ab = abs(a-b)
bc = abs(b-c)

if a == b == c:
  if a % 2 == 0:
    print(-1)
    exit()
  else:
    print(0)
    exit()

count = 0

while True:
  if ab % 2 != 0 or bc % 2 != 0:
    break
  else:
    ab = ab // 2
    bc = bc // 2
    count += 1

print(count)
### BUGGY CODE ###

from decimal import Decimal
n = int(input())
a = [Decimal(input()) for i in range(n)]
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        if (a[i] * a[j]) % 1 == 0:
            ans += 1
print(ans)

### FIXED CODE ###

from copy import deepcopy
from decimal import Decimal
n = int(input())
a = [int(Decimal(input()) * (pow(10, 9))) for i in range(n)]
l = [[0] * 19 for i in range(19)]
ans = 0
for i in a:
    cnt2 = 0
    i2 = deepcopy(i)
    while i2 % 2 == 0 and cnt2 < 18:
        i2 //= 2
        cnt2 += 1
    cnt5 = 0
    i5 = deepcopy(i)
    while i5 % 5 == 0 and cnt5 < 18:
        i5 //= 5
        cnt5 += 1
    ans += l[19 - cnt2 - 1][19 - cnt5 - 1]
    for i in range(cnt2 + 1):
        for j in range(cnt5 + 1):
            l[i][j] += 1
print(ans)
### BUGGY CODE ###

n = int(input())
nn = (n + 1) // 2
s = [0]*n
print(0)
s[0] = input()
if s[0] == "Vacant":
    exit()
print(n-1)
s[n-1] = input()
if s[n-1] == "Vacant":
    exit()
ll = 0
hh = nn-1
while hh - ll > 1:
    l = ll*2
    h = hh*2
    ii = (ll + hh) // 2
    i = ii*2
    print(i)
    s[i] = input()
    if s[i] == "Vacant":
        exit()
    elif s[i] != s[l]:
        ll = ii
    else:
        hh = ii
print(ll+hh)

### FIXED CODE ###

n = int(input())
nn = (n + 1) // 2
s = [0]*n
print(0)
s[0] = input()
if s[0] == "Vacant":
    exit()
print(n-1)
s[n-1] = input()
if s[n-1] == "Vacant":
    exit()
ll = 0
hh = nn-1
while hh - ll > 1:
    l = ll*2
    h = hh*2
    ii = (ll + hh) // 2
    i = ii*2
    print(i)
    s[i] = input()
    if s[i] == "Vacant":
        exit()
    elif s[i] != s[l]:
        hh = ii
    else:
        ll = ii
print(ll+hh)
### BUGGY CODE ###

a,b,k=map(int, input().split())
l=[int(i) for i in range(a,b+1)]
l2=(l[:k]+l[-k:])
if 2*k>b-a+1:
  print(" ".join(map(str, l)))
else:
  print(" ".join(map(str, l2)))

### FIXED CODE ###

a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b+1)):
    ans.append(i)
for j in range(b,max(b-k,a-1),-1):
    if j not in ans:
        ans.append(j)
ans.sort()
for k in range(len(ans)):
  print(ans[k])
### BUGGY CODE ###

#!python3
import sys
sys.setrecursionlimit(1000000000)
from functools import lru_cache

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    A = list(enumerate(iim()))

    A.sort(key=lambda x: x[1], reverse=True)

    @lru_cache
    def rec(i, j1, j2):
        if i == N:
            return 0
        pos, ai = A[i]

        ax = abs(pos - j1) * ai + rec(i+1, j1+1, j2)
        bx = abs(pos - j2) * ai + rec(i+1, j1, j2-1)

        return max(ax, bx)

    print(rec(0, 0, N-1))

if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    A = list(enumerate(iim()))

    A.sort(key=lambda x: (x[1], (2*x[0]-N)**2), reverse=True)

    dp = [0] * (N+1)
    dp0 = dp[:]
    for i, (j, ai) in enumerate(A):
        for k in range(i+1):
            dp[k] = max(dp[k], dp0[k] + abs(N-i+k-1-j) * ai)
            dp[k+1] = max(dp[k+1], dp0[k] + abs(k-j) * ai)
        dp, dp0 = dp0, dp

    print(max(dp0))

if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

n=int(input())
a=list(map(int,input().split()))

ans=1
for i in range(n):
    ans*=a[i]

if ans>10**18:
    print(-1)
else:
    print(ans)



### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n=int(input())
a=list(map(int,input().split()))

for i in range(n):
    if a[i]==0:
        print(0)
        exit()

ans=1
for i in range(n):
#    print(ans)
    if ans>10**18:
        print(-1)
        exit()
    else:
        ans*=a[i]

if ans>10**18:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

import numpy as np

N,M=map(int,input().strip().split())
PY=np.array([list(map(int,input().strip().split())) for _ in range(M)])

l=[[] for n in range(N)]
for m in range(M):
    l[PY[m,0]-1].append(PY[m,1])

dp=[[0 for i in range(max(PY[:,1]))] for j in range(max(PY[:,0]))]
for n in range(N):
    if l[n]:
        l[n].sort()
        for i in range(len(l[n])):
            city="000000"+str(n+1)
            num="000000"+str(i+1)
            dp[n][l[n][i]-1]=str(city[-6:]+num[-6:])
for m in range(M):
    print(dp[PY[m,0]-1][PY[m,1]-1])

### FIXED CODE ###

import numpy as np

N,M=map(int,input().strip().split())
PY=np.array([list(map(int,input().strip().split())) for _ in range(M)])

l=[[] for n in range(N)]
for m in range(M):
    l[PY[m,0]-1].append(PY[m,1])

dp={}
for n in range(N):
    if l[n]:
        l[n].sort()
        for i in range(len(l[n])):
            city="000000"+str(n+1)
            num="000000"+str(i+1)
            dp[(n,l[n][i]-1)]=str(city[-6:]+num[-6:])
for m in range(M):
    print(dp[(PY[m,0]-1,PY[m,1]-1)])
### BUGGY CODE ###

A, B, C = map(int, input().split())

res = B
lim = A + B
for i in range(C):
  res += 1
  if i + 1 >= lim + 1:
    break

print(res)

### FIXED CODE ###

A, B, C = map(int, input().split())

res = B
lim = A + B

if lim + 1 >= C + 1:
  res += C
else:
  res += lim + 1
print(res)
### BUGGY CODE ###

from sys import stdin
from sys import setrecursionlimit

setrecursionlimit(10 ** 7)

n,m,k = map(int,stdin.readline().rstrip().split())
mod = 998244353
wariate = 1
point = 0

def combination(n,r,mod=mod):
    r=min(r,n-r)
    up,down=1,1
    for i in range(r):
        up=up*(n-i)%mod
        down=down*(i+1)%mod
    return up*pow(down,mod-2,mod)%mod

li = [0]*(n+1)
for i in range(n+1):
    li[i] = combination(n-1,i)%mod

for i in range(n-1,-1,-1):
    now = m
    if i != n-1:
        wariate *= m-1
        wariate %= mod
    now *= wariate%mod
    now *= li[i]%mod
    if i <= k:
        point += now%mod

print(point%mod)

### FIXED CODE ###

from sys import stdin
from sys import setrecursionlimit

setrecursionlimit(10 ** 7)

n,m,k = map(int,stdin.readline().rstrip().split())
mod = 998244353
wariate = 1
point = 0

def prepare(n, MOD=mod):
    facts = [1]*(n+1)
    for i in range(1, n+1):
        facts[i] = facts[i-1]*i%MOD
    invs = [1]*(n+1)
    invs[n] = pow(facts[n], MOD-2, MOD)
    for i in range(0, n)[::-1]:
        invs[i] = invs[i+1] * (i+1) % MOD
    return facts, invs
facts, invs = prepare(n, mod)
for i in range(n-1,-1,-1):
    now = m
    if i != n-1:
        wariate *= m-1
        wariate %= mod
    now *= wariate%mod

    now *= facts[n-1]*invs[n-1-i]*invs[i]
    if i <= k:
        point += now%mod

print(point%mod)
### BUGGY CODE ###

N=int(input())
a=[int(input()) for i in range(N)]
b=[]
j=1
k=1
if 2 not in a:
    print(-1)
else:
    while j in range(1,N+1):
      if a[k-1] not in b:
         b.append(a[k-1])
         if a[k-1]==1:
                 break
         elif a[k-1]==2:
                 break
         else:
            j += 1
            k = a[k-1]
      else:
          break
    if 2 not in b:
        print(-1)
    else:
        print(len(b))

### FIXED CODE ###

N=int(input())
a=[int(input()) for i in range(N)]
b=[]
j=1
k=1
c=1
if 2 not in a:
    print(-1)
else:
    while j in range(1,N+1):
         c += 1
         if a[k-1]==1:
                 print(-1)
                 break
         elif a[k-1]==2:
                 print(c-1)
                 break
         else:
            j += 1
            k = a[k-1]
    if c>=(N+1):
        print(-1)
### BUGGY CODE ###

n,m = map(int,input().split())
a = sorted(map(int,input().split()))

for i in range(m):
    a[-1] //= 2
    a = sorted(a)
    
print(sum(a))


### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))

import heapq
a = list(map(lambda x:x*(-1),a))
heapq.heapify(a)

for i in range(m):
    b = heapq.heappop(a)
    heapq.heappush(a,-(-b//2))
    
print(sum(a)*(-1))
### BUGGY CODE ###

n = int(input())
ls = [int(input()) for _ in range(n)]
p = 200000
ans = 0
if p>n:
    p=n

def cul(n, x):
    l = len(x)
    b = [x[i] for i in range(l)]
    b.pop(n)
    return max(b)
    
for i in range(p):
    s = cul(i,ls[:p])
    print(s)

### FIXED CODE ###

n = int(input())
ls = [int(input()) for _ in range(n)]
ls_sort = sorted(ls,reverse=True)

for i in range(n):
    if ls[i] == ls_sort[0]:
        print(ls_sort[1])
    else:
        print(ls_sort[0])
### BUGGY CODE ###

def solve():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    a2=set(a)
    a2=list(sorted(a2))
    def c1(num1):
        return a.count(num1)
    for i in range(len(a2)):
        num=0
        if c1(a2[i])==1:
            for j in range(i):
                if a2[i]%a2[j]==0:
                    num=1
                    break
                if a2[i]/2+1<a2[j]:
                    break
            if num==0:
                ans+=1
    print(ans)

solve()


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=0
a.sort()
num=a[-1]
dp=[True]*num
seen=[0]*num
for i in range(n):
    num2=a[i]
    if dp[num2-1]==True:
        if seen[num2-1]==1:
            dp[num2-1]=False
        for j in range(2,num//num2+1):
            dp[j*num2-1]=False
    seen[a[i]-1]=1
ans=0
for i in range(n):
    if dp[a[i]-1]==True:
        ans+=1
print(ans)
### BUGGY CODE ###

from operator import mul
from functools import reduce
n=int(input())
lis=list(map(int,input().split()))
ans=reduce(mul,lis)
if ans>1000000000000000000:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n=int(input())
lis=list(map(int,input().split()))
ans=1
for i in lis:
    ans*=i
    if ans>1000000000000000000:
        ans=-1
        break
if 0 in lis:
    ans=0

print(ans)
### BUGGY CODE ###

N = int(input())

count = 0
for A in range(1, N):
  for B in range (1, N):
    if (A*B) < N:
      count += 1

print(count)

### FIXED CODE ###

N = int(input())

count = 0
for A in range(1, N):
  N_ = (N - 1) // A
  count += N_

print(count)
### BUGGY CODE ###

r,g,b,n=map(int,input().split())

sum=0
for x in range(0,3001):
    for y in range(0,3001):
        if r*x+g*y<=n and (n-r*x-g*y)%b==0:
            sum+=1
print(sum)

### FIXED CODE ###

r,g,b,n=map(int,input().split())

sum=0
for x in range(0,1+(n//r)):
    for y in range(0,1+(n-x*r)//g):
        if (n-r*x-g*y)%b==0:
            sum+=1
print(sum)
### BUGGY CODE ###

from bisect import bisect_right


def solve():
    N, *ABC = map(int, open(0).read().split())
    A = ABC[:N]
    B = ABC[N:2*N]
    C = ABC[2*N:]
    B.sort()
    C.sort()
    
    ans = 0
    for i in range(N):
        index = bisect_right(B, A[i])
        for j in range(index, N):
            ans += N - bisect_right(C, B[j])
    print(ans)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

from bisect import bisect_left, bisect_right


def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    
    A.sort()
    C.sort()
    
    ans = 0
    for i in range(N):
        cnt_a = bisect_left(A, B[i])
        cnt_b = N - bisect_right(C, B[i])
        ans += cnt_a * cnt_b
    print(ans)


if __name__ == '__main__':
    solve()
### BUGGY CODE ###

import math
from functools import reduce
n = int(input())
c = 0
def gcd(*numbers):
    return reduce(math.gcd, numbers)
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            c += gcd(i,j,k)

print(c)


### FIXED CODE ###

import math
import statistics
n = int(input())
ans = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        c = math.gcd(i,j)
        for k in range(1,n+1):
            ans += math.gcd(c,k)

print(ans)
### BUGGY CODE ###

N, K  = map(int,input().split())
h_list = list(map(int,input().split()))

INF = 100001010000100
dp = [INF]*N
dp[0] = 0

for i in range(1,N):
    start = max(0,i-K)
    dp[i] = min([dp[j]+abs(h_list[i]-h_list[j]) for j in range(start,i)])

print(dp[N-1])

### FIXED CODE ###

N, K  = map(int,input().split())
h_list = list(map(int,input().split()))

INF = 100001010000100
dp = [INF]*N
dp[0] = 0

for i in range(1,N):
    start = max(0,i-K)
    dp[i] = min([dp[j]+abs(h_list[i]-h_list[j]) for j in range(start,i)])

print(dp[N-1])
### BUGGY CODE ###

n=int(input())

pdat=[]
mdat=[]

for i in range(n):
    s=input()
    
    mini=0
    now=0
    for q in range(len(s)):
        if s[q]=="(":
            now+=1
        else:
            now-=1
            mini=(min(mini,now))
    if now>=0:
        pdat.append((now,mini,mini-now))
    else:
        mdat.append((now,mini,mini-now))

pdat.sort(key=lambda x:-x[1])
mdat.sort(key=lambda x:x[2])

now=0
for d in pdat+mdat:
    if now+d[1]<0:
        print("No")
        break
    now+=d[0]
else:
    if now==0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n=int(input())

pdat=[]
mdat=[]

for i in range(n):
    s=input()
    
    mini=0
    now=0
    for q in range(len(s)):
        if s[q]=="(":
            now+=1
        else:
            now-=1
            mini=(min(mini,now))
    if now>=0:
        pdat.append((now,mini,mini-now))
    else:
        mdat.append((now,mini,mini-now))

pdat.sort(key=lambda x:-x[1])
mdat.sort(key=lambda x:x[2])

now=0
for d in pdat+mdat:
    if now+d[1]<0:
        print("No")
        break
    now+=d[0]
else:
    if now==0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

# N, W = 3, 8
# ARR = [
#     [3, 30],
#     [4, 50],
#     [5, 60],
# ]
#
N, W, = 6, 15
ARR = [
    [6, 5],
    [5, 6],
    [6, 4],
    [6, 6],
    [3, 5],
    [7, 2],
]


N,W = map(int,input().split())
ARR = []

for i in range(N):
    ARR.append(list(map(int,input().split())))


def calculate(n, w, arr):
    srr = [[0] * (w + 1) for i in range (n + 1)]

    for i in range(1, n + 1):
        for j in range(1, w + 1):
            if (j - arr[i-1][0]) >= 0:
                s1 = srr[i-1][j - arr[i-1][0]] + arr[i-1][1]
                s2 = srr[i-1][j]
                srr[i][j] = max(s1, s2)
            else:
                srr[i][j] = srr[i - 1][j]

    print(srr[-1][-1])


calculate(N, W, ARR)


### FIXED CODE ###

# N, W = 3, 8
# ARR = [
#     [3, 30],
#     [4, 50],
#     [5, 60],
# ]
#
# N, W, = 6, 15
# ARR = [
#     [6, 5],
#     [5, 6],
#     [6, 4],
#     [6, 6],
#     [3, 5],
#     [7, 2],
# ]


N,W = map(int,input().split())
ARR = []

for i in range(N):
    ARR.append(list(map(int,input().split())))

def calculate(n, w, arr):
    result = [[0] * (w + 1) for i in range(n + 1)]


    for i in range(n):
        width = arr[i][0]
        value = arr[i][1]
        for j in range(w + 1):

            if j >= width:
                result[i + 1][j] = max(result[i][j - width] + value, result[i + 1][j])

            result[i + 1][j] = max(result[i + 1][j], result[i][j])

    # print(result)
    print(result[n][w])


calculate(N, W, ARR)
### BUGGY CODE ###

#!/usr/bin/env python3

N=int(input())
A=list(map(int,input().split()))

ans=1

for i in range(N):
    ans*=A[i]

if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

#!/usr/bin/env python3

N=int(input())
A=list(map(int,input().split()))

ans=1

for i in range(N):
    if A[i]==0:
        print(0)
        exit()

for i in range(N):
    ans*=A[i]
    if ans > 1000000000000000000:
        print(-1)
        exit()

print(ans)
### BUGGY CODE ###

S = list(map(int, list(input())))
N = len(S)
CNT = [0]*2019
CNT[0] = 1
base = pow(10, N+1)
num = 0
for i in range(N):
    base //= 10
    num = num * 10 + S[i]
    CNT[(num*base)%2019] += 1
ans = 0 
for cnt in CNT:
    if cnt==0: continue
    ans += (cnt*(cnt - 1)) // 2
print(ans)

### FIXED CODE ###

S = list(map(int, list(input())))[::-1]
N = len(S)
CNT = [0]*2019
CNT[0] = 1
num = 0
d = 0
for i in range(N):
    num += S[i]*pow(10, d, 2019)
    num %= 2019
    CNT[num] += 1
    d += 1
ans = 0 
for cnt in CNT:
    ans += (cnt*(cnt - 1)) // 2
print(ans)
### BUGGY CODE ###

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
s = input()

ans = set()
a_alr = []
b_alr = {}

for i in range(10):
    b_alr[str(i)] = []

for i in range(n-2):
    if(s[i] in a_alr):
        continue
    for j in range(i+1,n-1):
        if(s[j] in b_alr[s[i]]):
            continue
        for k in range(j+1,n):
            tmp = s[i]+s[j]+s[k]
            ans = ans | set([tmp])

        b_alr[s[i]].append(s[j])
    a_alr.append(s[i])

print(len(ans))

### FIXED CODE ###

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
s = input()

ans = 0
a_alr = []
b_alr = {}

for i in range(10):
    b_alr[str(i)] = []

for i in range(n-2):
    if(len(a_alr) == 10):
        break
    if(s[i] in a_alr):
        continue

    for j in range(i+1,n-1):
        if(len(b_alr[s[i]]) == 10):
            break
        if(s[j] in b_alr[s[i]]):
            continue
        
        ans += len(set(s[j+1:]))
        
        b_alr[s[i]].append(s[j])
    a_alr.append(s[i])

print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))

max = (10 ** 9) + 7

sum = 0
for i in range (n-1):
    for j in range (n):
        if i > j:
            continue
        if i != j:
            sum += a[i]*a[j]
        if sum > max:
            sum = sum % max


print(sum)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))

max = (10 ** 9) + 7

#一列の総和
wa = 0
for i in range (n):
    wa += a[i]

#a11, a22, ...の総和
rem = 0
for i in range(n):
    rem += a[i]*a[i]

sum = ((wa*wa) - rem) // 2

ans = sum % max

print(ans)
### BUGGY CODE ###

import sys
import heapq
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def shortest_path(s, n, w, es):
    d = [float("inf")]*n
    d[s] = 0
    while True:
        update = False
        for p,q,r in es:
            if d[p] != float("inf") and d[q] > d[p] + r:
                d[q] = d[p] + r
                update = True
        if not update:
            break
    return d

def main():
    n = int(input())
    es = list()
    cnt = 0
    ps = [1,6,36,216,1296,7776,46656,9,81,729,6561,590491,6,36,216,1296,7776,46656,9,81,729,6561,59049]
    ps.sort()
    for i in range(n+1):
        for j in ps:
            if i + j <= n:
                es.append([i, i+j, 1])
                cnt += 1
            else:
                break

    reslut = shortest_path(0,n+1, cnt*2, es)
    print(reslut[n])
    return

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import heapq
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def shortest_path(s, n, w, es):
    d = [float("inf")]*n
    d[s] = 0
    while True:
        update = False
        for p,q,r in es:
            if d[p] != float("inf") and d[q] > d[p] + r:
                d[q] = d[p] + r
                update = True
        if not update:
            break
    return d

def main():
    n = int(input())
    es = list()
    cnt = 0
    ps = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]
    ps.sort()
    for i in range(n+1):
        for j in ps:
            if i + j <= n:
                es.append([i, i+j, 1])
                cnt += 1
            else:
                break

    reslut = shortest_path(0,n+1, cnt, es)
    print(reslut[n])
    return

if __name__ == '__main__':
    main()