Harryxun/stf_run huggingface dataset:
# def popcount(x):
#     bitx = bin(x)
#     cnt = bitx.count('1')
#     return cnt

n = int(input())
x = list(input())
popcount = x.count('1')
stock = [1] * (n + 1)

for i in range(1, n + 1):
    stock[i] = stock[i - 1] * 2


for i in range(n):
    tmp = x.copy()
    tmp2 = popcount
    if tmp[i] == '1':
        tmp[i] = '0'
        tmp2 -= 1
    else:
        tmp[i] = '1'
        tmp2 += 1
    num = 0
    if tmp[i] == '0':
        for i in range(n):
            num += tmp[i] * stock[i]
    
    if tmp2 == 0:
        print(0)
    elif num>0 andnum % tmp2 == 0:
        print(1)
    elif tmp[n - 1] == '1' and tmp2 % 2 == 0 and tmp2 > 2:
        print(3)
    else:
        print(2)

### FIXED CODE ###

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def popcount(num):
    cnt = 0
    while num > 0:
        num %= bin(num).count('1')
        cnt += 1
    return cnt

def Main():
    n = read_int()
    x = read_str()
    x_int = int(x, 2)

    cnt = x.count('1')
    minus_cnt = cnt - 1
    plus_cnt = cnt + 1
    
    minus_mod = x_int % minus_cnt if minus_cnt != 0 else 0
    plus_mod = x_int % plus_cnt

    for i in range(n):
        if x[i] == '0':
            print(popcount((plus_mod + pow(2, n - 1 - i, plus_cnt)) % plus_cnt) + 1)
        elif minus_cnt != 0:
            print(popcount((minus_mod - pow(2, n - 1 - i, minus_cnt)) % minus_cnt) + 1)
        else:
            print(0)

if __name__ == '__main__':
    Main()
import sys
from collections import deque
input = sys.stdin.readline
N = int(input())
side = [[[]for _ in range(N)]for _ in range(N)] 
node = [[1]*N for i in range(N)]
for i in range(N):
    A = list(map(int,input().split()))
    for j in range(N-2):
        a,b = min(i,A[j]-1),max(i,A[j]-1)
        c,d = min(i,A[j+1]-1),max(i,A[j+1]-1)
        side[a][b].append([c,d])
        node[c][d] = 0
def DFS(x,y,l):
    if l > N**2:
        print(-1)
        exit()
    ret = l
    for i,j in side[x][y]:
        ret = max(ret, DFS(i,j,l+1))
    return ret


ans = 0
for i in range(N):
    for j in range(i+1,N):
        if node[i][j]:
            ans = max(DFS(i,j,1),ans)
if ans:
    print(ans)
else:
    print(-1)


### FIXED CODE ###

N = int(input())
A = list(list(map(int,input().split()))for _ in range(N))

c = [0]*(N)
p = []
for i in range(N):
    j = A[i][c[i]]-1
    if i == A[j][c[j]]-1 and i < j:
        p.append((i,j))
ans = 0
while p:
    q = []
    for i,j in p:
        c[i] += 1
        c[j] += 1
        if c[i] < N-1:
            k = A[i][c[i]]-1
            if A[k][c[k]]-1 == i:
                q.append((i,k))
        if c[j] < N-1:
            k = A[j][c[j]]-1
            if A[k][c[k]]-1 == j:
                q.append((j,k))
    ans += 1
    p = q[:]

if min(c) != N-1:
    print(-1)
else:
    print(ans)
n,m,c = map(int,input().split())
input_b = map(int,input().split())
list_a=list(map(int,input().split()))
for i in range(n):
  answer = c
  count = 0
  lista_item = list_a[i]
  for j in range(m):
    answer += input_b[m] * lista_item[m]
  if answer > 0
    count+=1
print count

### FIXED CODE ###

n,m,c = map(int,input().split())
input_b = list(map(int,input().split()))
a_list=[input() for i in range(n)]
count = 0
for i in range(n):
  answer = c
  aitems = list(map(int,a_list[i].split()))
  for j in range(m):
    answer += input_b[j] * aitems[j]
  if answer > 0:
    count+=1
print(count)
a, b, c = map(int, input().split())
    if a == b == c:
        print(1)
    elif a != b != c:
        print(3)
    else:
        print(2)



### FIXED CODE ###

def iroha():
    a, b, c = map(int, input().split())
    if a == b and b == c and a == c:
        print(1)
    elif a != b and b != c and a != c:
        print(3)
    else:
        print(2)

if __name__ == "__main__":
    iroha()
S = list(input())
K = int(input())

l = 0
for i, s in enumerate(S):
    if ord('z') - ord(s) + 1 <= K:
        S[i] = 'a'
        K -= ord('z') - ord(s) + 1
    else:
        l = i
else:
    if K > 0:
        S[l] = chr(ord(S[l]) + K)

print("".join(S))


### FIXED CODE ###

S = list(input())
K = int(input())

for i, s in enumerate(S):
    if s == "a":
        pass
    elif ord('z') - ord(s) + 1 <= K:
        S[i] = 'a'
        K -= ord('z') - ord(s) + 1

K %= 26
S[-1] = chr((ord(S[-1]) - ord('a') + K) % 26 + ord('a'))

print("".join(S))
s=input()
print(abs(min(s.index('A'))-max(s.index("Z"))))

### FIXED CODE ###

s=input()
print(s.rfind("Z")-s.find("A")+1)
N=int(input())
A=list(map(int,input().split()))

cost=[abs(A[i]-A[i+1] for i in range(N-1))]

for i in range(N):
  total=sum(cost)+abs(A[0])+abs(A[N-1])
  if i == 0:
    total-=abs(A[i])
    total-=cost[i]
    total+=abs(A[i+1])
  elif i == N-1:
    total-=abs(A[i])
    total+=abs(A[i-1])
    total-=cost[i-1]
  else:
    total-=cost[i]
    total-=cost[i-1]
    total+=abs(A[i+1]-A[i-1])
  print(total)

### FIXED CODE ###

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

cost=[abs(A[i]-A[i+1]) for i in range(N-1)]
costsum=total=sum(cost)+abs(A[0])+abs(A[N-1])
for i in range(N):
  total=costsum
  if i == 0:
    total-=abs(A[i])
    total-=cost[i]
    total+=abs(A[i+1])
  elif i == N-1:
    total-=abs(A[i])
    total+=abs(A[i-1])
    total-=cost[i-1]
  else:
    total-=cost[i]
    total-=cost[i-1]
    total+=abs(A[i+1]-A[i-1])
  print(total)
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
c=-int(input())
print(*d(list(map(int,input().split()))))
print(c-n)


### FIXED CODE ###

def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
if'__main__'==__name__:
 c=-int(input())
 print(*d(list(map(int,input().split()))))
 print(c)
N = int(input())
A = [int(input()) for i in range(N)]
B=0
for i in A:
    #if A.count(i) >= 1:
    if A.count(i)%2 == 1: 
        B += 1
    else:
        A.remove(i)
print(B)

### FIXED CODE ###

N = input()
print('Yes' if '9' in N else 'No')
n = int(input())

if(n == 0):
    printf(1)
if(n == 1):
    printf(0)

### FIXED CODE ###

n = int(input())

if(n == 0):
    print(1)
elif(n == 1):
    print(0)
K,X = map(int,input().split())
a = 500 * K
print ('Yes' if a => X else 'No')

### FIXED CODE ###

a = input().split()
K = int(a[0])
X = int(a[1])
if 500 * K >= X:
    print('Yes')
else:
    print('No')
read=input();
A,B=read.spilt(' ')
A=int(A)
B=int(B)
if A>12:
  print(B);
elif A>5:
  print(B/2);
else:
  print(B);

### FIXED CODE ###

read=input();
A,B=read.split(' ')
A=int(A)
B=int(B)
if A>12:
  print(B);
elif A>5:
  print(int(B/2));
else:
  print(0);
from bisect import bisect_left

@lru_cache(maxsize=None)
def index(a, x):
    ''' Locate the leftmost value exactly equal to x
    http: // docs.python.jp / 3.5 / library / bisect.html
    '''
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    raise ValueError


if __name__ == '__main__':
    # ??????????????\???
    # S = [1, 2, 3, 4, 5]
    # T = [3, 4, 1]
    num = int(input())
    S = [int(x) for x in input().split(' ')]
    num = int(input())
    T = [int(x) for x in input().split(' ')]

    # ????´¢??????
    found = 0
    for t in T:
        try:
            index(S, t)
        except ValueError:
            pass
        else:
            found += 1

    # ???????????????
    print(found)

### FIXED CODE ###

from bisect import bisect_left
#from functools import lru_cache

#@lru_cache(maxsize=None)
def index(a, x):
    ''' Locate the leftmost value exactly equal to x
    http: // docs.python.jp / 3.5 / library / bisect.html
    '''
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    raise ValueError


if __name__ == '__main__':
    # ??????????????\???
    # S = [1, 2, 3, 4, 5]
    # T = [3, 4, 1]
    num = int(input())
    S = tuple(int(x) for x in input().split(' '))
    num = int(input())
    T = [int(x) for x in input().split(' ')]

    # ????´¢??????
    found = 0
    for t in T:
        try:
            index(S, t)
        except ValueError:
            pass
        else:
            found += 1

    # ???????????????
    print(found)
s=sorted(set(input()))
test="abcdefghijklmnopqrstuvwxyz"
for i in range(len(test)):
    if (s[i]!=test[i]):
        print(test[i])
        break
    if (s[i]==test[i] and i==len(s)-1 and i!=len(test)):
        print(test[i+1])
        break
else:
    print("None")

### FIXED CODE ###

s=sorted(set(input()))
test="abcdefghijklmnopqrstuvwxyz"
for i in range(len(test)):
    if (s[i]!=test[i]):
        print(test[i])
        break
    if (s[i]==test[i] and i==len(s)-1 and i!=len(test)-1):
        print(test[i+1])
        break
else:
    print("None")
k, n = list(map(int, input().split(' ')))
l = list(map(int, input().split(' ')))
ct = 0
ans = 1
i = 0
while ct <= n:
  ct += l[i]
  ans += (ct <= n)
  i += 1
print(ans)

### FIXED CODE ###

k, n = list(map(int, input().split(' ')))
l = list(map(int, input().split(' ')))
ct = 0
ans = 1
i = 0
while ct <= n and i < len(l):
  ct += l[i]
  ans += (ct <= n)
  i += 1
print(ans)
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
ind=bisect.bisect_left(a,0)
print(ind)

if ind==0:
  print(sum(a))

elif ind%2==0 or a[ind]==0:

  print(-sum(a[:ind])+sum(a[ind:]))
else:
  print(-sum(a[:ind])+sum(a[ind:])-2*min(abs(a[ind]),abs(a[ind-1])))

### FIXED CODE ###

import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
ind=bisect.bisect_left(a,0)


if ind==0 :
  print(sum(a))
  
elif ind==n:
  if ind%2==1:
    print(-sum(a)+2*a[-1])
  else:
    print(abs(sum(a)))

elif ind%2==0:

  print(-sum(a[:ind])+sum(a[ind:]))
else:
  print(-sum(a[:ind])+sum(a[ind:])-2*min(abs(a[ind]),abs(a[ind-1])))
n=int(raw_input())
A=map(int, raw_input().split())
q=int(raw_input())
m=map(int, raw_input().split())

def solve(c, m):
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) or solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0, m[i]):
    print "yes"
  else:
    print "no"

### FIXED CODE ###

n=int(raw_input())
A=map(int, raw_input().split())
q=int(raw_input())
m=map(int, raw_input().split())

def solve(j, m):
  if m == 0:
    return 1
  if j >= n or m > sum(A):
    return 0
  res = solve(j + 1, m) or solve(j + 1, m - A[j])
  return res

for i in range(0,q):
  if solve(0,m[i]):
    print "yes"
  else:
    print "no"
from heapq import heappush, heappop

# input
N,M =map(int,input().split())
A = [0]*N
B = [0]*M
C = [0]*M
ans = int(0)

A = list(map(int, input().split()))
A.sort()
for i in range(M):
    B[i],C[i] = list(map(int,input().split()))


def solve():

    pairs = zip(C, B)
    sortedpairs = sorted(pairs, key=lambda x: x[0])
    for i in range(M):
        B[i]=sortedpairs[i][1]
        C[i]=sortedpairs[i][0]

    ansA=[0]*N
    for j in range(N):
        ansA[j] = A[j]
    p = int(0)
    j = int(0)
    while  j<N :
        jd = int(0)
        while  B[M-1-p]-jd>0 :
            if ansA[j]>=C[M-1-p] :
                break
            ansA[j]=C[M-1-p]
            jd +=1
            j +=1
            if j==N : break
        if ansA[j] >= C[M - 1 - p]:
            break
        p +=1

    for j in range(N):
        ans += ansA[j]

    print(ans)

solve()

### FIXED CODE ###

from heapq import heappush, heappop

# input
N,M =map(int,input().split())
A = [0]*N
B = [0]*M
C = [0]*M

A = list(map(int, input().split()))
A.sort()
for i in range(M):
    B[i],C[i] = list(map(int,input().split()))


def solve():

    pairs = zip(C, B)
    sortedpairs = sorted(pairs, key=lambda x: x[0])
    for i in range(M):
        B[i]=sortedpairs[i][1]
        C[i]=sortedpairs[i][0]

    ansA=[0]*N
    for j in range(N):
        ansA[j] = A[j]

    p = int(0)
    j = int(0)
    while  j<N and M>=1+p :
        jd = int(0)
        if ansA[j] >= C[M - 1 - p]:
            break
        while  B[M-1-p]-jd>0 :
            if j==N : break
            if ansA[j]>=C[M-1-p] :
                break
            else:
                ansA[j]=C[M-1-p]
            jd +=1
            j +=1

        p +=1

    ans = int(0)
    for j in range(N):
        ans += ansA[j]

    print(ans)

solve()
n = int(input())
temp = input()
h = temp.split()
for i,item in enumerate(h):
    h[i] = int(item)
dp = [0]

def rec_flog(i):
    if len(dp) > i:
        return dp[i]
    elif i >= 2:
        step1 = abs(h[i] - h[i - 1]) + rec_flog(i-1)
        step2 = abs(h[i] - h[i -2]) + rec_flog(i-2)
        dp.append(step1 if step1 <= step2 else step2)
        return dp[i]
    else :
        dp.append(h[1] - h[0])
        return h[1] - h[0]


print(rec_flog(n-1))




### FIXED CODE ###


n = int(input())
temp = input()
h = temp.split()
for i,item in enumerate(h):
    h[i] = int(item)
dp = [0]
for i,height in enumerate(h):
    if i >=2:
        step1 = dp[i - 1] + abs(height - h[i-1])
        step2 = dp[i-2] + abs(height - h[i-2])
        dp.append(step1 if step1 <= step2 else step2)
    elif i == 1:
        dp.append(abs(height - h[i-1]))

print(dp.pop())
n = int(input())
s = str(input()).split()
alpha_lst = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split()

tmp = [alpha_lst[(int(alpha_lst.index(i))+n)%26] for i in s]

print(''.join(tmp))

### FIXED CODE ###

n = int(input())
s = [i for i in str(input())]
alpha_lst = [i for i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']

tmp = [alpha_lst[(int(alpha_lst.index(i))+n)%26] for i in s]
#tmp = [alpha_lst.index(i) for i in s]
print(''.join(tmp))
N=int(input())
is_ans=0
for i in range(25):
    if is_ans:
        break
    for j in range(14):
        if 4*i+7*j==N:
            is_ans=1
            break
print("Yes" if is_ans else "No")

### FIXED CODE ###

N, K=list(map(int,input().split()))
print(0 if N%K==0 else 1)
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(len(a)):
    count += a.count(a[i])
count /= 2
for i in range(len(a)):
    print(count - a.count(a[i])+1)

### FIXED CODE ###

n, m = map(int, input().split())
result = (n+m)*(n+m-1)//2 - n*m
print(result)
n = input()
for n:
  a[n] = input()

### FIXED CODE ###

import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
from scipy.sparse.csgraph import dijkstra
import numpy as np

n = int(input())
L = np.zeros((n,n),int)
for _ in range(n-1):
    a,b,c = map(int,input().split())
    L[a-1,b-1] = c

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

dist = dijkstra(L,directed = False, indices= k-1).astype(int)

for _ in range(q):
    x,y = map(int,input().split())
    print(dist[x-1] + dist[y-1])

### FIXED CODE ###

from collections import deque

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

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

dist = [float('inf')] * n
visited = [0] * n

dist[k-1] = 0
visited[k-1] = 1
vq = deque([k-1])

while vq:
    
    vs = vq.popleft()
    
    for ve,vc in edge[vs]:
        if visited[ve] == 1: continue
        
        dist[ve] = dist[vs] + vc
        visited[ve] = 1
        vq.append(ve)


for _ in range(q):
    x,y = map(int,input().split())
    print(dist[x-1] + dist[y-1])
r=int(input())
area = r**2*3.14
circle = 2*r*3.14
print(area, circle)

### FIXED CODE ###

import math
r = float(input())
print(r**2*math.pi, 2*r*math.pi)
N, M, Q = map( int, input().split())
NN = [ [ 0 for _ in range(N)] for _ in range(N)]
for _ in range(M):
    L, R = map( int, input().split())
    NN[L-1][R-1] += 1

for i in range(1,N):
    for j in range(1,N):
        NN[j][j+1] += NN[j][j+i-1] + NN[j+1][i+j] - NN[j+1][j+i-1]
for _ in range(Q):
    p, q = map( int, input().split())
    print(NN[p-1][q-1])

### FIXED CODE ###

N, M, Q = map( int, input().split())
NN = [ [0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    L, R = map( int, input().split())
    NN[L][R] += 1

for i in range(1,N+1):
    for j in range(1,N+1):
        NN[i][j] += NN[i][j-1]+NN[i-1][j]-NN[i-1][j-1]
for _ in range(Q):
    p, q = map( int, input().split())
    print(NN[q][q]-NN[q][p-1]-NN[p-1][q]+NN[p-1][p-1])
N = int(input())
adj = [ [] for _ in range(N) ]
for _ in range(N-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  adj[a].append(b)

res = [None] * N
def dfs(n, c=-1, p=-1):
  res[n] = c
  if c==-1 or c>1: 
    nc = 1
  else:
    nc = c+1
  for nei in adj[n]:
    if nei == p: continue
    dfs(nei, nc, n)
    nc += 1
    if nc==c: nc += 1

dfs(0)
res = res[1:]
print(len(set(res)))
for r in res: print(r)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

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

res = [None] * (N-1)
def dfs(n, c=-1, p=-1):
  if c==-1 or c>1: 
    nc = 1
  else:
    nc = c+1
  for nei,i in adj[n]:
    if nei == p: continue
    res[i] = nc
    dfs(nei, nc, n)
    nc += 1
    if nc==c: nc += 1

dfs(0)
print(max(res))
for r in res: print(r)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A,B=[0],[0]
for i in range(n):
    A.append(A[i]+a[i])
for i in range(m):
    B.append(B[i]+b[i])
ans,j=0,m
for i in range(n+1):
    if a[i]>k:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)        


### FIXED CODE ###

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A,B=[0],[0]
for i in range(n):
    A.append(A[i]+a[i])
for i in range(m):
    B.append(B[i]+b[i])
ans,j=0,m
for i in range(n+1):
    if A[i]>k:
        break
    while B[j]>k-A[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, x = na()
x_li = na()
li = []
for i in range(n):
    li.append(abs(x - x_li[i]))
import functools
import math

gcd = functools.reduce(math.gcd, li)
print(gcd)

### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, x = na()
x_li = na()
li = []
for i in range(n):
    li.append(abs(x - x_li[i]))
import fractions

ans = li[0]
for i in range(n):
    ans = fractions.gcd(ans, li[i])
print(ans)
# 検証と認識が甘かった


def solve(A, B):
    _B = round(B * 100)
    print(A * _B // 100)


if __name__ == '__main__':
    A, B = [float(i) for i in input().split()]
    A = int(A)
    sorted(A, B)


### FIXED CODE ###

# 検証と認識が甘かった


def solve(A, B):
    _B = round(B * 100)
    print(A * _B // 100)


if __name__ == '__main__':
    A, B = [float(i) for i in input().split()]
    A = int(A)
    solve(A, B)
from collections import deque
N,M = map(int, input().split())
edges = [[] for _ in range(N)]
c_max = 0
for i in range(M):
	p,q,c = map(int, input().split())
	c_max = max(c, c_max)
	edges[p-1] += [[q-1, c]]
	edges[q-1] += [[p-1, c]]
distance = [[float('inf')]*(c_max+1) for _ in range(N)]
distance[0][0] = 0
Q = deque([[0,0]])


flag = False
while Q:
	s_now,c_now = Q.popleft()
	for t, c in edges[s_now]:
		t_dist = min(distance[t])
		if t_dist > distance[s_now][c_now] + (c_now != c):
			distance[t][c] = distance[s_now][c_now] + (c_now != c)
			if c_now == c:
				Q.appendleft([t, c])
				continue
			Q.append([t, c])
d = min(distance[N-1])
print(d if d != float('inf') else -1)

### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())
F_C_of_S = [{} for i in range(N)]
#Companies of Station
C_of_S = {}

#def Union-find
parent = [-1]*M
def root(x):
	if (parent[x] < 0): return x
	else:
		parent[x] = y = root(parent[x])
		return y

def unite(x, y):
	px = root(x)
	py = root(y)
	if (px == py): return False
	if (parent[px] > parent[py]):
		px = root(y)
		py = root(x)
	parent[px] += parent[py]
	parent[py] = px
	return True


#Union-find
pqcs = []
for i in range(M):
	p, q, c = map(int, input().split())
	p -= 1; q -= 1;
	pqcs += [(p, q, c)]
	
	#The first
	if not c in F_C_of_S[p]: F_C_of_S[p][c] = i
	#else
	else: unite(F_C_of_S[p][c], i)
	C_of_S.setdefault(p, set()).add(c)
	
	#The first
	if not (c in F_C_of_S[q]):F_C_of_S[q][c] = i
	#else
	else: unite(F_C_of_S[q][c], i)
	C_of_S.setdefault(q, set()).add(c)

#stations of company
S_of_C = {}
for i in range(M):
	p, q, c = pqcs[i]
	c_set = S_of_C.setdefault(root(i), set())
	c_set.add(p)
	c_set.add(q)


Q = deque([(0, 0, 0)])
#cost to go to the stations from station_0
dist = [float('inf')]*N
dist[0] = 0

gdist = [float('inf')]*M

while Q:
	cost, v, flag = Q.popleft()
	
	if not (flag):#(flag == 0) then gdist_update
		if (dist[v] < cost) or (v not in C_of_S):
			continue
		for l in F_C_of_S[v].values():
			l = root(l)
			if (cost < gdist[l]):
				gdist[l] = cost
				Q.appendleft((cost, l, 1))
	
	else:#(flag == 1) then dist_update
		if (gdist[v] < cost) or (v not in S_of_C):
			continue
		for s in S_of_C[v]:
			if (cost+1 < dist[s]):
				dist[s] = cost+1
				Q.append((cost+1, s, 0))

print(dist[N - 1] if dist[N - 1] < float('inf') else -1)
# -*- coding: utf-8 -*-

n, k, q =map(int, input().split())
a = []
a.append(map(int, [input() for i in range(q)]))

m = [k]*n

for i in range(a):
  for j in range(n):
    m[j]=m[j]-1
    m[a-1]=m[a-1]+1
  
for i in range(n):
  if m[n]>0:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
 
n, k, q =map(int, input().split())
a = [int(input()) for i in range(q)]

p = [0]*(n+1)

for i in range(q):
  p[a[i]] += 1
  

for i in range(1,n+1):
  if p[i]>q-k:
    print("Yes")
  else:
    print("No")
N = int(input())
print(sum(1,N))

### FIXED CODE ###

n = int(input())
N = int(n*(n+1)/2)
print(N)
n = int(input())
a = [int(i) for i in input().split()]

tmp = a[0]

for i in range(1,n):
  tmp += abs(a[i] - a[i-1])
  
a = [0] + a + [0]

for i in range(1,n+1):
  print(tmp - (abs(a[i] - a[i - 1])) - (abs(a[i] - a[i+1]) + abs(a[i-1] - a[i+1]))
    

### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
a = IR(2)
b = IR(2)
print(min(a)+min(b))
"""

#B
"""
n = I()
d, x = LI()
a = IR(n)
ans = x
for i in a:
    k = 0
    while k * i + 1 <= d:
        ans += 1
        k += 1
print(ans)
"""

#C
n = I()
a = LI()
a.insert(0, 0)
a.append(0)
ans = 0
for i in range(1, n + 2):
    ans += abs(a[i] - a[i - 1])
#print(ans)
for k in range(1, n + 1):
    if a[k - 1] < a[k]:
        if a[k] > a[k + 1]:
            print(ans - 2 * min(abs(a[k] - a[k - 1]), abs(a[k] - a[k + 1])))
        else:
            print(ans)
    if a[k - 1] > a[k]:
        if a[k] < a[k + 1]:
            print(ans - 2 * min(abs(a[k] - a[k - 1]), abs(a[k] - a[k + 1])))
        else:
            print(ans)
    if a[k - 1] == a[k]:
        print(ans)
x = str(input())
if x[n] ==0:
  print(n)

### FIXED CODE ###

print(15 - sum(list(map(int , input().split()))))