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

s=input()

res=0
for i in range(len(s)):
	for j in range(i+4,len(s)):
		if int(s[i:j+1])%2019==0:
			res+=1
			
print(res)

### FIXED CODE ###

s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

for i in range(2019):
    cnt += int(countRemainder[i] * (countRemainder[i] - 1) / 2)

print(cnt)
### BUGGY CODE ###

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

m = 0

for x in reversed(range(max(1, n-b),n+1)):
    y = (a*x)//b - a * (x//b)
    if m < y:
        m = y

print(m)

### FIXED CODE ###

import math

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

m = 0
x = n

while x >= n-b:
    if m > (a*x) // b:
        break
    else:
        y =  math.floor((a * (x / b - math.floor(x / b))))
        if m < y:
            m = y
            x = b * math.floor(x / b) - 1
        else:
            x-=1  

print(m)
### BUGGY CODE ###

N = int(input())
for h in range(3501):
    for n in range(3501):
        if 4*h*n - N*n - N*h == 0:
            continue
        w = N*h*n / (4*h*n - N*n - N*h)
        if w > 0 and int(w) == w:
            print(h, n, int(w))
            exit()


### FIXED CODE ###

N = int(input())
for h in range(3501):
    for n in range(3501):
        if 4*h*n - N*n - N*h == 0:
            continue
        w = N*h*n / (4*h*n - N*n - N*h)
        if w > 0 and int(w) == w:
            print(h, n, int(w))
            exit()
### BUGGY CODE ###

def locnt(s):
    index = 0
    lopair = 0
    s = list(s)
    while(index <= len(s)-2):
        if (s[index] != s[index+1]):
            lopair += 1
            index += 2
        else :
            index += 1
    return lopair

ans = 0
s = input()
lopair = locnt(s)
while(lopair):
    i = 0
    s = list(s)
    while(lopair):
        if s[i] != s[i+1]:
            lopair -= 1
            ans += 2
            s.pop(i)
            s.pop(i)
        else:
            i += 1
    s = "".join(s)
    lopair = locnt(s)
print(ans)

### FIXED CODE ###

s=input();f=s.count;print(2*min(f("1"),f("0")))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(1,n+1):
  b.append(a.index(i)+1)
print(*b)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i,q in enumerate(a):
  #print(i+1,q)
  b[q-1]=i+1
print(*b)
### BUGGY CODE ###

def recursin_operation(S, len_init_s):
    S = list(S)
    N = len(S)
    lst = [i for i in range(N - 1) if S[i] != S[i + 1]]
    nums_of_deleted = []
    if len(lst) != 0:
        for i in lst:
            S_next = [S[j] for j in range(len(S)) if j < i or j > i + 1]
            nums_of_deleted.append(recursin_operation(S_next, len_init_s))
    else:
        nums_of_deleted.append(len_init_s - len(S))

    return max(nums_of_deleted)


def main():
    S = input()
    len_init_s = len(S)
    ans = recursin_operation(S, len_init_s)
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

S = input()
len_S = len(S)
zero_lst = [S[i] for i in range(len_S) if S[i] == "0"]
one_lst = [S[i] for i in range(len_S) if S[i] == "1"]
ans = min(len(zero_lst), len(one_lst)) * 2
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3

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

C = max(A, B)

for i in range(1, C+1):
    if abs(A-i) == abs(B-i):
        print(i)
        exit()

print("IMPOSSIBLE")

### FIXED CODE ###

#!/usr/bin/env python3

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

if (A+B)%2 == 0:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

s = input()
ans = 0
f = 0
while f == 0:
  for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
      next
    else:
      ans += 2
      s = s[:i] + s[i + 2:]
      break
  if s.count('0') == 0 or s.count('1') == 0:
    f =1 
    break
print(ans)    

### FIXED CODE ###

s = input()
k = len(s)
a = s.count('0')
b = s.count('1')
ans = 0
if a >= b:
  ans = k - a + b
else:
  ans = k + a - b
print(ans)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
def position_zip(a,flag):
  j=0
  d={}
  for i in sorted(a):
    if i in d:continue
    d[i]=j
    j+=1
  if flag==1:return d
  return [d[i] for i in a]
class BinaryIndexedTree:
  def __init__(self,n):
    self.bit=[0]*n
  def add(self,i,x):
    i+=1
    while i<=len(self.bit):
      self.bit[i-1]+=x
      i+=i&-i
  def sum_sub(self,i):
    a=0
    i+=1
    while i:
      a+=self.bit[i-1]
      i-=i&-i
    return a
  def sum(self,i,j):
    a=self.sum_sub(j+1)
    if i!=0:a-=self.sum_sub(i-1)
    return a
n,q=map(int,input().split())
a=list(map(int,input().split()))
a=position_zip(a,0)
k=max(a)+1
ans=[0]*q
queries=[list(map(lambda x:int(x)-1,input().split()))[::-1]+[i]for i in range(q)]
queries.sort()
queries.append([10*20,0,0])
lastAppeared=[-1]*k
bitt=BinaryIndexedTree(n)
j=0
for i in range(n):
  if lastAppeared[a[i]]!=-1:
    bitt.add(lastAppeared[a[i]],-1)
    bitt.add(i,1)
    lastAppeared[a[i]]=i
  else:
    bitt.add(i,1)
    lastAppeared[a[i]]=i
  while queries[j][0]==i:
    r,l,ind=queries[j]
    j+=1
    ans[ind]=bitt.sum(l,r-1)
print(*ans)

### FIXED CODE ###

def main():
  def add(i,x):
    i+=1
    while i<=n:
      bit[i-1]+=x
      i+=i&-i
  def sum_sub(i):
    a=0
    i+=1
    while i:
      a+=bit[i-1]
      i-=i&-i
    return a
  def sum(i,j):
    a=sum_sub(j+1)
    if i!=0:a-=sum_sub(i-1)
    return a
  
  n,q,*x=map(int,open(0).read().split())
  a=x[:n]
  queries=[]
  for i in range(q):
    l,r=x[n+i*2:n+(i+1)*2]
    l-=1
    r-=1
    queries.append(r<<40|l<<20|i)
  ans=[0]*q
  queries.sort()
  for i in range(q):
    ind=queries[i]%(1<<20)
    queries[i]>>=20
    l=queries[i]%(1<<20)
    queries[i]>>=20
    r=queries[i]
    queries[i]=[r,l,ind]
  queries.append([10*20])
  lastAppeared=[-1]*n
  bit=[0]*n
  j=0
  for i in range(n):
    if lastAppeared[a[i]-1]!=-1:
      add(lastAppeared[a[i]-1],-1)
      add(i,1)
      lastAppeared[a[i]-1]=i
    else:
      add(i,1)
      lastAppeared[a[i]-1]=i
    while queries[j][0]==i:
      r,l,ind=queries[j]
      j+=1
      ans[ind]=sum(l,r-1)
  print(*ans)
if __name__ == "__main__":
  main()
### BUGGY CODE ###

def main():
    N, M, K  = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    bs = M
    ans = 0
    for i in range(N + 1):
        asum = sum(A[:i])
        if asum > K:
            break
        for j in range(bs, -1, -1):
            if sum(B[:j]) + asum <= K:
                bs = j
                break
        ans = max(ans, i + bs)
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N, M, K  = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    a, b = [0], [0]
    for i in range(N):
        a.append(a[i] + A[i])
    for i in range(M):
        b.append(b[i] + B[i])
    bs = M
    ans = 0
    for i in range(N + 1):
        if a[i] > K:
            break
        for j in range(bs, -1, -1):
            if b[j] + a[i] <= K:
                bs = j
                break
        ans = max(ans, i + bs)
    print(ans)

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

n,k=map(int,input().split())
a=list(map(int,input().split()))
old=1
for j in range(k):
	old*=a[k-1-j]
for i in range(n-k+1):
	new=1
	for s in range(k):
		new*=a[k-1-s+i]
	if i>0 and new>old:
		print('Yes')
	elif i>0 and new<=old:
		print('No')
	old=new

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n-k+1):
	if i+k<n:
		if a[i]<a[i+k]:
			print('Yes')
		else:
			print('No')
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import  dijkstra
from scipy.sparse import csr_matrix

n,x,y = map(int,input().split())
graph = [[0 for i in range(n)]for j in range(n)]

for i in range(n-1):
    graph[i][i+1] = 1
    graph[i+1][i] = 1
    
graph[x-1][y-1] = 1
graph[y-1][x-1] = 1

ans = dijkstra(graph )

for i in range(1,n):
    print(int(np.count_nonzero(ans == i)/2))

### FIXED CODE ###

n,x,y = map(int,input().split())
ans = [0]*n
for i in range(1,n+1):
    for j in range(i+1,n+1):
        ans[min(abs(i-j) , abs(i-x)+1+abs(j-y), abs(i-y)+1+abs(j-x)) ]+=1
        
for i in range(1,n):
    print(ans[i])
### BUGGY CODE ###

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

a_min, a_max = min(a), max(a)
cnt = 0
p = [-1] * N

for j in range(a_min, a_max+1):
    for i in range(N):
        if j-1 <= a[i] <= j+1:
            p[i] = j
    cnt = max(cnt, p.count(j))
print(cnt)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
 
set_a = set(a)
cnt = [0] * (max(a)+1)
ans = 0
 
for i in a:
    cnt[i] += 1
 
if len(cnt) == 1:
    print(cnt[0])
elif len(cnt) == 2:
    print(sum(cnt))
else:
    for i in range(1, max(a)):
        ans = max(ans, cnt[i-1]+cnt[i]+cnt[i+1])
    print(ans)
### BUGGY CODE ###

H,W,M=map(int,input().split())
Y=[0 for i in range(H+1)]
X=[0 for i in range(W+1)]
HW=[]
for i in range(M):
    h,w=map(int,input().split())
    Y[h]+=1
    X[w]+=1
    HW.append([h,w])

#print(Y,X)

LY=[]
LX=[]
MY=max(Y)
MX=max(X)
for i in range(H+1):
    if Y[i]==MY:
        LY.append(i)
for i in range(W+1):
    if X[i]==MX:
        LX.append(i)


#print(LY,LX)
import sys
for i in range(len(LY)):
    for j in range(len(LX)):
        if [LY[i],LX[j]] not in HW:
            print(MY+MX)
            sys.exit()
print(MY+MX-1)

### FIXED CODE ###

H,W,M=map(int,input().split())
Y=[0 for i in range(H+1)]
X=[0 for i in range(W+1)]
HW=[]
for i in range(M):
    h,w=map(int,input().split())
    Y[h]+=1
    X[w]+=1
    HW.append([h,w])

LY=[]
LX=[]
MY=max(Y)
MX=max(X)
for i in range(H+1):
    if Y[i]==MY:
        LY.append(i)
for i in range(W+1):
    if X[i]==MX:
        LX.append(i)

count=0
for i in range(M):
    if Y[HW[i][0]]==MY and X[HW[i][1]]==MX:
        count+=1

if count==len(LY)*len(LX):
    print(MY+MX-1)
else:
    print(MY+MX)
### BUGGY CODE ###

n,k = map(int,input().split())
num_list = list(map(int , input().split()))
candidate = []
tmp = [0]
num = 0
for i in range(n):
    i += num
    
    if sum(tmp) < sum(num_list[i:i+k]):
        tmp = num_list[i:i+k]
    else:
        candidate.append(tmp)
        num += 2
        
    if i == n-k:
        candidate.append(tmp)
        break
        
ans = 0
for i in candidate:
    tmp = 0
    for j in i:
        tmp += (j+1)/2
    if tmp > ans:
        ans = tmp
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
num_list = list(map(int , input().split()))
candidate = 0
for i in range(n-k+1):
    if i == 0:
        for j in range(k):
            candidate += (num_list[j]+1)/2
        tmp = candidate
    else:
        tmp += -(num_list[i-1]+1)/2 + (num_list[i+k-1]+1)/2
        if tmp > candidate:
            candidate = tmp
        
print(candidate)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for n in range(N)]

setA = set(A)

if len(setA) < 10:
    res = 0
    for a in setA:
        if A.count(a)%2 != 0:
            res += 1

    print(res)

else:
    res = []
    while A:
        a = A.pop()
        if a in res:
            res.remove(a)
        else:
            res.append(a)
    
    print(len(res))

### FIXED CODE ###

N = int(input())
A = [int(input()) for n in range(N)]
A = sorted(A)

res = []
tmp = A[0]
count = 1
for i in range(1,N):
    if A[i] == tmp:
        count += 1
    else:
        res.append(count%2 != 0)
        count = 1
    tmp = A[i]
res.append(count%2 != 0)

print(sum(res))
### BUGGY CODE ###

import sys
n=int(input())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))

day=0

match=[0 for i in range(n)]

while True:
  day+=1
  check=[True for i in range(n)]
  for i in range(n):
    if match[i]>=n-1:
      check[i]=False
    if check[i]==False:
      continue
    else:
      vs=a[i][match[i]]-1
      if check[i] and check[vs] and a[i][match[i]]-1==vs and a[vs][match[vs]]-1==i:
        match[i]+=1
        match[vs]+=1
        check[i]=False
        check[vs]=False
      
    if i==n-1:
      if not False in check:
        print(-1)
        sys.exit()
  if min(match)==n-1 and min(match)==max(match):
    break
        
print(day)


### FIXED CODE ###

import sys
MAX_INT = int(10e9)
MIN_NUM = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()
 
N = I()
a = [IL()[::-1] for i in range(N)]
 
used = [-1]*N
updatelist = [i for i in range(N)]
total = N*(N-1)//2
cnt = 0
days = 0
ul = []
while updatelist:
  ul = []
  for i in updatelist:
    #print(a)
    #print(i+1)
    if len(a[i]) > 0 and used[i] != days:
      numIND = a[i][-1] -1
      #print(numIND+1)
      if a[numIND][-1] == i+1 and used[numIND] != days:
        a[i].pop(-1)
        a[numIND].pop(-1)
        used[i] = days
        used[numIND] = days
        ul.append(i)
        ul.append(numIND)
        cnt += 1
  else:
    updatelist = ul[:]
    if len(ul) != 0:
      days += 1
#print(a)
#print(cnt)
if cnt == total:
  print(days)
else:
  print(-1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def ti(): return tuple(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

from functools import reduce

def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    return gcd(b, r)

def gcd_list(numbers):
    return reduce(gcd, numbers)

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = ii()
    A = ti()
    inf = 10**9+7
    lcm_a = lcm_list(A)

    ans = 0
    for num in A:
        ans =  (ans + lcm_a // num) % inf
        #ans %= inf
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def ti(): return tuple(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

from functools import reduce

def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    return gcd(b, r)

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

def table(n:int, p=10**9+7):
    global fact, factinv, inv
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, n+1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)

def main():
    N = ii()
    A = ti()
    P = 10**9 + 7
    lcm_a = lcm(A) % P

    N = 10**6+1
    inv_t = [0]+[1]
    for i in range(2,N):
        inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

    #print(inv_t[:10])
    ans = 0
    for num in A:
        ans = (ans + inv_t[num] * lcm_a) % P
        #ans +=  (ans + lcm_a // num) % P
        #ans %= inf
    print(ans)

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

N, W = map(int, input().split())

wv = []
for i in range(N):
    wv.append(list(map(int, input().split())))
    
dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
    for w in range(W+1):
        if w - wv[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w - wv[i][0]] + wv[i][1], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]

print(dp[N][W])

### FIXED CODE ###

N, W = map(int, input().split())

wv = []
for i in range(N):
    wv.append(list(map(int, input().split())))
    
dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
    for w in range(W+1):
        if w - wv[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w - wv[i][0]] + wv[i][1], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]

print(dp[N][W])
### BUGGY CODE ###

a, b, k = map(int, input().split())
list_ANS = [i for i in range(a, b+1)]

for _ in range(k):
    if len(list_ANS) != 0:
        a = list_ANS.pop(0)
        print(a)
    else:
        break
list_A = []
for _ in range(k):
    if len(list_ANS) != 0:
        b = list_ANS.pop(-1)
        list_A.append(b)

    else:
        break
if len(list_A) != 0:
    list_A.reverse()
    for i in list_A:
        print(i)

### FIXED CODE ###

a, b, k = map(int, input().split())
if b-a > pow(10, 5):
    list_ANS = [i for i in range(a, a+pow(10, 5))] + [i for i in range(b - pow(10, 5), b+1)]
else:
    list_ANS = [i for i in range(a, b+1)]

for _ in range(k):
    if len(list_ANS) != 0:
        a = list_ANS.pop(0)
        print(a)
    else:
        break
list_A = []
for _ in range(k):
    if len(list_ANS) != 0:
        b = list_ANS.pop(-1)
        list_A.append(b)

    else:
        break
if len(list_A) != 0:
    list_A.reverse()
    for i in list_A:
        print(i)
### BUGGY CODE ###

#python3

#cups for water, spoons for sugar
cup1, cup2, spoon1, spoon2, max_density, max_volume = (int(x) for x in input().split())

possible_water_volumes = set()

for cups1_nr in range(0, 30):
    for cups2_nr in range(0, 30):
        curr_water_volume = cups1_nr * cup1 + cups2_nr * cup2
        if curr_water_volume <= max_volume and curr_water_volume != 0:
            possible_water_volumes.add(curr_water_volume)

global_optimal_sugar = 0
global_optimal_water = 0
global_dencity = 0            
for water_volume in possible_water_volumes:
    curr_optimal_sugar = water_volume * max_density
    for spoons1_nr in range(0, 1 + curr_optimal_sugar // spoon1):
        curr_sugar = spoon1 * spoons1_nr
        spoons2_nr = ((curr_optimal_sugar - curr_sugar) // spoon2)
        curr_sugar += spoon2 * spoons2_nr
        curr_density = curr_sugar / (water_volume * 100 + curr_sugar)
        if curr_sugar + water_volume * 100 > max_volume:
            continue
        elif curr_sugar > curr_optimal_sugar:
            continue
        elif curr_density >= global_dencity:
            # print(curr_sugar, water_volume)
            global_optimal_sugar = curr_sugar
            global_optimal_water = water_volume
            global_dencity = curr_density
            
sugar_water_volume = global_optimal_water * 100 + global_optimal_sugar
print(sugar_water_volume, global_optimal_sugar)
        
        

### FIXED CODE ###

#python3

#cups for water, spoons for sugar
cup1, cup2, spoon1, spoon2, max_density, max_volume = (int(x) for x in input().split())

possible_water_volumes = set()

for cups1_nr in range(0, 30):
    for cups2_nr in range(0, 30):
        curr_water_volume = cups1_nr * cup1 + cups2_nr * cup2
        if curr_water_volume * 100 <= max_volume and curr_water_volume != 0:
            possible_water_volumes.add(curr_water_volume)

global_optimal_sugar = 0
global_optimal_water = cup1
global_dencity = 0            
for water_volume in possible_water_volumes:
    curr_optimal_sugar = min(water_volume * max_density, max_volume - water_volume * 100)
    for spoons1_nr in range(0, 1 + curr_optimal_sugar // spoon1):
        curr_sugar = spoon1 * spoons1_nr
        spoons2_nr = ((curr_optimal_sugar - curr_sugar) // spoon2)
        curr_sugar += spoon2 * spoons2_nr
        curr_density = curr_sugar / (water_volume * 100 + curr_sugar)
        if curr_sugar + water_volume * 100 > max_volume:
            continue
        elif curr_sugar > curr_optimal_sugar:
            continue
        elif curr_density > global_dencity:
            # print(curr_sugar, water_volume)
            global_optimal_sugar = curr_sugar
            global_optimal_water = water_volume
            global_dencity = curr_density
            
sugar_water_volume = global_optimal_water * 100 + global_optimal_sugar
print(sugar_water_volume, global_optimal_sugar)
### BUGGY CODE ###

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

for i in range(N - 1):
	for j in range(i + 1, N):
		s += (A[i] * A[j]) % (10 ** 9 + 7)
		s = s % (10 ** 9 + 7)
print(s)

### FIXED CODE ###

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

x = sum(A)
y = sum([A[i] ** 2 for i in range(N)])

print(((x ** 2 - y) // 2) % (10 ** 9 + 7))
### BUGGY CODE ###

n,m = map(int,input().split())
abl = []
for _ in range(m):
   a,b = map(int,input().split())
   cl = list(map(int,input().split()))
   bit = 0
   for c in cl:
      bit += 2**(c-1)
   abl.append((a,bit))

bitdp = [[float('inf') for i in range(1<<n)] for i in range(m+1)]
   
bitdp[0][0] = 0

for i in range(m):
   for j in range(1<<n):
      bitdp[i+1][j] = min(bitdp[i][j], bitdp[i+1][j])
      bitdp[i+1][j|abl[i][1]] = min(bitdp[i][j] + abl[i][0], bitdp[i][j|abl[i][1]], bitdp[i+1][j|abl[i][1]])

if bitdp[-1][(1<<n)-1] == float('inf'):
   print(-1)
else:
   print(bitdp[-1][(1<<n)-1])

### FIXED CODE ###

n,m = map(int,input().split())
abl = []
for _ in range(m):
   a,b = map(int,input().split())
   cl = list(map(int,input().split()))
   bit = 0
   for c in cl:
      bit += 2**(c-1)
   abl.append((a,bit))

bitdp = [[float('inf') for i in range(1<<n)] for i in range(m+1)]
   
bitdp[0][0] = 0

for i in range(m):
   for j in range(1<<n):
      bitdp[i+1][j] = min(bitdp[i][j], bitdp[i+1][j])
      bitdp[i+1][j|abl[i][1]] = min(bitdp[i][j] + abl[i][0], bitdp[i][j|abl[i][1]], bitdp[i+1][j|abl[i][1]])

if bitdp[-1][(1<<n)-1] == float('inf'):
   print(-1)
else:
   print(bitdp[-1][(1<<n)-1])
### BUGGY CODE ###

import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
N = int(X[0])
M = int(X[1])

H = [[0 for i in range(2)] for j in range(N)]
Y = [0 for j in range(N)]
Z =[0]*N

for i in range(N):
    H[i] =int(lines[1].split(' ')[i])

for j in range(M):
    A = int(lines[j+2].split(' ')[0])
    B = int(lines[j+2].split(' ')[1])
    if int(H[A-1]) <= int(H[B-1]):      
      Y[A-1] = -1
    if int(H[B-1]) <= int(H[A-1]):
      Y[B-1] = -1

good = 0
for i in range(N):
    if Y[i] ==0:
        good +=1
print(good)


### FIXED CODE ###

import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
N = int(X[0])
M = int(X[1])

H = []
Y = []

H=lines[1].split(' ')

for j in range(M):
    A = int(lines[j+2].split(' ')[0])
    B = int(lines[j+2].split(' ')[1])
    if int(H[A-1]) <= int(H[B-1]):      
      Y.append(A-1)
    if int(H[B-1]) <= int(H[A-1]):
      Y.append(B-1)
Z = len(set(Y))
print(N-Z)
### BUGGY CODE ###

n = int(input())
l = []
for i in range(n):
  a = int(input())
  if a not in l:
    l.append(a)
  else:
    l.remove(a)
print(len(l))

### FIXED CODE ###

N=int(input())
s=set()
for i in range(N):s^={input()}
print(len(s))
### BUGGY CODE ###

#三井住友2019 D 全列挙
def main():
    import sys
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    tmp = [-1,-1,-1]
    L = set()
    for i in range(N-2):
        tmp[0]=S[i]
        for j in range(i+1, N-1):
            tmp[1]=S[j]
            for k in range(j+1, N):
                tmp[2]=S[k]
                L.add(''.join(tmp))
    #print(tmp)
    print(len(L))
    
if __name__=='__main__':
    main()


### FIXED CODE ###

#三井住友2019 D 貪欲法
def main():
    import sys
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    ans = 0
    for i in range(1000):
        num = str(i).zfill(3)
        L = []
        k = 0
        for j in range(N):
            #print(num, S[j])
            if int(S[j])==int(num[k]):
                #print('Yes', num)
                L.append(S[j])
                k+=1
            if len(L)==3:
                #print(L)
                ans +=1
                break
                
    print(ans)
        
    
if __name__=='__main__':
    main()