Harryxun/stf_run huggingface dataset:
line = input()

N = int(line)
A = np.array([0]*N)

for i in range(N):
    line = input()
    A[i] = int(line)

    
def IsNotPossible(A):
    foo = 0
    
    if A[0] != 0:
        foo = 1
        return foo
        
    else:
        for i in range(N-1):
            if A[i] + 1 < A[i+1]:
                foo  = 1
                break
        return foo

if IsNotPossible(A):
    print(-1)
    
else:
    count = 0
    for i in range(N-1):
        a = A[N-1-i]
        
        if a == 0:
            continue
        elif a == A[N-2-i] + 1:
            count += 1
        else:
            count += a
            
    print(count)

### FIXED CODE ###

line = input().split()

A = int( line[0] )
B = int( line[1] )
C = int( line[2] )
K = int( line[3] )

if K % 2 == 0:
    print(A-B)
    
else:
    print(B-A)
a,b,c,d,e,k = [int(input()) for x in range()]
if e-a <= k:
    print("Yay!")
else:
    print(":(")

### FIXED CODE ###

a,b,c,d,e,k = [int(input()) for x in range(6)]
if e-a <= k:
    print("Yay!")
else:
    print(":(")
s = input()
sr = s[-1::-1]
left = 0
right = 0
ans = 0
while (1):
    if left + right == len(s) - 1:
        break
    if s[left] != sr[right]:
        if s[left] == 'x':
            left += 1
        elif sr[right] == 'x':
            right += 1
        else:
            print(-1)
            exit()
        ans += 1
    elif s[left] == sr[right]:
        left += 1
        right += 1

print(ans)


### FIXED CODE ###

s = input()
sr = s[-1::-1]
left = 0
right = 0
ans = 0
while (1):
    if left + right >= len(s) - 1:
        break
    if s[left] != sr[right]:
        if s[left] == 'x':
            left += 1
        elif sr[right] == 'x':
            right += 1
        else:
            print(-1)
            exit()
        ans += 1
    elif s[left] == sr[right]:
        left += 1
        right += 1

print(ans)
N = int(input())
S,T=input().split()
lists=[]
for i in range(N):
    lists+=S[i]
    lists+=T[i]
print(*lists.split())

### FIXED CODE ###

N = int(input())
S,T=input().split()
lists=[]
for i in range(N):
    lists+=S[i]
    lists+=T[i]
print(*lists,sep="")
a,b=map(float,input().split())
b=int(float(b)*100)
a=int(a)
print(int(a*tempb)//100)


### FIXED CODE ###

a,b=map(str,input().split())
tempb=int(float(b)*1000)
tempa=int(a)
print(int(tempa*tempb)//1000)
N = input()
print(N**3)

### FIXED CODE ###

N = int(input())
print(N**3)
a = int(input())
if 9 in a:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a = input()
if "9" in a:
  print("Yes")
else:
  print("No")
D, T, S = map(int, input().split())

if not __debug__:
	print("Yes" if D < T * S else "No")
else:
    1/0

### FIXED CODE ###

D, T, S = map(int, input().split())
print("Yes" if T * S >= D else "No")
s = input()
t = input()
r = t.len()
if s in t[0,r]:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
t = input()
if s == t[:-1]:
    print('Yes')
else:
    print('No')
n=int(input())
a=[int(input())for _ in[0]*n]
s=[int(pow(4, i) + 3*pow(2, i-1) + 1) for i in range(13)[::-1]] + [1]
s=[v for v in s if v <= n]
c=0
for g in s:
 for i in range(n):
  v=a[i]
  j=i-g
  while j>=0 and a[j]>v:a[j+g]=a[j];j-=g;c+=1
  a[j+g]=v
print(len(s))
print(*s)
print(c)
print(*a,sep='\n')


### FIXED CODE ###

import sys
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
def solve():
    n = int(input())
    A = list(map(int, sys.stdin))
    G = [int((2.25**i - 1) / 1.25)for i in range(17, 0, -1)]
    G = [v for v in G if v <= n]
    for g in G:
        insertionSort(A, n, g)
    print(len(G))
    print(*G)
    print(cnt)
    print('\n'.join(map(str, A)))
if __name__ == '__main__':
    cnt = 0
    solve()
n = int(input())
a = map(int,input().split())
b = map(int,input().split())
c = map(int,input().split())

s = 0

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

print(s)
    

### FIXED CODE ###

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

s = 0
a.append(0)

for i in range(n):
  s += b[i]
  if a[i]+1 == a[i+1]:
    s += c[a[i]-1]

print(s)
def gcm(a,b):
    if a < b:
        a,b = b,a
    while True:
        if a % b == 0:
            return b
        else:
            a,b = b,a % b

def lcm(a,b):
    g = gcm(a,b)
    return a*b//g;

N = int(input())
Data = []
for _ in range(N):
    Data.append(int(input()))
ans = Data[0]
for i in range(1,N):
    ans = lcm(ans,Data[i])
print(ans)
def gcm(a,b):
    if a < b:
        a,b = b,a
    while True:
        if a % b == 0:
            return b
        else:
            a,b = b,a % b

def lcm(a,b):
    g = gcm(a,b)
    return a*b//g;

N = int(input())
Data = []
for _ in range(N):
    Data.append(int(input()))
ans = Data[0]
for i in range(1,N):
    ans = lcm(ans,Data[i])
print(ans)


### FIXED CODE ###

def gcm(a,b):
    if a < b:
        a,b = b,a
    while True:
        if a % b == 0:
            return b
        else:
            a,b = b,a % b

def lcm(a,b):
    g = gcm(a,b)
    return a*b//g;

N = int(input())
Data = []
for _ in range(N):
    Data.append(int(input()))
ans = Data[0]
for i in range(1,N):
    ans = lcm(ans,Data[i])
print(ans)
# -*- coding: utf-8 -*-
#ABC070C
import math

def lcm(x, y):
	ans=((x * y) // math.gcd(x, y))
	return ans

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

t=[]
for i in range(0,n):
	t.append(0)
for i in range(0,n):
    t[i] = int(input())

ans = t[0]
for i in range(1,n):
	ans = lcm(ans,t[i])

print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
#ABC070C
import math

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n = int(input())

t=[]
for i in range(0,n):
	t.append(0)
for i in range(0,n):
    t[i] = int(input())

ans = t[0]
for i in range(1,n):
	j = gcd(ans,t[i])
	ans *= t[i]
	ans = ans//j

print(ans)
N,D = map(int,input().split(" "))
 
for _ in range(N):
  count=0
  p,q=map(int,input().split(" "))
  if (p**2 + q**2) <=D**2:
    count+=1
print(count)

### FIXED CODE ###

X=int(input())

if X>=30:
  print("Yes")
else:
  print("No")
"""
ある街にN人のすぬけ君(すぬけ君1、すぬけ君2、 ...、 すぬけ君N)が住んでいます。

"""
n, k = map(int, input().split())
input_map = {}
for i in range(k):
    d = int(input())
    for j in range(d):
        input_list = input().split()
        list = [ int(ai) for ai in input_input ]
    input_map.setdefault(i, list)

cnt = 0
having_list = input_map(k)
for j in having_list:
    cnt += 1

print(cnt)


### FIXED CODE ###

"""
ある街にN人のすぬけ君(すぬけ君1、すぬけ君2、 ...、 すぬけ君N)が住んでいます。

"""
n, k = map(int, input().split())
n_list = list(range(1, n+1))
input_map = {}
for i in range(k):
    d = int(input())
    d_list = [ int(ai) for ai in input().split()]
    for h in d_list:
        if n_list.count(h) == 1:
            n_list.remove(h)

print(len(n_list))
list=list(map(int,input().split()))
a=list[0]
b=list[1]
c=list[2]
k=list[3]
if k=<a+b:
  max_value=a
else:
  max_value=a-k+a+b
print(max_value)


### FIXED CODE ###

a,b,c,k=map(int,input().split())
if a<=k<=a+b:
  max_value=a
elif k<a:
	max_value=k
else:
  max_value=a*2-k+b
print(max_value)
s=list(map(int,input().split()))
i=1
while True:
	if s[i-1]==0:
		break
	else:
		print('Case '+str(i)+': '+str(s[i-1]))
		i+=1

### FIXED CODE ###

n=[]
line=''
while line != '0':
    line=input()
    if line != '0': n.append(int(line))
for x in range(len(n)): print('Case %d: %d'%(x+1, n[x]))
N = int(input())
R = int(input())
ans = 0

if N < 10:
  ans = R + 100*(10-N)
  print(ans)
else:
  ans = R
  print(R)


### FIXED CODE ###

l=[int(x) for x in input().split()]
N=l[0]
R=l[1]

if N >= 10:
  ans = R
  print(ans)
else:
  ans = R + 100*(10-N)
  print(ans)
data = input()

n = int(data[0])
m = int(data[1])

if n == m:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

data = input().split()
 
n = data[0]
m = data[1]
 
if n == m:
  print("Yes")
else:
  print("No")
import scipy.misc

N=int(input())
X=list(map(int,input().split()))
SX=sorted(X)
M=SX.pop()
MV=10**9
ANS=0
for x in SX:
  z = M - x
  if MV > z:
    MV = z
    ANS = x
print("{} {}".format(M,ANS))



### FIXED CODE ###

from heapq import heapify, heappop, heappush, heappushpop

class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap

    def __len__(self):
        return len(self.heap)
      
N,M=map(int,input().split())
L = list(map(lambda s:int(s) * -1,input().split()))
#print(L)
pq = PriorityQueue(L)
import math
for _ in range(M):
  m = pq.pop()
  #print(m)
  pq.push(math.ceil(m / 2))
ANS=0
for _ in range(N):
  k = pq.pop()
  #print(k)
  ANS += k
print(ANS * -1)
n, x = (int(i) for i in input().split()) 
a = sorted([int(i) for i in input().split()])

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

import functools

if len(a) == 1:
    print(a[0] - x)
    exit()

diff = []
for i in range(len(a)-1):
    diff.append(a[i+1] - a[i])

list_gcd = functools.reduce(gcd, diff)

import bisect

bi_index = bisect.bisect_left(a, x)
if a[bi_index] == x:
    print(list_gcd)
    exit()

if bi_index == 0:
    print(gcd(list_gcd, a[0]-x))
    exit()

if bi_index == len(a):
    print(gcd)
    exit()

print(functools.reduce(gcd, [list_gcd, x-a[bi_index], a[bi_index+1]-x ]))


### FIXED CODE ###

n, x = (int(i) for i in input().split()) 
a = sorted(list(set([int(i) for i in input().split()])))

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

import functools

if len(a) == 1:
    print(abs(a[0] - x))
    exit()

diff = []
for i in range(len(a)-1):
    diff.append(a[i+1] - a[i])

list_gcd = functools.reduce(gcd, diff)

import bisect

bi_index = bisect.bisect_left(a, x)
if bi_index == len(a):
    print(gcd(list_gcd, x-a[-1]))
    exit()

if a[bi_index] == x:
    print(list_gcd)
    exit()

if bi_index == 0:
    print(gcd(list_gcd, a[0]-x))
    exit()

print(functools.reduce(gcd, [list_gcd, x-a[bi_index-1], a[bi_index]-x ]))
n = int(input())
s = input()

t = [0] * n
if s[0] == 'E':
    s[0] = 1

for i in range(1, n):
    if s[i] == 'E':
        t[i] = 1
    t[i] += t[i-1]

ans = 10000000000

for i in range(n):
    if i == 0:
        a = 0
    else:
        a = i - t[i-1]
    b = t[n-1] - t[i]
    c = a + b

    ans = min(ans, c)

print(ans)


### FIXED CODE ###

n = int(input())
s = input()

t = [0] * n
for i in range(n):
    if s[i] == 'E':
        t[i] = 1
    if i == 0:
        continue
    t[i] += t[i-1]

ans = 10000000000

for i in range(n):
    if i == 0:
        a = 0
    else:
        a = i - t[i-1]
    b = t[n-1] - t[i]
    c = a + b

    ans = min(ans, c)

print(ans)
#input
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))

#output
import numpy as np
A.sort()

def number_of_shake(K):
    p = np.searchsorted(A, K-A)
    return N*N - p.sum()

left = 0
right = 10**10+1
while left + 1 < right:
    mid = (left + right) // 2
    if number_of_shake(mid) >= M:
        left = mid
    else:
        right = mid

L = np.searchsorted(A, right-A)
Acum = np.zeros(N+1, np.int64)
Acum[1:] = np.cumsum(A)

shake = N*N - L.sum()
happy = (Acum[-1] - Acum[L]).sum() + (A*(N-L)).sum()
happy += (M-shake)*left

print(happy)

### FIXED CODE ###

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

#output
import numpy as np
A = np.array(A)
A.sort()

def number_of_shake(K):
    p = np.searchsorted(A, K-A)
    return N*N - p.sum()

left = 0
right = 10**6
while left + 1 < right:
    mid = (left + right) // 2
    if number_of_shake(mid) >= M:
        left = mid
    else:
        right = mid

L = np.searchsorted(A, right-A)
Acum = np.zeros(N+1, np.int64)
Acum[1:] = np.cumsum(A)

shake = N*N - L.sum()
happy = (Acum[-1] - Acum[L]).sum() + (A*(N-L)).sum()
happy += (M-shake)*left

print(happy)
#include <iostream>
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    if (B % A == 0) cout << (A+B) << endl;
    else cout << (B-A) << endl;
}


### FIXED CODE ###

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

if (B % A == 0):
    print(A+B)
else:
    print(B-A)
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a - b <= d and b - c <= d:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a, b, c, d = map(int, input().split())

if abs(a - c) <= d:
    print('Yes')
elif (a < b and b < c) or (a > b and b > c):
    if abs(a - b) <= d and abs(b - c) <= d:
        print('Yes')
    else:
        print('No')
else:
    print('No')
I = lambda: map(int, input().split())
nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
minf = -10**9
n, _ = I()
*A, = sorted(I(), reverse = True)
digs = [0]*(n+1)
for i in range(1, n+1):
    d = []
    for a in A :
        before = i-nums[a]
        d.append(minf if before < 0 else digs[before]+1)
    digs[i] = max(d)
ans = []
while n > 0:
    for a in A:
        if digs[n-nums[a]] == digs[n]-1:
            ans.append(a)
            n -= nums[a]
            break
print(*ans, sep = '')

### FIXED CODE ###

I = lambda: map(int, input().split())
nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
minf = -float('inf')
n, _ = I()
*A, = sorted(I(), reverse = True)
digs = [0]*(n+1)+[-1]*9
for i in range(1, n+1):
    d = []
    for a in A :
        before = i-nums[a]
        d.append(minf if before < 0 else digs[before]+1)
    digs[i] = max(d)
ans = []
while n > 0:
    for a in A:
        if digs[n-nums[a]] == digs[n]-1:
            ans.append(a)
            n -= nums[a]
            break
print(*ans, sep = '')
N, A, B = map(int, input().split())
S = ''
r = 'r'*B
b = 'b'*A
while len(S) < N+5:
    S += b
    S += r
print(S[:N].count('b'))

### FIXED CODE ###

N, A, B = map(int, input().split())
d = N//(A+B)
p = N%(A+B)

S = d*A + min(p, A)
print(S)
n,m=map(int,input().split())
s={}
for i in range(m):
    a,b=map(int,input().split())
    s[a]=s.get(a,0)+1
    s[b]=s.get(b,0)+1
for i in range(1,n+1):
    print(s[i])

### FIXED CODE ###

n,m=map(int,input().split())
ls=[0]*(n+1)
for i in range(m):
    a,b= map(int,input().split())
    ls[a]+=1
    ls[b]+=1
for j in range(1,n+1):
    print(ls[j])
n = int(input())
ls = []
for i in range(n):
    a = int(input())
    for i in range(a):
        x,y = map(int,input().split())
        ls.append([x-1,y])

ans = 0

for i in range(2**n):
    flag = 0
    for j in range(n):
        if (i >> j) & 1:
            for k in ls[j]:
                if (i >> k[0]) & 1 != y:
                    flag = 1
                    break
    if flag == 0:
        ans = max(ans, bin(i)[2:].count('1'))
print(ans)

### FIXED CODE ###

n = int(input())
ls = []
for i in range(n):
    a = int(input())
    p = []
    for i in range(a):
        x,y = map(int,input().split())
        p.append([x-1,y])
    ls.append(p)

ans = 0

for i in range(2**n):
    flag = 0
    for j in range(n):
        if (i >> j) & 1:
            for k in ls[j]:
                if (i>>k[0])&1 != k[1]:
                    flag = 1
                    break
    if flag == 0:
        ans = max(ans, bin(i)[2:].count('1'))
print(ans)
_, *a = map(int, open(0).read.split())
ret = 1
for x in sorted(a):
  ret *= x
  if ret > 10**18:
    ret = -1
    break
print(ret)

### FIXED CODE ###

_, *a = map(int, open(0).read().split())
ret = 1
for x in sorted(a):
  ret *= x
  if ret > 10 ** 18:
    ret = -1; break
    
print(ret)
n, k = list(map(int, input().split()))
t = list(map(int, input().split()))

visited = [False]*(2*10**5 + 10)
val = 1
count = 0
hold = k
while hold > 0 :
    if visited[val - 1] or val == t[val - 1]:
        break
    visited[val - 1] = True
    val = t[val - 1]
    # print('a', val)
    count += 1
    hold -= 1
if hold == 0:
    print(1/0)
    exit(0)
if val == t[val - 1]:
    print(1/0)
    exit(0)
count0 = count
count = 1
newval = val
start = t[newval - 1]
while start != newval:
    count += 1
    start = t[start - 1]
# print('count', count, 'count0', count0)
if t[val - 1] == t[0]:
    temp = k
else:
    temp = k - count0
# print('temp', temp)
jump = (temp) % (count)
# print('jump', jump)
# print('val', val)
ans = val
for i in range(jump):
    ans = t[ans - 1]
    # print('b', ans)
print(ans)

### FIXED CODE ###

n, k = list(map(int, input().split()))
t = list(map(int, input().split()))

visited = [False]*(2*10**5 + 10)
val = 1
count = 0
hold = k
while hold > 0 :
    if visited[val - 1] or val == t[val - 1]:
        break
    visited[val - 1] = True
    val = t[val - 1]
    # print('a', val)
    count += 1
    hold -= 1
# print(hold)
if hold == 0:
    print(val)
    exit(0)
if val == t[val - 1]:
    print(val)
    exit(0)
count0 = count
count = 1
newval = val
start = t[newval - 1]
while start != newval:
    count += 1
    start = t[start - 1]
# print('count', count, 'count0', count0)
if t[val - 1] == t[0]:
    temp = k
else:
    temp = k - count0
# print('temp', temp)
jump = (temp) % (count)
# print('jump', jump)
# print('val', val)
ans = val
for i in range(jump):
    ans = t[ans - 1]
    # print('b', ans)
print(ans)
import math

x = int(input())

if x == 2:
    print(3)
elif x%2 == 0:
    ans = x+1
else:
    ans = x

#2以外の素数は奇数であることに注意

while True:
    for i in range(3, int(math.sqrt(ans))+1, 2):
        if ans%i == 0:
            ans += 2
            break
    else:
        print(ans)
        exit()



### FIXED CODE ###

import math

x = int(input())

if x == 2:
    print(2)
    exit()

elif x%2 == 0:
    ans = x+1

else:
    ans = x

#2以外の素数は奇数であることに注意

while True:
    for i in range(3, int(math.sqrt(ans))+1, 2):
        if ans%i == 0:
            ans += 2
            break
    else:
        print(ans)
        exit()
import itertools
from scipy.sparse.csgraph import floyd_warshall as wf

def do():
    N,M,R = list(map(int,input().split(" ")))
    rs = list(map(int,input().split(" ")))
    INF = float('inf')

    graph = [ [INF for _ in range(N + 1)]for _ in range(N + 1)]
    for _ in range(M):
        a,b,c = (map(int, input().split(" ")))
        graph[a][b] = c
        graph[b][a] = c

    graph = wf(graph)

    perms = itertools.permutations(rs)
    ans = INF
    for temp in perms:
        cand = 0
        for i in range(0,R-1):
            fr = temp[i]
            to = temp[i + 1]
            cand+= graph[fr][to]
        ans = min(cand,ans)
    print(int(ans))

if __name__ == "__main__":
    do()

### FIXED CODE ###


import itertools

def do():
    N,M,R = list(map(int,input().split(" ")))
    rs = list(map(int,input().split(" ")))
    INF = 10 ** 20
    graph = [ [INF for _ in range(N + 1)]for _ in range(N + 1)]
    for _ in range(M):
        a,b,c = (map(int, input().split(" ")))
        graph[a][b] = c
        graph[b][a] = c
    for k in range(1,N+1):
        for j in range(1, N + 1):
            for i in range(1, N + 1):
                graph[j][i] = min(graph[j][i] , graph[j][k] + graph[k][i])

    perms = itertools.permutations(rs)
    ans = INF
    for temp in perms:
        cand = 0
        for i in range(0,R-1):
            fr = temp[i]
            to = temp[i + 1]
            cand+= graph[fr][to]
        ans = min(cand,ans)
    print(ans)

if __name__ == "__main__":
    do()
import numpy as np

n = float(input())
list = [int(input()) for i in range(5)]

l = np.array(list)

d = np.amin(l)
dm = np.argmin(l)
'''                                                                                 
if dm == 4:                                                                         
    print(int(n//d))                                                                
'''
else:
    print(int(n//d+5))

### FIXED CODE ###

import numpy as np
import math

n = float(input())
list = [int(input()) for i in range(5)]

l = np.array(list)

d = np.amin(l)
dm = np.argmin(l)

print(int(math.ceil(n/d)+4))
from itertools import zip_longest as zi
n=int(input())
hil=[ [ [],[] ] for i in range(n)]
for i in range(n):
  hint=int(input())
  if hint:
    for j in range(hint):
      a,s=map(int,input().split())   
      hil[a-1][s]+=[i]

ans=0
for i in range(2**n)[::-1]:
  ss=bin(i)[2:]
  s="0"*(n-len(ss))+ss
  sset=set([fg for fg in range(n) if s[fg]=="1"])
  hset=set(range(n))-sset
  print(sset,hset)
  jjj,kkk=set(),set()
  for kk in sset:
    j,k=hil[kk]
    j,k=set(j),set(k)
    jjj|=j;kkk|=k
    
  if len(jjj&sset) or len(kkk&hset) :
    contiue
  else:
    ans=max(ans,len(ss.replace("0","")))
print(ans)


### FIXED CODE ###

n=int(input())
l=[0 for i in range(n)]
for i in range(n):
  ka=int(input())
  r,w=[],[]
  for k in range(ka):
    x,y=map(int,input().split())
    r.append(x-1) if y else w.append(x-1)
  l[i]=(set(r),set(w))
ans=0
for j in range(2**n):
  v=format(j,"b").zfill(n)
  R,W=set(),set()
  RR={t for t in range(n) if v[t]=="1"}
  for h in RR:
    r,w=l[h]
    R|=r
    W|=w
  WW=set(range(n))-RR
  if len(RR&W) or len(WW&R) or len(R&W) :continue
  else:ans=max(ans,len(RR))
print(ans)
i=0
while 1:
 i+=1
 print'Case %d: %s'%(i,raw_input())

### FIXED CODE ###

i=0
while 1:
 i+=1
 try:
  s=input()
  assert(s)
  print'Case %d: %d'%(i,s)
 except:
  break
n = int(input())
a = [int(x) for x in input()]
ans = 1/sum(1/x for x in a)
print(ans)

### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]
ans = 1/sum(1/x for x in a)
print(ans)
n, k = map(int, input().split())

import sys

sys.setrecursionlimit(2000)

l = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)

def first_search(first, depth):
    record = 0
    for i in l[first]:
        temp = search(first, i, depth-1)
        if record < temp:
            record = temp
    return record + 1

def search(before, now, depth):
    if depth <= 0:
        return 1
    else:
        ans = 1
        for i in l[now]:
            if before != i:
                ans += search(now, i, depth-1)
        return ans

ret = 0
for i in range(n):
    temp = first_search(i, k)
    if temp > ret:
        ret = temp
        

print(n-ret)

### FIXED CODE ###

n, k = map(int, input().split())

import sys

sys.setrecursionlimit(2000)

l = [[] for i in range(n)]
e = []
for i in range(n-1):
    a, b = map(int, input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)
    e.append([a-1, b-1])

def first_search(first, depth):
    record = 0
    for i in l[first]:
        temp = search(first, i, depth-1)
        if record < temp:
            record = temp
    return record + 1

def search(before, now, depth):
    if depth <= 0:
        return 1
    else:
        ans = 1
        for i in l[now]:
            if before != i:
                ans += search(now, i, depth-1)
        return ans

ret = 0
if k%2 == 0:
    for i in range(n):
        temp = search(-1, i, k//2)
        if temp > ret:
            ret = temp
else:           
    for i in e:
        temp = search(i[0], i[1], k//2) + search(i[1], i[0], k//2)
        if temp > ret:
            ret = temp
        

print(n-ret)
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
  A[i] -= 1
  A[i] %= K

hm = {}
hm[A[0]] = 1
out = 0
for i in range(1,N):
  A[i] += A[i-1]
  A[i] %= K

for i in range(K-1):
  if A[i]==0:
    out+=1
    
for i in range(1,K-1):
  if A[i] in hm:
    hm[A[i]]+=1
  else:
    hm[A[i]]=1
  out += hm[A[i]]-1
  
for i in range(K-1,N):
  if A[i] in hm:
    hm[A[i]]+=1
  else:
    hm[A[i]]=1
  hm[A[i-K+1]] -= 1
  out += hm[A[i]]-1

print(int(out))

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
  A[i] -= 1
  A[i] %= K

hm = {}
hm[A[0]] = 1
out = 0
for i in range(1,N):
  A[i] += A[i-1]
  A[i] %= K

for i in range(min(K-1,N)):
  if A[i]==0 and K != 1:
    out+=1
    
for i in range(1,min(N,K)):
  if A[i] in hm:
    hm[A[i]]+=1
  else:
    hm[A[i]]=1
  out += hm[A[i]]-1
  
for i in range(min(K,N),N):
  if A[i] in hm:
    hm[A[i]]+=1
  else:
    hm[A[i]]=1
  hm[A[i-K]] -= 1
  out += hm[A[i]]-1

print(int(out))