Harryxun/stf_run huggingface dataset:
N,A,B = [map(int,input().split())]
print(sum(i for i in range(n+1) if A <= sum(map(int,str(i))) <= B))

### FIXED CODE ###

N,A,B =map(int,input().split())
print(sum(i for i in range(N+1) if A <= sum(map(int,str(i))) <= B))
import sys

def main():
    input = sys.stdin.readline

    _, _, m = input().split()
    m = int(m)
    alist = input().split()
    blist = input().split()

    waribiki = [input().split() for _ in range(m)]
    
    res = [200000] * 200000
    count = 0
    for a in alist:
      for b in blist:
        res[count] = int(a) + int(b)
        count += 1

    for i in range(m):
        res[count] = int(alist[int(waribiki[i][0])-1]) + int(blist[int(waribiki[i][1])-1]) - int(waribiki[i][2])
        count += 1
      
    print(min(res))


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline

    a, b, m = input().split()
    a, b, m = int(a), int(b), int(m)
    alist = list(map(int, input().split()))
    blist = list(map(int, input().split()))

    waribiki = [input().split() for _ in range(m)]
    
    res = [200000] * (m + 1)
    count = 0

    for i in range(m):
        res[count] = alist[int(waribiki[i][0])-1] + blist[int(waribiki[i][1])-1] - int(waribiki[i][2])
        count += 1

    res[count] = min(alist) + min(blist)
      
    print(min(res))


if __name__ == '__main__':
    main()
N,W = map(int,input().split())
dp = [0]*(W+1)
for i in range(N):
    w,v = map(int,input().split())
    for i in range(W,w-1,-1):
        dp[i] = max(dp[i],dp[i-w]+v)
print(dp[-1])

### FIXED CODE ###

import bisect
N,W = map(int,input().split())
dp = [0]*(10**3+1)+[10**12]*(10**5)
for i in range(N):
    w,v = map(int,input().split())
    for j in range(len(dp)-1,1000,-1):
        dp[j] = min(dp[j],dp[j-v]+w)
print(bisect.bisect_right(dp,W)-1001)
import itertools


def main():
    n, m, q = map(int, input().split())

    A, B, C, D = [], [], [], []
    for _ in range(q):
        a, b, c, d = map(int, input().split())
        A.append(a)
        B.append(b)
        C.append(c)
        D.append(d)
    ans = 0
    for item in itertools.combinations(range(19), 9):
        ptn = []
        num = 1
        p = 0
        for i in range(19):
            if i == item[p]:
                num += 1
                p += 1
                p = min(8, p)
                continue
            ptn.append(num)
        tmp = 0
        for k in range(q):
            if (ptn[B[k]] - ptn[A[k]]) == C[k]:
                tmp += D[k]

        ans = max(tmp, ans)
    return ans

print(main())


### FIXED CODE ###

import itertools


def main():
    n, m, q = map(int, input().split())

    A, B, C, D = [], [], [], []
    for _ in range(q):
        a, b, c, d = map(int, input().split())
        A.append(a)
        B.append(b)
        C.append(c)
        D.append(d)
    if m == 1:
        return sum(D)
    ans = 0
    length = m+n-1
    for item in itertools.combinations(range(length), m-1):
        ptn = []
        num = 1
        p = 0
        for i in range(length):
            if i == item[p]:
                num += 1
                p += 1
                p = min(m-2, p)
                continue
            ptn.append(num)
        tmp = 0
        for k in range(q):
            if (ptn[B[k]-1] - ptn[A[k]-1]) == C[k]:
                tmp += D[k]

        ans = max(tmp, ans)
    return ans

print(main())
X=int(input())
Y=int(X**(0.2))
for i in range(Y,-Y,-1):
    for t in (-Y//2,Y,1):
        if i**5-t**5==X:
            S=i
            Z=t
            break
        else:
            continue
print(S,Z)

### FIXED CODE ###

S=input()
print('ABC' if S=='ARC' else 'ARC')
import sys
def soin(n):
    I=n
    s=0
    R=int(I)
    L=[]
    while s==0:
        for i in range(2,R+1):
            if I%i==0:
                I=I/i
                if I==1:
                    s=1
                L.append(i)
                break
    if len(L)==1:
        print(R)
    else:
        print(L)

n,p= map(int,input().split())
if n==1:
    print(p)
    sys.exit()
l=soin(p)
if len(l)<n:
    print(1)
    sys.exit()
print(l.min())



### FIXED CODE ###

s = input()

cnt=0
for c in s:
    if c =="2":
        cnt+=1
print(cnt)
def __is_even(num):
    return num % 2 == 0


N = int(input())
reported_num_count = {}
if __is_even(N):  # Nが偶数の場合
    # 報告が正しい場合、値は全て奇数であり、1 ~ N-1 (1つ飛ばし) が2回ずつ出現する
    for i in range(1, N, 2):
        reported_num_count[i] = 0
    for i in list(map(int, input().split())):
        if (1 <= i <= N - 1) and not __is_even(i) and reported_num_count[i] < 2:
            reported_num_count[i] += 1
        else:
            print(0)
            exit()
    print(int((2 ** (N / 2)) % (10 ** 9 + 7)))
else:  # N が奇数の場合
    # 報告が正しい場合、値は全て偶数であり、0 が 1回、 2 ~ N-1（1つ飛ばし）が2回ずつ出現する
    for i in range(0, N, 2):
        reported_num_count[i] = 0
    for i in list(map(int, input().split())):
        if (i == 0) and reported_num_count[0] < 1:
            reported_num_count[0] += 1
        elif (2 <= i <= N - 1) and __is_even(i) and reported_num_count[i] < 2:
            reported_num_count[i] += 1
        else:
            print(0)
            exit()
    print(int((2 ** ((N - 1) / 2)) % (10 ** 9 + 7)))


### FIXED CODE ###

def __is_even(num):
    return num % 2 == 0


DIVISOR = 10 ** 9 + 7
ITR_NUM = 1000

N = int(input())
reported_num_count = {}
power_num = 0
if __is_even(N):  # Nが偶数の場合
    # 報告が正しい場合、値は全て奇数であり、1 ~ N-1 (1つ飛ばし) が2回ずつ出現する
    for i in range(1, N, 2):
        reported_num_count[i] = 0
    for i in list(map(int, input().split())):
        if (1 <= i <= N - 1) and not __is_even(i) and reported_num_count[i] < 2:
            reported_num_count[i] += 1
        else:
            print(0)
            exit()
    power_num = int(N / 2)
else:  # N が奇数の場合
    # 報告が正しい場合、値は全て偶数であり、0 が 1回、 2 ~ N-1（1つ飛ばし）が2回ずつ出現する
    for i in range(0, N, 2):
        reported_num_count[i] = 0
    for i in list(map(int, input().split())):
        if (i == 0) and reported_num_count[0] < 1:
            reported_num_count[0] += 1
        elif (2 <= i <= N - 1) and __is_even(i) and reported_num_count[i] < 2:
            reported_num_count[i] += 1
        else:
            print(0)
            exit()
    power_num = int((N - 1) / 2)

result = 1
while power_num > ITR_NUM:
    result *= 2 ** ITR_NUM % DIVISOR
    result %= DIVISOR
    power_num -= ITR_NUM
result *= 2 ** power_num % DIVISOR
print(result % DIVISOR)
import time


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0] * 100010

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

    for i in range(0, Q):
        l, r = map(int, input().split())
        print(sum[r-1] - sum[l-1])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    # print(end - start)


### FIXED CODE ###

import time


def main():

    N, Q = map(int, input().split())
    S = input()

    sum = [0] * (N + 1)

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

    for i in range(Q):
        l, r = map(int, input().split())
        print(sum[r-1] - sum[l-1])


if __name__ == '__main__':
    start = time.perf_counter()

    main()

    end = time.perf_counter()
    # print(end - start)
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 = []

ApB = []

for i in range(min(X, K)):
  for j in range(min(Y, K)):
      ApB.append(A[i] + B[j])

ApB.sort(reverse = True)

for i in range(min(Z, K)):
  for j in range(min(ApB.count() + 1, K)):
    ans.append(C[i] + ApB[j])

ans.sort(reverse = True)
    
for i in range(K):
  print(ans[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(min(X, K)):
  for j in range(min(Y, K)):
    if (i + 1) * (j + 1) > K:
      break
    for k in range(min(Z, K)):
      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])
from collections import Counter

N = int(input())
A = [int(_) // 400 if int(_) < 3199 else 8 for _ in input().split()]

min_counter = Counter(A)
if 8 in min_counter.keys():
    min_counter.pop(8)
maximum = 0
max_counter = Counter(A)
if max_counter[8] >= 8:
    maximum = 8
else:
    if 8 in max_counter.keys():
        maximum = max_counter[8]
        max_counter.pop(8)
    maximum += len(max_counter)
minimum = len(min_counter)
print(f"{minimum} {maximum}")

### FIXED CODE ###

from collections import Counter

N = int(input())
A = [int(_) // 400 if int(_) <= 3199 else 8 for _ in input().split()]

min_counter = Counter(A).copy()
if 8 in min_counter.keys():
    min_counter.pop(8)
    if not min_counter:
        minimum = 1
    else:
        minimum = len(min_counter)
else:
    minimum = len(min_counter)

maximum = 0
max_counter = Counter(A).copy()

if 8 in max_counter.keys():
    maximum = max_counter[8]
    max_counter.pop(8)
    maximum += len(max_counter)
else:
    maximum += len(max_counter)

print(minimum, maximum)
n = [i for i in raw_input()]
print "Yes" if "7" in n else "No"


### FIXED CODE ###

n = [i for i in input()]
print("Yes" if "7" in n else "No")
s = str(input())
     
alphabet = "abcdefghijklmnopqrstuvwxyz"
     
for i in range(len(alphabet)):
        if not alphabet[i] in s:
                ans = alphabet[i]
                break
print(ans)

### FIXED CODE ###

s = str(input())
     
alphabet = "abcdefghijklmnopqrstuvwxyz"
     
ans ='None' 
for i in range(len(alphabet)):
        if not alphabet[i] in s:
                ans = alphabet[i]
                break
print(ans)
n = int(input())
#n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
up = True
ans = 0
for i in range(n-1):
    if a[i] <= a[i+1]:
        if up == False:
            ans -= a[i]
        up = True
    else:
        if up == True:
            ans += a[i]
        up = False

if a[-2] <= a[-1]:
    ans += a[-1]

print(ans)


### FIXED CODE ###

n = int(input())
#n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]

if n == 1:
    print(a[0])
    exit()

up = True
ans = 0
for i in range(n-1):
    if a[i] <= a[i+1]:
        if up == False:
            ans -= a[i]
        up = True
    else:
        if up == True:
            ans += a[i]
        up = False

if a[-2] <= a[-1]:
    ans += a[-1]

print(ans)
x = input()

y = x**3

print (int(y))

### FIXED CODE ###

x = input()
print(int(x) ** 3)
def lam(x):
	ans=1
	for i in range(1,x+1):
		ans*=i
        ans%=mod
	return ans
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
	print(0)
	exit()
if n+1==m:
	print(lam(n)*lam(m)%mod)
else:
	print(2*lam(n)**2%mod)


### FIXED CODE ###

def lam(x,mo):
	ans=1
	for i in range(1,x+1):
		ans*=i
		ans%=mo
	return ans
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
	print(0)
	exit()
if n+1==m:
	print(lam(n,mod)*lam(m,mod)%mod)
else:
	print(2*(lam(n,mod)**2)%mod)
def PoorOrnot(number_list):
  number_dict = {}
  for num in number_list:
    if num not in number_dict:
      number_dict[num] = 1
  if len(number_dict) == 2:
    return "Yes"
  else:
    return "No"
  
number_list = list[map(int, input().split())]
print (PooeOrNot(number_list))

### FIXED CODE ###

def PoorOrNot(number_list):
  number_dict = {}
  for num in number_list:
    if num not in number_dict:
      number_dict[num] = 1
  if len(number_dict) == 2:
    return "Yes"
  else:
    return "No"
  
number_list = list(map(int, input().split()))
print (PoorOrNot(number_list))
def next_check(cubes):
	index_list = []
	for cube_index in reversed(range(1, len(cubes))):
		if ((cube_index not in index_list) and (cubes[cube_index] == cubes[cube_index - 1])):
			index_list.append(cube_index - 1)
			index_list.append(cube_index)
	l = len(index_list)
	for i in reversed(index_list):
		cubes.pop(i)
	return (cubes, l)

def main():
	cubes = input()
	for c in cubes:
		if c not in ['0', '1']:
			exit(0)
	cube_list = []
	for cube in cubes:
		cube_list.append(cube)
	l = len(cube_list)
	k = 0
	while (l != 0):
		cubes, l = next_check(cube_list)
		k += l
	print(k)

if __name__ == "__main__":
	main()

### FIXED CODE ###

S = input()

num_0 = S.count('0')
num_1 = S.count('1')

print(min(num_0, num_1)*2)
N = int(input())
ans=0
for _ in range(N):
    xu=input().split()
    if xu[1]=="JPY":
        ans+=xu[0]
    else:
        ans+=xu[0]*380000
print(ans)


### FIXED CODE ###

N = int(input())
ans=0
for _ in range(N):
    xu=input().split()
    if xu[1]=="JPY":
        ans+=int(xu[0])
    else:
        ans+=float(xu[0])*380000
print(ans+0.000001)
import math
    h = int(input())

    l = math.floor(math.log2(h))

    print(2**l * 2 -1)

### FIXED CODE ###

import math
h = int(input())
l = math.floor(math.log(h, 2))
print(2**l * 2 -1)
O = input()
E = input()

ans = ''
for i in range(len(O) -1):
  ans += O[i] + E(i)

if len(O) - len(E) == 0:
  ans += O[-1] + E[-1]
else:
  ans += O[-1]
  
print(ans)

### FIXED CODE ###

O = input()
E = input()

ans = ''
for i in range(len(O) -1):
  ans += O[i] + E[i]

if len(O) - len(E) == 0:
  ans += O[-1] + E[-1]
else:
  ans += O[-1]
  
print(ans)
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c　= a * b
if c % 2 == 1:
  print("Odd")
elese:
  print("Even")


### FIXED CODE ###

# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = (a * b) % 2
if c == 0:
  print("Even")
else :
  print("Odd")
from collections import deque
n=int(input())
a=list(map(int,input().split()))
A=[a[0]+a[0]<a[1]-a[0]>a[1]]+a+[a[-1]+a[-1]<a[-2]-a[-1]>a[-2]]
valley=0
peak=1
dp=deque()
for i in range(1,n+1):
  if A[i-1]<A[i]>A[i+1]:
    dp.append((i-1,peak))
  elif A[i-1]>A[i]<A[i+1]:
    dp.append((i-1,valley))
l,lf=dp.popleft()
r,rf=dp.popleft()
if lf == peak:
  ans=a[0]
else:
  ans=a[0]*(r+1)
for i in range(1,n-1):
  if r == i:
    t,tf=r,rf
    r,rf=dp.popleft()
    if tf == valley:
      ans+=a[i]*(i-l+1)*(r-i+1)
    else:
      ans+=a[i]
    l,lf=t,tf
  else:
    if lf == valley:
      ans+=a[i]*(r-i+1)
    else:
      ans+=a[i]*(i-l+1)
if rf == valley:
  ans+=a[-1]*(n-l)
else:
  ans+=a[-1]
print(ans)


### FIXED CODE ###

class BinaryIndexedTree:
    # http://hos.ac/slides/20140319_bit.pdf
    def __init__(self, size):
        """
        :param int size:
        """
        self.bit = [0 for _ in range(size)]
        self.size = size

    def add(self, i, w):
        """
        i番目にwを加える
        :param int i:
        :param int w:
        :return:
        """
        x = i + 1
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

    def sum(self, i):
        """
        [0,i]の合計
        :param int i:
        :return:
        """
        res = 0
        x = i + 1
        while x > 0:
            res += self.bit[x - 1]
            x -= x & -x
        return res

    def search(self, x):
        """
        二分探索。和がx以上となる最小のインデックス(>= 1)を返す
        :param int x:
        :return :
        """
        i = 0
        s = 0
        step = 1 << self.size.bit_length()
        while step:
            if i + step <= self.size and s + self.bit[i + step - 1] < x:
                print(self.bit[i + step - 1], i, step)
                i += step
                s += self.bit[i - 1]
            step >>= 1
        return i

    def __len__(self):
        return self.size
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
d=defaultdict(int)
for i in range(n):
  d[a[i]]=i+1
Bit = BinaryIndexedTree(n+1)
ans=0
for i in range(n):
  j=i+1
  i=d[j]
  x=Bit.sum(i)
  ok=i
  ng=-1
  while ok - ng > 1:
    mid=(ok+ng)//2
    if Bit.sum(mid)==x:
      ok=mid
    else:
      ng=mid
  l=ok+1
  ok=i
  ng=n+1
  while ng - ok > 1:
    mid=(ok+ng)//2
    if Bit.sum(mid)==x:
      ok=mid
    else:
      ng=mid
  r=ok
  ans+=j*(i-l+1)*(r-i+1)
  Bit.add(i,1)
print(ans)
N = int(input())
A = map(int, input().split())
under = 0
for i in range(N):
    under += 1 / A[i]
print(1 / under)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
under = 0
for i in range(N):
    under += 1 / A[i]
print(1 / under)
import math
A,B=input().rstrip()
print(A*B//math.gcd(A,B))

### FIXED CODE ###

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def lcm(a,b):
  return a*b//gcd(a,b)

num=list(map(int,input().split()))
A=num[0]
B=num[1]
S=lcm(A,B)
print(S)
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10*6)

def search(values,hp,vp,item):
	if not (0<=hp<len(values)): return
	if not (0<=vp<len(values[hp])): return
	if item!=values[hp][vp]: return
	values[hp][vp]=True
#	for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]:
#		search(values,hp+dh,vp+dv,item)
	search(values,hp-1,vp,item)
	search(values,hp+1,vp,item)
	search(values,hp,vp-1,item)
	search(values,hp,vp+1,item)

def solve(values):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(values)):
		for j in range(len(values[i])):
			if values[i][j] in valid_items:
				search(values,i,j,values[i][j])
				count+=1
	return count

def main():
	line,values=input().strip(),list()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		value = list()
		for _ in range(H):
			value.append(list(x for x in input().strip()))
		print(solve(value))
#		values.append(value)
		line = input().strip()
#	for value in values:
#		print(solve(value))

if __name__=='__main__':
	main()

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

def search(field,hp,vp,item):
	if not (0<=hp<len(field)): return
	if not (0<=vp<len(field[hp])): return
	if item!=field[hp][vp]: return
	field[hp][vp]=True
	for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]:
		search(field,hp+dh,vp+dv,item)
#	search(field,hp-1,vp,item)
#	search(field,hp+1,vp,item)
#	search(field,hp,vp-1,item)
#	search(field,hp,vp+1,item)

def solve(field):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(field)):
		for j in range(len(field[i])):
			if field[i][j] in valid_items:
				search(field,i,j,field[i][j])
				count+=1
	return count

def main():
	line = input().strip()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		field = list()
		for _ in range(H):
			field.append(list(input().strip()))
		print(solve(field))
		line = input().strip()

if __name__=='__main__':
	main()
import sys

n = int(input())
a = input().split()

money = 1000
stock = 0
pivot = []

for i in range(n-1):
    pivot.append(int(a[i+1]) - int(a[i]))

pivot.append(-1)

i=0

for j in range(n):
    if(pivot[j]>0):
        i = j
        break
    else:
        print("money=",money)
        sys.exit()

stock = int(money//int(a[i]))
money = int(money%int(a[i]))

i+=1

while(i<n):
    if(i==n-1):
        if(pivot[i-1]>0):
            money = money + stock*int(a[i])
            stock = 0
        sys.exit()

    if(pivot[i]<0):
        while(pivot[i+1]<=0):
            i+=1
        stock = int(money//int(a[i]))
        money = int(money%int(a[i]))
        i+=1
    else:
        while(pivot[i+1]>=0):
            i+=1
        money = money + stock*int(a[i+1])
        stock = 0
        i+=1

print(money)


### FIXED CODE ###

n = int(input())
a = input().split()

money = 1000
stock = 0
pivot = []
upflag = 0
dnflag = 1

if(int(a[1]) - int(a[0]) > 0): # initial
    stock = int(money // (int(a[0])))
    money = int(money % (int(a[0])))
    upflag = 1
    dnflag = 0

for i in range(n-2): # i=0,1,,,,n-3 (for n=7, n-3=4)
    if(int(a[i+1]) == int(a[i])):
        if((int(a[i+2]) - int(a[i+1]) < 0) and upflag == 1): # i+1 is local max so that to sell stock
            money = money + stock * (int(a[i+1]))
            stock = 0
            upflag = 1
            dnflag = 0
        elif((int(a[i+2]) - int(a[i+1]) > 0) and dnflag == 1): # i+1 is local min so that to sell stock
            stock = int(money // (int(a[i+1])))
            money = int(money % (int(a[i+1])))
            upflag = 0
            dnflag = 1

    elif(int(a[i+1]) - int(a[i]) > 0):
        upflag = 1
        if(int(a[i+2]) - int(a[i+1]) < 0): # i+1 is local max so that to sell stock
            money = money + stock * (int(a[i+1]))
            stock = 0
            upflag = 0

    elif(int(a[i+1]) - int(a[i]) < 0):
        dnflag = 1
        if(int(a[i+2]) - int(a[i+1]) > 0): # i+1 is local min so that to buy stock
            stock = int(money // (int(a[i+1])))
            money = int(money % (int(a[i+1])))
            dnflag = 0

if(int(a[n-1]) - int(a[n-2]) > 0): # sell @ final
    money = money + stock * (int(a[n-1]))
elif(int(a[n-1]) - int(a[n-2]) == 0):
    if(upflag == 1):
        money = money + stock * (int(a[n-1]))

print(money)
N = int(input())
s = list(map(int, input().split()))

m = s[0]
M = s[N-1]

lis = []
sum = 0

for i in range(m,M):
  for j in range(N):
  	sum += (s[j] - i) ** 2
  lis.append(sum)
  sum = 0
  
print(min(lis))

### FIXED CODE ###

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

m = s[0]
M = s[N-1]

lis = []
ans = 0

for i in range(1000):
  for j in range(N):
  	ans += (s[j] - i) ** 2
  lis.append(ans)
  ans = 0
  
print(min(lis))
A,B = list(map(int,input().split()))

tasu = A+B
hiku = A-B
kakeru = A *B

ans =0

if tasu >= hiku and tasu >= kakeru:
  ans = tasu
elif hiku >= tasu and hiku >= kakeru:
  ans = hiku
elif kakru >= tasu and kakeru >= hiku:
  ans = kakeru

print(ans)

### FIXED CODE ###

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

tasu = A+B
hiku = A-B
kakeru = A *B

ans =0

if tasu >= hiku and tasu >= kakeru:
  ans = tasu
elif hiku >= tasu and hiku >= kakeru:
  ans = hiku
elif kakeru >= tasu and kakeru >= hiku:
  ans = kakeru

print(ans)
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9 for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    for j in range(1,k+1):
        if((i-j)>=0):
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
            print(dp)
print(dp[n-1])

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9 for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    for j in range(1,k+1):
        if((i-j)>=0):
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
            
print(dp[n-1])
N = int(input())
A = list(map(int, input().split()))

ans = N
j = 1
s = A[0] + A[1] if N > 0 else A[0]
x = A[0] | A[1] if N > 0 else A[0]
for i, a in enumerate(A):
    x = a
    s = a
    if j == i:
        j += 1
    if j == N:
        break
    for k in range(j-i):
        x = x | A[1 + i + k]
        s += A[1 + i + k]
    while True:
        print(i,j,ans, x, s)
        if j == N:
            break
        if s == x:
            ans += j-i
            j += 1
            if j == N:
                break
            s += A[j]
            x = x | A[j]
        else:
            break

print(ans)


### FIXED CODE ###

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

ans = N
if N == 1:
    print(1)
    sys.exit()
j = 1
s = A[0] + A[1]
x = A[0] ^ A[1]
for i, a in enumerate(A):
    if j == i:
        j += 1
        if j == N:
            break
        x = x ^ A[j]
        s += A[j]

    while True:
        if j == N:
            break
        if s == x:
            ans += j-i
            j += 1
            if j == N:
                break
            s += A[j]
            x = x ^ A[j]
        else:
            s -= a
            x = x ^ a
            break
    if j == N:
        break

print(ans)
u = input()

a = u[0];
b = u[2];
at = int(a)
bt = int(b)

x = at*b
y = bt*a

if(x < y)
{
  print(x)
}
else
{
 print(y)
}

### FIXED CODE ###

u = input()

a = u[0];
b = u[2];
at = int(a)
bt = int(b)

x = b*at
y = a*bt

if x <= y:
  print(x)

else:
 print(y)
N = map(int,input().split())
W = list(map(int,　input().split()))
 
min_list = []
for i in range(N):
    mi = abs(sum(W[0:i]) - sum(W[i:]))
    min_list.append(mi)
print(min(min_list))

### FIXED CODE ###

n = int(input())
w = list(map(int, input().split()))
 
min_diff = 1000
for i in range(n):
	diff = abs(sum(w[0:i]) - sum(w[i:]))
	if diff < min_diff:
		min_diff = diff
print(min_diff)