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

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

inf=float("inf")
dp=[inf]*N
dp[0]=0
 
for i in range(1,N):
	for g in range(1, K+1):
		if i-g<0:
			break
		dp[i] = min(dp[i-g] + abs(h[i] - h[i-g]), dp[i])

print(dp[N-1])

### FIXED CODE ###

def main():
	N, K = map(int, input().split())
	h = list(map(int, input().split()))

	dp=[0]*N
 
	for i in range(1,N):
		dp[i] = min(
			dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
		)
	print(dp[N-1])
main()
### BUGGY CODE ###

import re
n = int(input().split()[1])
s = input()

iter = re.finditer('AC', s)

indexes = []
for i in iter:
  indexes.append(i.start())
  
counts = []
for r in range(len(s)):
  c = sum(i < r for i in indexes)
  counts.append(c)

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


### FIXED CODE ###

import re
n = int(input().split()[1])
s = input()

counts = [0]
for i in range(len(s)):
  counts.append(counts[i] + (1 if s[i : i + 2] == 'AC' else 0))

for i in range(n):
  l, r = map(int, input().split())
  print(counts[r - 1] - counts[l - 1])
### BUGGY CODE ###

# coding=utf-8
# Date: 2020-01-08
# Author: lee215


get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


H, N = gets()
AB = getss(N)
AB.sort(key=lambda a_b: -a_b[0] * 1.0 / a_b[1])

a0, b0 = AB[0]
dp = [0] + [float('inf')] * (H + a0)

cur = 0
while cur <= H + a0:
    dp[cur] = cur / a0 * b0
    cur += a0


for a, b in AB[1:]:
    for i in xrange(a, H + a0 + 1):
        dp[i] = min(dp[i], dp[i - a] + b)
print min(dp[H:])


### FIXED CODE ###

# coding=utf-8
# Date: 2020-01-08
# Author: lee215

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

H, N = gets()
AB = getss(N)
AB.sort(key=lambda a_b: -a_b[0] * 1.0 / a_b[1])

a0, b0 = AB[0]
dp = [0] + [float('inf')] * (H + a0)

cur = 0
while cur <= H + a0:
    dp[cur] = cur / a0 * b0
    cur += a0


for a, b in AB[1:]:
    for i in xrange(a, H + a0 + 1):
        dp[i] = min(dp[i], dp[i - a] + b)
print min(dp[H:])
### BUGGY CODE ###

import collections


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

    # 頂点のリスト、ポイント、走査済みか
    graph = [[[], 0, False] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        graph[a-1][0].append(b-1)
        graph[b-1][0].append(a-1)

    for i in range(q):
        p, x = map(int, input().split())
        graph[p-1][1] += x

    queue = collections.deque([0])
    while queue:
        q = queue.pop()
        graph[q][2] = True
        for v in graph[q][0]:
            if graph[v][2]:
                continue
            graph[v][1] += graph[q][1]
            queue.append(v)

    for i in range(n):
        print(graph[i][1], end=' ')


if __name__ == '__main__':
    main()


### FIXED CODE ###

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

    # 頂点のリスト、ポイント、走査済みか
    graph = [[[], 0, False] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        graph[a-1][0].append(b-1)
        graph[b-1][0].append(a-1)

    for i in range(q):
        p, x = map(int, input().split())
        graph[p-1][1] += x

    queue = [0]
    while queue:
        q = queue.pop()
        graph[q][2] = True
        for v in graph[q][0]:
            if graph[v][2]:
                continue
            graph[v][1] += graph[q][1]
            queue.append(v)

    for i in range(n):
        print(graph[i][1], end=' ')


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

import sys
N = int(input())
p = list(map(float, input().split()))
if N == 1:
    print(p[0])
    sys.exit()
dp = [[0 for _ in range(N + 10)] for _ in range(N + 10)]
dp[2][0] = (1.0 - p[0]) * (1.0 - p[1])
dp[2][2] = p[0] * p[1]
dp[2][1] = 1.0 - dp[2][0] - dp[2][2]
for i in range(2, N):
    for l in range(0, N + 1):
        dp[i + 1][l + 1] += dp[i][l] * p[i]
        dp[i + 1][l] += dp[i][l] * (1.0 - p[i])
ans = 0.0
for i in range(N // 2 + 1, N + 1):
    ans += dp[N][i]
print(ans)


### FIXED CODE ###

import sys
import math
from collections import deque
import copy

N = int(input())
p = list(map(float, input().split()))
if N == 1:
    print(p[0])
    sys.exit()
dp = [[0 for _ in range(N + 10)] for _ in range(N + 10)]
dp[2][0] = (1.0 - p[0]) * (1.0 - p[1])
dp[2][2] = p[0] * p[1]
dp[2][1] = 1.0 - dp[2][0] - dp[2][2]
for i in range(2, N):
    for l in range(0, N + 1):
        dp[i + 1][l + 1] += dp[i][l] * p[i]
        dp[i + 1][l] += dp[i][l] * (1.0 - p[i])
ans = 0.0
for i in range(N // 2 + 1, N + 1):
    ans += dp[N][i]
print(ans)
### BUGGY CODE ###

n = int(input())
p = [int(i) for i in input().split()]

ans = 0
for i in range(1, n+1):
    low = p[:i]
    if min(low) == p[i-1]:
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
ppp = list(map(int, input().split()))
curr = 10 ** 6
ans = 0
for p in ppp:
    if p < curr:
        ans += 1
        curr = p
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
INF = 10 ** 5 * 12
dp = [INF] * (1 << n)
dp[0] = 0
keys = []

for _ in range(m):
    a, b = map(int, input().split())
    s = 0
    for c in list(map(int, input().split())):
        s |= 1 << (c - 1)
    keys.append([s, a])

for s in range(1 << n):
    for i in range(m):
        to = s | keys[i][0]
        cost = dp[s] + keys[i][1]
        dp[to] = min(dp[to], cost)

ans = dp[-1] if dp[-1] != INF else -1
print(ans)


### FIXED CODE ###

n, m = map(int, input().split())
keys = []
INF = 10 ** 5 * 12
dp = [INF] * (1 << n)
dp[0] = 0

for _ in range(m):
    a, b = map(int, input().split())
    s = 0
    for c in list(map(int, input().split())):
        s |= 1 << (c - 1)
    keys.append([s, a])

for s in range(1 << n):
    for i in range(m):
        to = s | keys[i][0]
        cost = dp[s] + keys[i][1]
        dp[to] = min(dp[to], cost)

ans = dp[-1]
if ans == INF:
    ans = -1
print(ans)
### BUGGY CODE ###

# python には結構厳しいTLE・・・python以外のお勉強時間ないよ～( ;∀;)
# . から見た # の最大距離の方が楽ではあるが・・・
# 嫌いだけど def main も使ってみた．

def ins(ls, i):
  ls[i] = True
  return i

def main():
  H, W = list(map(int, input().split()))
  all_count = H * W
  L = [j == "#" for i in range(H) for j in input()]
  blacks = [i for i in range(all_count) if L[i]]
  black_count = len(blacks)
 
  cands_H = [-W, W]
  cands_W = [-1, 1]
  result = 0
  while black_count < all_count:
    next_steps = [black+cand for black in blacks for cand in cands_H]
    next_steps.extend([black-1 for black in blacks if black%W != 0])
    next_steps.extend([black+1 for black in blacks if black%W != W-1])
    next_steps = set(next_steps)
    blacks = [ins(L, i) for i in next_steps if i >= 0 and i < all_count and not L[i]]
    black_count += len(blacks)
    result += 1

  print(result)

if __name__ == "__main__":
  main()


### FIXED CODE ###

# python には結構厳しいTLE・・・python以外のお勉強時間ないよ～( ;∀;)
# . から見た # の最大距離の方が楽ではあるが・・・
# 嫌いだけど def main も使ってみた．
from collections import deque
import copy

def main():
  H, W = list(map(int, input().split()))
  L = [[j=="#" for j in input()] for i in range(H)]
  q = deque([(i, j) for i in range(H) for j in range(W) if L[i][j]])
  cands = [(0, -1), (0, 1), (-1, 0), (1, 0)]
  result = 0
  while True:
    nq = deque()
    while q:
      i, j = q.popleft()
      if i > 0 and not L[i-1][j]:
        L[i-1][j] = True
        nq.append((i-1, j))
      if j > 0 and not L[i][j-1]:
        L[i][j-1] = True
        nq.append((i, j-1))
      if i < H-1 and not L[i+1][j]:
        L[i+1][j] = True
        nq.append((i+1, j))
      if j < W-1 and not L[i][j+1]:
        L[i][j+1] = True
        nq.append((i, j+1))
    if nq:
      q = copy.copy(nq)
    else:
      break    
    result += 1
  print(result)

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

alphabet = "abcdefghijklmnopqrstuvwxyz"
a_len = len(alphabet)
table = {c: idx for idx, c in enumerate(alphabet)}

s = input()
k = int(input())

ans = ""
for i in range(len(s)):
    if i == len(s) - 1:
        ans += alphabet[(table[s[i]] + k) % a_len]
    else:
        gap = a_len - table[s[i]]
        if gap <= k:
            ans += "a"
            k -= gap
        else:
            ans += s[i]

print(ans)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    s = rl().rstrip()
    K = int(rl())
    
    ans = []
    for si in s:
        if si == 'a':
            ans.append('a')
            continue
        cnt = ord('z') - ord(si) + 1
        if cnt <= K:
            ans.append('a')
            K -= cnt
        else:
            ans.append(si)
    
    ans[-1] = chr(ord('a') + (ord(ans[-1]) - ord('a') + K % 26) % 26)
    print(''.join(ans))


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

# @author 

import sys


class PIndependentSet:
    def solve(self):
        from collections import defaultdict
        import sys
        sys.setrecursionlimit(10 ** 5 + 5)
        MOD = 10 ** 9 + 7

        def dfs(s):
            done[s] = 1
            dp[s][0] = 1
            dp[s][1] = 1
            for x in adj[s]:
                if done[x]:
                    continue
                dfs(x)
                dp[s][0] = (dp[s][0] * dp[x][1]) % MOD
                dp[s][1] = (dp[s][1] * (dp[x][0] + dp[x][1])) % MOD

        n = int(input())
        adj = defaultdict(list)

        for i in range(n - 1):
            x, y = [int(_) for _ in input().split()]
            x -= 1
            y -= 1
            adj[x].append(y)
            adj[y].append(x)

        dp = [[0, 0] for _ in range(n)]
        done = [0] * n
        dfs(0)

        print((dp[0][0] + dp[0][1]) % MOD)

solver = PIndependentSet()
input = sys.stdin.readline

solver.solve()


### FIXED CODE ###

# @author 

import sys


class PIndependentSet:
    def solve(self):
        from collections import defaultdict
        import sys
        sys.setrecursionlimit(10 ** 5 + 5)
        MOD = 10 ** 9 + 7

        def dfs(s):
            done[s] = 1
            dp[s][0] = 1
            dp[s][1] = 1
            for x in adj[s]:
                if done[x]:
                    continue
                dfs(x)
                dp[s][0] = (dp[s][0] * dp[x][1]) % MOD
                dp[s][1] = (dp[s][1] * (dp[x][0] + dp[x][1])) % MOD

        n = int(input())
        adj = defaultdict(list)

        for i in range(n - 1):
            x, y = [int(_) for _ in input().split()]
            x -= 1
            y -= 1
            adj[x].append(y)
            adj[y].append(x)

        dp = [[0, 0] for _ in range(n)]
        done = [0] * n
        dfs(0)

        print((dp[0][0] + dp[0][1]) % MOD)

solver = PIndependentSet()
input = sys.stdin.readline

solver.solve()
### BUGGY CODE ###

N = int(input())
L = [input() for i in range(N)]
max = 0
ans = []
while(len(L) > 0):
    a = L[0]
    c = L.count(L[0])
    if c > max:
        max = c
        ans.clear()
        ans.append(L[0])
    elif c == max:
        ans.append(L[0])
    L = [i for i in L if i !=a]
ans.sort()
[print(i) for i in ans]

### FIXED CODE ###

N = int(input())
ans = {}
for i in range(N):
    a = input()
    ans[a] = ans.get(a,0) + 1

t = max(ans.values())
ans2 = [k for k, v in ans.items() if v ==t ]
ans2.sort()
[print(i) for i in ans2]
### BUGGY CODE ###

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

############################################

# read data for n sequences.
N = int(input())
data = input()

out = 0

if N > 2:
    for ii, i in enumerate(data[:-2]):
        for jj,j in enumerate(data[ii+1:-1]):
            jj = jj+ii+1
            if i!=j:
                sum1 = 0                    
                for d in [d for d in "RGB"]:
                    if i!=d and j!=d:
                        #sum1 = np.sum(np.asarray([d for d in data[jj+1:]])==d)
                        sum1 = 0
                        for l in data[jj+1:]:
                            if d == l:
                                sum1 +=1
                        let = d
                out+=sum1
                if jj+jj-ii<N:
                    if data[jj+jj-ii]==let:                    
                        out-=1
print(out)



### FIXED CODE ###

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

############################################

# read data for n sequences.
N = int(input())
data = input()

out = 0
r=0;g=0;b=0;
for d in data:
    if d =="R":
        r+=1
    elif d=="B":
        b+=1
    else:
        g+=1
out = r*g*b

if N > 2:
    for ii, i in enumerate(data[:-2]):
        for jj,j in enumerate(data[ii+1:-1]):
            jj = jj+ii+1
            if i!=j:
                sum1 = 0                    
                for d in [d for d in "RGB"]:
                    if i!=d and j!=d:
                        let = d

                if jj+jj-ii<N:
                    if data[jj+jj-ii]==let:                    
                        out-=1
print(out)
### BUGGY CODE ###

from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

L = [0]
R = [0]
for i in range(N):
    L.append(gcd(L[i], A[i]))
    R.insert(0, gcd(R[0], A[N-i-1]))   

M = []
for i in range(N):
    M.append(gcd(L[i], R[i+1]))
print(max(M))


### FIXED CODE ###

from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

L = [0] * (N+1)
R = [0] * (N+1)
for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

max_m = 0
for i in range(N):
    m = gcd(L[i], R[i+1])
    if max_m < m:
        max_m = m
print(max_m)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
my_dict = dict()
n = int(input())
for i in range(n):
    my_input = input()
    if my_input in my_dict:
        my_dict[my_input] = my_dict[my_input] + 1
    else:
        my_dict[my_input] = 1

max_k_list = [kv[0]
              for kv in my_dict.items() if kv[1] == max(my_dict.values())]

max_k_list.sort()

print("\n".join(max_k_list))


### FIXED CODE ###

# -*- coding: utf-8 -*-
my_dict = dict()
n = int(input())
for i in range(n):
    my_input = input()
    if my_input in my_dict:
        my_dict[my_input] += 1
    else:
        my_dict[my_input] = 1

max_val = max(my_dict.values())
keys_of_max_val = [key for key in my_dict if my_dict[key] == max_val]

keys_of_max_val.sort()

print("\n".join(keys_of_max_val))
### BUGGY CODE ###

import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    d = list(map(int, input().split()))
    m = int(input())
    t = list(map(int, input().split()))
    t = collections.Counter(t)
    for i in t:
        if t[i] > d.count(i):
            print("NO")
            break
    else:
        print("YES")
    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    d = list(map(int, input().split()))
    m = int(input())
    t = list(map(int, input().split()))
    t = collections.Counter(t)
    d = collections.Counter(d)
    for i in t:
        if t[i] > d[i]:
            print("NO")
            break
    else:
        print("YES")
    return 0

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

import sys
input = sys.stdin.readline

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

dp = [[0]*(W+1) for _ in range(N+1)]
    
def npsk_1(N, W):
    for i in range(N):
        w, v = map(int, input().split())
        for j in range(W+1):
            if j  >= w:
                dp[i+1][j] = max(dp[i][j], dp[i][j - w] + v)
            else:
                dp[i+1][j] = dp[i][j]
    
    print(dp[N][W])

npsk_1(N, W)

### FIXED CODE ###

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

w, v = [0] * N, [0] * N

for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]

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

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

import itertools
K,S = (int(i) for i in input().split()) 
A=()
for i in range(K+1):
    A=A+(i,)

L=list(itertools.combinations_with_replacement(A,3))
SUM=0
for i in range(len(L)):
    if L[i][0]+L[i][1]+L[i][2]==S:
        if len(L[i]) == len(set(L[i])) + 2:
            SUM = SUM + 1  # sonomama! 3tu tyouhuku
        if len(L[i]) == len(set(L[i])) + 1:
            SUM = SUM + 3  # kakeru3 2tu tyouhuku
        if len(L[i]) == len(set(L[i])):  # kakeru6 tyouhuku 0
            SUM = SUM + 6

print(SUM)

### FIXED CODE ###

K,S=map(int,input().split())
b=sum(0<=S-x-y<=K  for x in range(K+1)for y in range(K+1))
print(b)
### BUGGY CODE ###

from collections import deque
from itertools import product


def main():
    h, w = map(int, input().split())
    c = tuple(map(lambda x: int(x)+1, input().split()))
    d = tuple(map(lambda x: int(x)+1, input().split()))
    s = ['#'*(w+4)] * 2
    for _ in range(h):
        s.append(f'##{input()}##')
    s.extend(['#'*(w+4)] * 2)

    move_a_area = [(0, -1), (-1, 0), (1, 0), (0, 1)]
    move_b_area = [(i, j) for i, j in product(range(-2, 3), repeat=2) if (i, j) not in [(0, 0)] + move_a_area]

    cost = [[float('inf')] * (w+4) for _ in range(h+4)]
    cost[c[0]][c[1]] = 0
    yet = deque([(c[0], c[1], 0)])
    done = deque()

    while yet:
        y, x, m = yet.popleft()
        done.append((y, x, m))
        # Move A
        for dx, dy in move_a_area:
            hh, ww = y + dy, x + dx
            if s[hh][ww] == '#' or cost[hh][ww] <= m:
                continue
            cost[hh][ww] = m
            yet.append((hh, ww, m))
        # Move B
        if not yet:
            while done:
                y, x, m = done.popleft()
                for dx, dy in move_b_area:
                    hh, ww = y + dy, x + dx
                    if s[hh][ww] == '#' or cost[hh][ww] <= m + 1:
                        continue
                    cost[hh][ww] = m + 1
                    yet.append((hh, ww, m + 1))

    print(v if (v := cost[d[0]][d[1]]) < float('inf') else -1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import deque
from itertools import product

h, w = map(int, input().split())
c = tuple(map(lambda x: int(x)-1, input().split()))
d = tuple(map(lambda x: int(x)-1, input().split()))
s = list(input() for _ in range(h))

move_a_area = [(0, -1), (-1, 0), (1, 0), (0, 1)]
move_b_area = [(i, j) for i, j in product(range(-2, 3), repeat=2) if (i, j) not in [(0, 0)] + move_a_area]

cost = [[float('inf')] * w for _ in range(h)]
cost[c[0]][c[1]] = 0
que = deque([(c[0], c[1], 0)])

while que:
    y, x, m = que.popleft()
    # Move A
    for dx, dy in move_a_area:
        hh, ww = y + dy, x + dx
        if hh < 0 or h <= hh or ww < 0 or w <= ww or s[hh][ww] == '#' or cost[hh][ww] <= m:
            continue
        cost[hh][ww] = m
        que.appendleft((hh, ww, m))
    # Move B
    for dx, dy in move_b_area:
        hh, ww = y + dy, x + dx
        if hh < 0 or h <= hh or ww < 0 or w <= ww or s[hh][ww] == '#' or cost[hh][ww] <= m + 1:
            continue
        cost[hh][ww] = m + 1
        que.append((hh, ww, m + 1))

print(cost[d[0]][d[1]] if cost[d[0]][d[1]] < float('inf') else -1)
### BUGGY CODE ###

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

from bisect import insort_left

for _ in range(m):
    x = A.pop()//2
    insort_left(A, x)

print(sum(A))


### FIXED CODE ###

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

from heapq import heappush, heappop

for _ in range(m):
    x = heappop(A)
    heappush(A, (-1*x)//2*(-1))

print(sum(A)*(-1))
### BUGGY CODE ###

import math
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
 
n, a, b = map(int, input().split(' '))
s = 0
for i in range(1, n+1):
    if i == a or i == b:
        continue
    s += cmb(n, n-i)
print(int(s % (math.pow(10, 9)+7)))

### FIXED CODE ###

import sys
input = sys.stdin.readline
def cmb(n, k, p):
    x, y = 1, 1
    for i in range(k):
        x = x * (n-i) % p
        y = y * (k-i) % p
    return x * pow(y, p-2, p) % p
def main():
    n, a, b = map(int, input().split())
    p = 10 ** 9 + 7
    ans = pow(2, n, p) - 1
    ans -= cmb(n, a, p) + cmb(n, b, p)
    print(ans%p)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if L[i] < L[j]+L[k] and L[j] < L[i]+L[k] and L[k] < L[i]+L[j]:
        ans += 1
print(ans)

### FIXED CODE ###

from bisect import bisect_left
N = int(input())
L = list(map(int,input().split()))
ans = 0
L.sort()
for i in range(N):
  for j in range(i+1,N):
    sumn = L[i]+L[j]
    num = bisect_left(L,sumn)
    ans += max(0,num-j-1)
print(ans)
### BUGGY CODE ###

import sys
MOD=10**9+7

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

abi=[0]*61
aze=[0]*61

for item in a:
    j=0
    #print(bin(item))
    while j<len(str(bin(item)))-2:
        #print(j)
        if item>>j & 1:
            abi[j]+=1
        else:
            aze[j]+=1
        j+=1
    k=len(str(bin(item)))-2
    while k<61:
        aze[k]+=1
        k+=1


        #print(abi)

result=0
i=0
while i<61:
    result+=(2**i)%MOD*abi[i]%MOD*(aze[i])%MOD

    i+=1

#print(abi[:4])

#print(aze[:4])
print(result%MOD)


"""
01
10
11
"""



"""
0001
0010
0011
0100
0101
0110
0111
"""

### FIXED CODE ###

import sys
MOD=10**9+7

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

abi=[0]*61
aze=[0]*61

for item in a:
    j=0
    #print(bin(item))
    while j<61:
        #print(j)
        if item>>j & 1:
            abi[j]+=1
        else:
            aze[j]+=1
        j+=1

        #print(abi)

result=0
i=0
while i<61:
    result+=(2**i)%MOD*abi[i]%MOD*(aze[i])%MOD

    i+=1

#print(abi[:4])

#print(aze[:4])
print(result%MOD)


"""
01
10
11
"""



"""
0001
0010
0011
0100
0101
0110
0111
"""
### BUGGY CODE ###

from collections import defaultdict
def main():  
    def factorization(num):
        result = []
        temp = num
        if temp % 2 == 0:
                while temp % 2 == 0:
                    temp /= 2
                d[2] += 1
                result.append(2)
        for i in range(3, int(num ** 0.5) + 1, 2):
            if temp % i == 0:
                while temp % i == 0:
                    temp /= i
                d[i] += 1
                result.append(i)
        if temp != 1:
            d[int(temp)] += 1
            result.append(int(temp))
        if result == []:
            d[num] += 1
    n = int(input())
    A = map(int, input().split())
    d = defaultdict(int)
    for a in A:
        factorization(a)
    d[1] = 0
    m = max(d.values())
    if m == n:
        print('not coprime')
    elif m >= 2:
        print('setwise coprime')
    else:
        print('pairwise coprime')
    



if __name__ == '__main__':
    main()



### FIXED CODE ###

from functools import reduce
from math import gcd
def main():   
    n = int(input())
    A = list(map(int, input().split()))
    C = [0] * 1000001
    for a in A: C[a] += 1
    if reduce(gcd, A) != 1:
        print('not coprime')
    elif all(sum(C[i::i]) <= 1 for i in range(2, 1000001)):
        print('pairwise coprime')
    else:
        print('setwise coprime')

if __name__ == '__main__':
    main()