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

import numpy as np

N, Ma, Mb = map(int, input().split())

items = []
for i in range(N):
  items.append(list(map(int, input().split())))

items = np.array(items)

import itertools
l = list(itertools.product([False,True], repeat=N))

min_cost = 1000000000000000000
for comb in l[1:]:
  idx = np.where(comb)
  cost = items[idx,2].sum()
  if ((items[idx,0].sum() // Ma) == (items[idx,1].sum() // Mb)) & (items[idx,0].sum()%Ma==0) & (items[idx,1].sum()%Mb==0) & (cost < min_cost):
    min_cost = cost
if min_cost == 1000000000000000000:
  print("-1")
else:
  print(min_cost)

### FIXED CODE ###

N, Ma, Mb = map(int, input().split())

items = []
mas = []
mbs = []
costs = []
for i in range(N):
  ma, mb, c = map(int, input().split())
  mas.append(ma)
  mbs.append(mb)
  costs.append(c)

max_cost = 5000
dp = [[[max_cost for k in range((N+1)*10)] for j in range((N+1)*10)] for i in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
  for j in range(N*10):
    for k in range(N*10):
      if dp[i][j][k] == max_cost:
        continue
      if dp[i+1][j][k] > dp[i][j][k]:
        dp[i+1][j][k] = dp[i][j][k]
      if dp[i+1][j+mas[i]][k+mbs[i]] > dp[i][j][k] + costs[i]:
        dp[i+1][j+mas[i]][k+mbs[i]] = dp[i][j][k] + costs[i]
        
min_cost = max_cost
for wa in range(1, N*10):
  for wb in range(1, N*10):
    if (wa * Mb != wb * Ma):
      continue;
    if min_cost > dp[N][wa][wb]:
      min_cost = dp[N][wa][wb]

  
if min_cost == max_cost:
  print("-1")
else:
  print(min_cost)
### BUGGY CODE ###

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
maxA = max(A)
minA = min(A)
ans = -1
for i in range(minA,maxA+1):
    ans = max(ans, A.count(i-1) + A.count(i) + A.count(i+1))
print(ans)


### FIXED CODE ###

#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""
# 最大公約数 と 最小公倍数
"""def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
def lcm(a,b):
  g = gcd(a,b)
  return (a * b) // g"""

def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7

def main():
  n = int(input())
  LIST = readInts()
  MAX_ = [0] * (10**5 + 10) # 始めに確保しておく
  for a in LIST:
    for i in range(3):
      MAX_[a+i]+=1 # -1,0,1のように、0,1,2で被るものを考える。
  print(max(MAX_))
if __name__ == '__main__':
  main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W = map(int, input().split())
MEIJI = [input() for _ in range(H)]


def dfs(r, c, cnt, iswhite=True):
    #if r == H - 1 and c == W - 1:
        #return cnt

    now = '.' if iswhite == True else '#'

    ans = 200

    if MEIJI[r][c] != now:
        if iswhite == True:
            cnt += 1

        iswhite = not (iswhite)
        
    if r == H-1 and c == W - 1:
        return cnt
    if r < H-1:
        ans = min(dfs(r + 1, c, cnt, iswhite), ans)
    if c < W-1:
        ans = min(dfs(r, c + 1, cnt, iswhite), ans)

    return ans


ans = dfs(0, 0, 0, True)
print(ans)


### FIXED CODE ###

import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W = map(int, input().split())
MEIJI = [input() for _ in range(H)]


@lru_cache(maxsize=None)
def dfs(r, c, cnt, iswhite=True):
    # if r == H - 1 and c == W - 1:
        # return cnt

    now = '.' if iswhite == True else '#'

    ans = 200

    if MEIJI[r][c] != now:
        if iswhite == True:
            cnt += 1

        iswhite = not (iswhite)

    if r == H-1 and c == W - 1:
        return cnt
    if r < H-1:
        ans = min(dfs(r + 1, c, cnt, iswhite), ans)
    if c < W-1:
        ans = min(dfs(r, c + 1, cnt, iswhite), ans)

    return ans


ans = dfs(0, 0, 0, True)
print(ans)
### BUGGY CODE ###

import sys
from collections import Counter
from functools import reduce

input = sys.stdin.readline

def extended_euclid(a, b):
    x1, y1, m = 1, 0, a
    x2, y2, n = 0, 1, b
    while m % n != 0:
        q, r = divmod(m, n)
        x1, y1, m, x2, y2, n = x2, y2, n, x1 - q * x2, y1 - q * y2, r
    return (x2, y2, n)

def modular_inverse(a, mod):
    x, _, g = extended_euclid(a, mod)
    if g != 1:
        return None # Modular inverse of a does not exist
    else:
        return x % mod

def prime_factorization(n):
    '''
    Trial division.
    Input: 
        n : a positive integer
    Output:
        a dictionary of #(each prime factors) of n,
    '''
    result = Counter()
    if n < 2:
        return result
    while n % 2 == 0:
        result[2] += 1
        n //= 2
    p = 3
    while p*p <= n:
        while n % p == 0:
            n //= p
            result[p] += 1
        p += 2
    if n > 1:
        result[n] += 1
    return result

MOD = 10**9 + 7

N = int(input())
*A, = map(int, input().split())
ans = 0
lcm = reduce(lambda x,y: x | y, [prime_factorization(a) for a in A])
L = 1
for x, y in lcm.items():
    L *= pow(x, y, MOD); L %= MOD
for a in A:
    ans += L * modular_inverse(a, MOD)
    ans %= MOD
print(ans)

### FIXED CODE ###

from collections import Counter

def extended_euclid(a, b):
    x1, y1, m = 1, 0, a
    x2, y2, n = 0, 1, b
    while m % n != 0:
        q, r = divmod(m, n)
        x1, y1, m, x2, y2, n = x2, y2, n, x1 - q * x2, y1 - q * y2, r
    return (x2, y2, n)

def modular_inverse(a, mod):
    x, _, g = extended_euclid(a, mod)
    if g != 1:
        return None # Modular inverse of a does not exist
    else:
        return x % mod

def prime_factorization(n):
    '''
    Trial division.
    Input: 
        n : a positive integer
    Output:
        a dictionary of #(each prime factors) of n,
    '''
    result = []
    app = result.append
    if n < 2:
        return Counter()
    while n % 2 == 0:
        app(2)
        n //= 2
    p = 3
    while p*p <= n:
        while n % p == 0:
            app(p)
            n //= p
        p += 2
    if n > 1:
        app(n)
    return Counter(result)

MOD = 10**9 + 7

N = int(input())
*A, = map(int, input().split())
ans = 0
lcm = {}
for a in A:
    for x, y in prime_factorization(a).items():
        if x not in lcm.keys():
            lcm[x] = y
        else:
            lcm[x] = max(lcm[x], y)
L = 1
for x, y in lcm.items():
    L *= pow(x, y, MOD)
    L %= MOD
for a in A:
    ans += L * modular_inverse(a, MOD)
    ans %= MOD
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
from decimal import Decimal

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

trans = lambda x : Decimal(x) * (-1)

a = list(map(trans,a))

from heapq import heappush, heappop, heapify

heapify(a)
for i in range(m):
    j = heappop(a)/2
    heappush(a,j)

print(sum(list(map(lambda x:int(x*-1),a))))

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n,m = list(map(int,input().split()))
a = list(map(lambda x : int(x) * (-1) ,input().split()))

from heapq import heappush, heappop, heapify

heapify(a)
for i in range(m):
    tmp_min = (-1)*heappop(a)//2*(-1)
    heappush(a,tmp_min)

print(sum(list(map(lambda x : int(x * (-1)),a))))
### BUGGY CODE ###

N, C = map(int, input().split())
x = []
v = []
for i in range(N):
    a, b = map(int, input().split())
    x.append(a)
    v.append(b)

R = [0] * N
L = [0] * N
for i in range(N):
    if i == 0:
        R[i] = v[i] - x[i]
        L[N-1-i] = v[N-1-i] - (C - x[N-1-i])
    else:
        R[i] = R[i - 1] + v[i] - (x[i] - x[i - 1])
        L[N-1-i] = L[N-i] + v[N-1-i] - (x[N-i] - x[N-1-i])
R2L = 0
L2R = 0
for i in range(N-1):
    R2L = max(R2L, R[i] - x[i] + max(L[i+1:]))
    L2R = max(L2R, L[i+1] - (C - x[i+1]) + max(R[:i+1]))

print(max(0, max(R), max(L), R2L, L2R))

### FIXED CODE ###

N, C = map(int, input().split())
x = []
v = []
for i in range(N):
    a, b = map(int, input().split())
    x.append(a)
    v.append(b)

R = [0] * N
L = [0] * N
for i in range(N):
    if i == 0:
        R[i] = v[i] - x[i]
        L[N-1-i] = v[N-1-i] - (C - x[N-1-i])
    else:
        R[i] = R[i - 1] + v[i] - (x[i] - x[i - 1])
        L[N-1-i] = L[N-i] + v[N-1-i] - (x[N-i] - x[N-1-i])

Rmax = [0] * N
Lmax = [0] * N
for i in range(N):
    if i == 0:
        Rmax[i] = R[i]
        Lmax[N-1-i] = L[N-1-i]
    else:
        Rmax[i] = max(Rmax[i-1], R[i])
        Lmax[N-1-i] = max(Lmax[N-i], L[N-1-i])

R2L = 0
L2R = 0
for i in range(N-1):
    R2L = max(R2L, R[i] - x[i] + Lmax[i+1])
    L2R = max(L2R, L[i+1] - (C - x[i+1]) + Rmax[i])

print(max(0, max(R), max(L), R2L, L2R))
### BUGGY CODE ###

import re

i = int(input().split()[1])
s = input()
k = 0
result = []

while k < i:
    ft, et = map(int, input().split())
    result.append(len(re.findall("AC", s[ft - 1:et])))
    k += 1

for kekka in result:
    print(kekka)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])
### BUGGY CODE ###

a=int(input())
res=1
l=list(map(int, input().split()))
for i in l:
    res*=i
if res>1000000000000000000:
    res=-1
print(res)
        


### FIXED CODE ###

a=int(input())
res=1
flag=1
l=list(map(int, input().split()))
for i in l:
    if i==0:
        flag=0
if flag!=0:
    for i in l:
        res*=i
        if res>1000000000000000000:
            res=-1
            break
    if res>1000000000000000000:
        res=-1
else:
    res=0
print(res)
### BUGGY CODE ###

def D_160():
    import itertools
    import collections
    N, X, Y = map(int, input().split())
    count_list = [[0]*N for i in range(N)]
    for i in range(0,N):
        for j in range(i,N):
            count_list[i][j] = min(j-i,abs(X-1-i) + abs(j-(Y-1)) + 1)
    
   # print(count_list)
    count_list = sum(count_list,[])
    
    for i in range(1,N):
        print(count_list.count(i))

D_160()

### FIXED CODE ###


def D_160():
    N, X, Y = map(int, input().split())
    #count_list = [[0]*N for i in range(N)]
    ans = [0 for i in range(N-1)]
    for i in range(0,N):
        for j in range(1+i,N):
            ans_i = min(j-i,abs((X-1)-i) + abs(j-(Y-1)) + 1)
            ans[ans_i-1] += 1
    
    
    for i in ans:
        print(i)

D_160()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
N, Q = map(int, input().split())
S = input()
question_list = []

for i in range(Q):
    l, r = map(int, input().split())
    question_list.append((l, r))

cut_s = S
index_list = []
for i in range(1, N):
    if S[i] == 'C' and S[i - 1] == 'A':
        index_list.append(i - 1)

for lr in question_list:
    l = lr[0]
    r = lr[1]
    num = 0
    for i in range(l - 1, r - 1):
        if i in index_list:
            num += 1
    print(num)

### FIXED CODE ###

# -*- coding: utf-8 -*-
N, Q = map(int, input().split())
S = input()
question_list = []

for i in range(Q):
    l, r = map(int, input().split())
    question_list.append((l, r))

total_list = [0] * N
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        total_list[i + 1] = total_list[i] + 1
    else:
        total_list[i + 1] = total_list[i]

for lr in question_list:
    l = lr[0]
    r = lr[1]
    num = total_list[r - 1] - total_list[l - 1]
    print(num)
### BUGGY CODE ###

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

for i in range(n):
  j = i + 1
  b = a.count(j)
  print(b)

### FIXED CODE ###

import numpy as np

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

b = np.zeros(shape=(n), dtype=np.int)

for i in a:
  b[i-1] += 1

for i in range(n):
  print(b[i])
### BUGGY CODE ###

x,y,z,K=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

oisisa=[]
for i in range(x):
    for j in range(y):
        for k in range(z):
            val=a[i]+b[j]+c[k]
            oisisa.append(val)
oisisa.sort(reverse=True)
for i in range(K):
    print(oisisa[i])


### FIXED CODE ###

x,y,z,K=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ans=[]
for i in range(x):
    for j in range(y):
        if (i+1)*(j+1)>K:
            break
        for k in range(z):
            if (i+1)*(j+1)*(k+1)>K:
                break
            ans.append(a[i]+b[j]+c[k])
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])
### BUGGY CODE ###

n = int(input())
a = [int(_) for _ in input().split()]
M = max(a)
p = len(format(M, 'b'))
l = [[0 for _ in range(n)] for _ in range(p)]
ans = 0
for i in range(n):
    a_s = format(a[i], '0' + str(p) + 'b')
    for c in range(p):
        l[c][i] = int(a_s[c])
for i in range(p):
    zero = 0
    one = 0
    for j in range(n):
        if l[i][j] == 0:
            zero += 1
        else:
            one += 1
    ans += (2**(p - i - 1)) * zero * one
    ans %= (10**9 + 7)
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = [int(_) for _ in input().split()]
    M = max(a)
    p = len(format(M, 'b'))
    l = [0 for _ in range(p)]
    ans = 0
    for i in range(n):
        a_s = format(a[i], '0' + str(p) + 'b')
        for c in range(p):
            if a_s[c] == '1':
                l[c] += 1
    for i in range(p):
        c1 = l[i]
        ans += (2**(p - i - 1)) * c1 * (n - c1)
        ans %= (10**9 + 7)
    print(ans)

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


d=[0]*13
d[0]=1
mul=1
for c in reversed(input()):
    e=[0]*13
    """
    if c=="?":
        for i in range(10):
            for j in range(13):
                e[(i*mul+j)%13]+=d[j]
                e[(i*mul+j)%13]%=(10**9+7)
    else:
        for j in range(13):
            e[(int(c)*mul+j)%13]+=d[j]
            e[(int(c)*mul+j)%13]%=(10**9+7)
    """
    for i in (range(10) if c=="?" else[int(c)]):
        for j in range(13):
            e[(i*mul+j)%13]+=d[j]
            
    d=[e%(10**9+7)for e in e]
    mul*=10
print(d[5])



### FIXED CODE ###

# coding: utf-8
# Your code here!
 
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意
 
s = input()
l = len(s)
MOD = 10**9+7
 
dp = [0]*13
dp[0] = 1
for i in s:
    new = [0]*13
    if i == "?":
        for i in range(10):
            for j in range(13):
                new[(10*j+i)%13] += dp[j]
    else:
        i = int(i)
        for j in range(13):
            new[(i+10*j)%13] += dp[j]
    
    for i in range(13):
        new[i] %= MOD
    dp,new = new,dp
#    print(dp)
 
print(dp[5]%MOD)
### BUGGY CODE ###

import itertools
l,r = map(int,input().split())

sc = list(itertools.combinations(range(l,r+1),2))

print(min([s[0]*s[1]%2019 for s in sc]))


### FIXED CODE ###

l,r = map(int,input().split())

a = []
r = min(r,l+2019)
for i in range(l,r):
    for j in range(i+1,r+1):
        a.append(i*j%2019)

print(min(a))
### BUGGY CODE ###

N=int(input())
list1=list(map(int,input().split()))
list2=[]
def calc(n):
    tempsum=0
    for j in range(1,n+1):
        tempsum+=((-1)**(n-j))*list1[j-1]
    return tempsum
list2.append(calc(N))
for i in range(1,N):
    list2.append(2*calc(i)+((-1)**i)*list2[0])
str1=""
for i in range(len(list2)):
    str1+=str(list2[i])
    if i==len(list2)-1:
        print(str1)
    else:
        str1+=" "

### FIXED CODE ###

N=int(input())
list1=list(map(int,input().split()))
list2=[]
def calc(n):
    tempsum=0
    for j in range(1,n+1):
        tempsum+=((-1)**(n-j))*list1[j-1]
    return tempsum
list2.append(calc(N))
for i in range(1,N):
    list2.append(2*list1[i-1]-list2[i-1])
str1=""
for i in range(len(list2)):
    str1+=str(list2[i])
    if i==len(list2)-1:
        print(str1)
    else:
        str1+=" "
### BUGGY CODE ###

import itertools

x,y,z,K = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

r = [i+j for i,j in list(itertools.product(a, b))]
r.sort(reverse=True)

r = [i+j for i,j in list(itertools.product(r[0:K], c))]
r.sort(reverse=True)

for i in range(K):
    print(r[i])


### FIXED CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
### BUGGY CODE ###

import io,sys
sys.setrecursionlimit(10**6)

def main():
    import bisect
    n = int(input())
    A = list(map(int,sys.stdin.readline().rstrip().split()))
    A.sort()

    ans = 0
    note = [True]*n
    for i in range(n):
        if note[i]:
            a = A[i]
            if i != n-1 and a==A[i+1]:
                ans-=1
            ans +=1
            for j in range(i,n):
                if A[j]%a==0:
                    note[j]=False
       
    
    print(ans)
main()

### FIXED CODE ###

import io,sys
sys.setrecursionlimit(10**6)

def main():
    import bisect
    n = int(input())
    A = list(map(int,sys.stdin.readline().rstrip().split()))
    A.sort()

    ans = 0
    a_max = A[-1]
    note = [True]*(a_max+1)
    for j in range(n):
        a = A[j]
        if note[a]:
            if j != n-1 and A[j]==A[j+1]:
                ans-=1
            ans+=1
            # for i in range(a,a_max+1):
            #     if i%a==0:
            #         note[i] = False
            temp = a 
            while temp <= a_max:
                note[temp]=False
                temp+=a

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

# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    l, r = MI()
    mod = 2019

    r = min(r, l+4038)
    ans = 2018
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            x = i * j % mod
            ans = min(ans, x)
    print(ans)

if __name__ == '__main__':
    solve()


### FIXED CODE ###

l, r = map(int, input().split())
mod = 2019
 
r = min(r, l+4038)
ans = 2018
for i in range(l, r+1):
    for j in range(i+1, r+1):
        x = i * j % mod
        ans = min(ans, x)
print(ans)
### BUGGY CODE ###

from collections import defaultdict


s = input()
n = len(s)

dd = defaultdict(int)

d = [0 for i in range(2019)]
d[0] = 1
tmp = 0
_10 = 1
# print(s, n)
for i in range(n - 1, -1, -1):
    # print(i, s[i])
    # print(int(s[i]), _10)
    tmp += (int(s[i]) * _10) % 2019
    _10 *= 10
    # print(tmp, tmp % 2019)
    d[tmp % 2019] += 1


# count = 0
# for i in range(len(d)):
#     if d[i] >= 2:
#         count += (d[i])*(d[i]-1)//2
# print(count)

# # print(dd)
print(sum(v*(v-1)//2 for v in d))


### FIXED CODE ###

import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

#print(b)
for i in reversed(range(0, n)):
 #   print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
  #  print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)
### BUGGY CODE ###

n = int(input())
S = [int(a) for a in input().split()]
divisor = 10**9 + 7
tot = 0
for i in range(n-1):
  for j in range(i+1,n):
    tot += (S[i]*S[j] % divisor)
    if tot >= divisor:
      tot = tot % divisor
    
print(tot)

### FIXED CODE ###

def multmod(a,b,m):
  ans = 0
  a = a % m
  
  while b:
    if (b & 1): # odd
      ans = (ans + a) % m
    
    a = (2 * a) % m
    b >>= 1 # b = b / 2
    
  return ans

n = int(input())
S = [int(a) for a in input().split()]
divisor = 10**9 + 7
tot = 0
a,b = 0,0
arr_sum = sum(S) #% divisor
arr_ssq = arr_sum*arr_sum #% divisor
isq_sum = 0
for i in range(n):
  isq_sum += S[i]*S[i] #% divisor
  
#isq_sum = isq_sum % divisor
tot = (arr_ssq - isq_sum)//2 % divisor

print(tot)
### BUGGY CODE ###

# -*= coding: utf-8 -*-
import queue

N, X, Y = map(int, input().split())

q = queue.Queue()

ans = [0] * N

# BFS
for i in range(N):
  # 0 〜 N-1の各頂点からスタート
  
  cost = [-1] * N
  cost[i] = 0
  q.put(i) # 基準とする頂点をノードiにする
  
  while not q.empty():
    
    # 現在のノードのインデックス
    current = q.get()
    
    if current - 1 >= 0 and cost[current - 1] == -1:
      # 1つ前のノードを登録
      
      q.put(current - 1)
      cost[current - 1] = cost[current] + 1
      
    if current + 1 < N and cost[current + 1] == -1:
      # 1つ後ろのノードを登録
      
      q.put(current + 1)
      cost[current + 1] = cost[current] + 1
      
    if current == X - 1 and cost[Y - 1] == -1:
      # XからYへのルートを登録
      
      q.put(Y - 1)
      cost[Y - 1] = cost[current] + 1
    
    if current == Y - 1 and cost[X - 1] == -1:
      # YからXへのルートを登録
      
      q.put(X - 1)
      cost[X - 1] = cost[current] + 1
      
  # この時点でcostにはノードiから各ノードへの最小コストが格納されている
  
  #print(cost)
  for j in range(N):
    ans[cost[j]] += 1

for i in range(1, N):
  print(ans[i]//2) # ノードA→Bと、逆向きのB→Aが、両方カウントされているので2分の1する

### FIXED CODE ###

# -*= coding: utf-8 -*-
from collections import deque

N, X, Y = map(int, input().split())

d = deque() # 初期化

ans = [0] * N

# BFS
for i in range(N):
  # 0 〜 N-1の各頂点からスタート
  
  cost = [-1] * N
  cost[i] = 0
  d.append(i) # 基準とする頂点をノードiにする
  
  while len(d) > 0:
    # dequeueが空でない間ループ
    
    # 現在のノードのインデックス
    current = d.popleft()
    
    if current - 1 >= 0 and cost[current - 1] == -1:
      # 1つ前のノードを登録
      
      d.append(current - 1)
      cost[current - 1] = cost[current] + 1
      
    if current + 1 < N and cost[current + 1] == -1:
      # 1つ後ろのノードを登録
      
      d.append(current + 1)
      cost[current + 1] = cost[current] + 1
      
    if current == X - 1 and cost[Y - 1] == -1:
      # XからYへのルートを登録
      
      d.append(Y - 1)
      cost[Y - 1] = cost[current] + 1
    
    if current == Y - 1 and cost[X - 1] == -1:
      # YからXへのルートを登録
      
      d.append(X - 1)
      cost[X - 1] = cost[current] + 1
      
  # この時点でcostにはノードiから各ノードへの最小コストが格納されている
  
  #print(cost)
  for j in range(N):
    ans[cost[j]] += 1

for i in range(1, N):
  print(ans[i]//2) # ノードA→Bと、逆向きのB→Aが、両方カウントされているので2分の1する