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

def main():
    from bisect import bisect_left
    from array import array
    I=10**9+1
    n,*t=open(0)
    n,q=map(int,n.split())
    *d,=map(int,t[n:])
    z=[]
    for t in t[:n]:
        s,t,x=map(int,t.split())
        z.append((x,bisect_left(d,s-x),bisect_left(d,t-x)))
    z.sort(reverse=1)
    N0=2**(q+1).bit_length()
    data=array('I',[I]*2*N0)
    for x,l,r in z:
        L,R=l+N0,r+N0
        while L<R:
            if R&1:
                R-=1
                data[R-1]=x
            if L&1:
                data[L-1]=x
                L+=1
            L>>=1
            R>>=1
    for k in range(q):
        k+=N0-1
        s=I
        while k+1:
            if data[k]<s:s=data[k]
            k=(k-1)//2
        print(-(s==I)or s)
if __name__=='__main__':
    main()

### FIXED CODE ###

def main():
    from bisect import bisect_left
    def update(l,r,v):
        L,R=l+N0,r+N0
        while L<R:
            if R&1:
                R-=1
                data[R-1]=v
            if L&1:
                data[L-1]=v
                L+=1
            L>>=1
            R>>=1
    def query(k):
        k+=N0-1
        s=10**18
        while k+1:
            if data[k]<s:s=data[k]
            k=~-k//2
        return s
    n,*t=open(0)
    n,q=map(int,n.split())
    d=[-10**18]+list(map(int,t[n:]))+[10**18]
    N0=2**(q+1).bit_length()
    data=[10**18]*2*N0
    for x,t,s in sorted(list(map(int,t.split()))[::-1]for t in t[:n])[::-1]:
        l=bisect_left(d,s-x)
        r=bisect_left(d,t-x)
        update(l,r,x)
    for i in range(q):
        a=query(i+1)
        print(-(a==10**18)or a)
if __name__=='__main__':
    main()
### BUGGY CODE ###

n,q = map(int,input().split())
s = input()

for i in range(q):
        t1,t2 = map(int,input().split())
        r1 =s[t1-1:t2]
        print(r1.count("AC"))

### FIXED CODE ###

n,q = map(int,input().split())
s = list(input())
c = 0
t = [0]
for i in range(1,n):
        if s[i] == "C" and s[i-1] == "A":
                c = c + 1
        t.append(c)

for i in range(q):
        t1,t2=map(int,input().split())
        print(t[t2-1]-t[t1-1])
### BUGGY CODE ###

n = int(input())

a = []
s = [0] * n
a.append(input().split())

for i in range(n - 1):
    a[0][i] = int(a[0][i])
    for j in range(n):
        if j == a[0][i]:
            s[j - 1] += 1
            break

for i in range(n):
    print(s[i])


### FIXED CODE ###

n = int(input())

a = []
s = [0] * n
a.append(input().split())

for i in range(n - 1):
    a[0][i] = int(a[0][i])
    s[a[0][i]-1] += 1

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

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

flg = True

s = []



for i in a:
    if i in s:
        flg = False
        break

    s.append(i)


        
if flg:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

def has_duplicates(seq):
    return len(seq) != len(set(seq))


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

flg = has_duplicates(a)

if not flg:
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
l=[1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199]
a=0
b=0
#for i in range(K):
#    b+=
K=int(input())
for i in range(1,K+1):
    if i in l:
        a+=K**2 +(i-1)*(K//i)**2
    else:
        for j in range(1,K+1):
            for r in range(1,K+1):
                a+=gcd(i,j,r)
print(a)

### FIXED CODE ###

import math

a=0

K=int(input())
for i in range(1,K+1):#(1,2,3)
    for j in range(i,K+1):
        for r in range(j,K+1):
            if i==j and i==r:#(1,1,1)のような場合
                a+=math.gcd(i,math.gcd(j,r))
            elif i==j or j==r:#(1,1,2),(1,2,2)のような場合。各3通り
                a+=math.gcd(i,math.gcd(j,r))*3
            else:
                a+=math.gcd(i,math.gcd(j,r))*6
print(a)
### BUGGY CODE ###

def main():
    N, K = map(int, input().split())
    A = [int(i) for i in input().split()]

    test_sum = 1
    for i in A[:K]:
        test_sum *= i


    for i in range(K, N):
        before_sum = test_sum
        test_sum //= A[i - K]
        test_sum *= A[i]

        if test_sum > before_sum:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = [int(i) for i in input().split()]

    for i in range(K, N):
        if A[i] > A[i - K]:
            print("Yes")
        else:
            print("No")


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

from functools import reduce 
from operator import mul
N = int(input())
A = sorted(list(map(int,input().split())),reverse = True)

lim = 10 ** 18
ans = 1

for i in A:
  ans *= i
  if ans > lim and A[-1] > 0:
    ans = -1
    break
    
print(ans)

### FIXED CODE ###

from functools import reduce 
from operator import mul
N = int(input())
A = sorted(list(map(int,input().split())),reverse = True)

lim = 10 ** 18
ans = 1

if A[-1] == 0:
  print(0)
else:
  for i in A:
    ans *= i
    if ans > lim:
      ans = -1
      break
  print(ans)
### BUGGY CODE ###

N=int(input())
s=input().split()
result=1
for i in range (N):
  result=result*int(s[i])
if result<= 10**18:
  print(result)
else:
  print(-1)
  


### FIXED CODE ###

N=int(input())
s=input().split()
result=1
if '0' in s:
  print(0)
else:
  for i in range (N):
    result=result*int(s[i])
    if result> 10**18:
      print(-1)
      break
    elif i==N-1 and result<=10**18:
      print(result)
### BUGGY CODE ###

k,s = map(int,input().split())
ans = 0
for i in range(k+1):
    for l in range(k+1):
        if (s-i-l) >= 0 and (s-i-l) <= k:
            if i+l+(s-i-l) == s:
                ans += 1
print(ans)

### FIXED CODE ###

k,s = map(int,input().split())
ans = 0
for i in range(k+1):
    for l in range(k+1):
        if (s-i-l) >= 0 and (s-i-l) <= k:
            ans += 1
print(ans)
### BUGGY CODE ###

from math import inf
n,h=map(int,input().split())
l=[int(i) for i in input().split()]
dp=[inf]*n
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(2,n):
    dp[i]=min(dp[i-j]+abs(l[i-j]-l[i]) for j in range(1,min(i,h)+1))
print(dp[-1])

### FIXED CODE ###

def main():
    N,K = map(int,input().split())
    h = list(map(int,input().split()))
    INF = 10**10
    DP = [INF]*N
    DP[0] = 0
    DP[1] = abs(h[1]-h[0])
    for i in range(2,N):
        DP[i] = min(DP[i-j] + abs(h[i-j]-h[i]) for j in range(1,min(K,i)+1))
    print(DP[-1])
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n, m = map(int, input().split())
am = [int(input()) for _ in range(m)]

dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    for j in range(i+1, min(n, i+2)+1):
        if j not in am:
            dp[j] += dp[i]
            dp[j] %=1000000007
print(dp[n])


### FIXED CODE ###

n, m = map(int, input().split())
am = [int(input()) for _ in range(m)]
hole = [False]*(n+1)

for i in am:
    hole[i] = True

dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    for j in range(i+1, min(n, i+2)+1):
        if not hole[j]:
            dp[j] += dp[i]
            dp[j] %=1000000007
print(dp[n])
### BUGGY CODE ###

n, k = map(int, input().split())
lr = [list(map(int,input().split())) for _ in range(k)]
s = []
mod = 998244353

for i in range(k):
    l,r = lr[i]
    for j in range(l, r+1):
        s.append(j)

li = [0]*(n+1)
li[0] = 1

for i in range(n):
    for j in s:
        if i+j > n:
            continue
        li[i+j] += li[i]
        li[i+j] %= mod

print(li[n-1])

### FIXED CODE ###

n, k = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(k)]
s = []
mod = 998244353

dp = [0]*(n+1)
dpsum = [0]*(n+1)
dp[1] = 1
dpsum[1] = 1

for i in range(2,n+1):
    for j in lr:
        l, r = j
        li = i-r
        ri = i-l
        if ri < 0:
            continue
        li = max(1,li)
        dp[i] += dpsum[ri]-dpsum[li-1]
        dp[i] %= mod
    dpsum[i] = dpsum[i-1]+dp[i]

print(dp[n])
### BUGGY CODE ###

H,N = map(int,input().split())
Alist = []
Blist = []
for _ in range(N):
    A,B = map(int,input().split())
    Alist.append(A)
    Blist.append(B)

dp = [float('inf')]*(H+1)
dp[0] = 0
for h in range(H+1):
    for n in range(N):
        damage = Alist[n]
        cost = Blist[n]
        first_index = min(h + damage, H)
        dp[first_index] = min(dp[h] + cost, dp[first_index])
        
print(dp[-1])

### FIXED CODE ###

H,N = map(int,input().split())
Alist = []
Blist = []
for _ in range(N):
    A,B = map(int,input().split())
    Alist.append(A)
    Blist.append(B)

dp = [float('inf')]*(H+1)
dp[0] = 0
for h in range(H+1):
    for n in range(N):
        damage = Alist[n]
        cost = Blist[n]
        first_index = min(h + damage, H)
        dp[first_index] = min(dp[h] + cost, dp[first_index])
        
print(dp[-1])
### BUGGY CODE ###

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

adic = {}
bdic = {}
cdic = {}


setabc = list(sorted(list(set(a) | set(b) | set(c))))

setdict = {}
for i in range(len(setabc)):
    setdict.update({setabc[i]:i})
    

for i in range(len(a)):
    if setdict[a[i]] in adic:
        adic[setdict[a[i]]] =  adic[setdict[a[i]]] + 1 
    else:
        adic.update({setdict[a[i]]:1})

for i in range(len(b)):
    if setdict[b[i]] in bdic:
        bdic[setdict[b[i]]] =  bdic[setdict[b[i]]] + 1 
    else:
        bdic.update({setdict[b[i]]:1})

for i in range(len(c)):
    if setdict[c[i]] in cdic:
        cdic[setdict[c[i]]] =  cdic[setdict[c[i]]] + 1 
    else:
        cdic.update({setdict[c[i]]:1})

ami = min(adic.keys())
ama = max(adic.keys())
bmi= min(bdic.keys())
bma= max(bdic.keys())
cmi= min(cdic.keys())
cma= max(cdic.keys())

        
        
summer = 0
for i in range(ami,ama+1):
    if i in adic.keys():
        for j in range(bmi,bma + 1):
            if i < j and j in bdic.keys():
                for k in range(cmi,cma+1):
                    if i< j< k  and k in cdic.keys():
                        summer = summer + adic[i] * bdic[j] * cdic[k] 
                
print(summer)
                
    
            

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split(" ")))
b = list(map(int,input().split(" ")))
c = list(map(int,input().split(" ")))
#アルゴリズムわからないけどN log N?
a.sort()
b.sort()
c.sort()
 
#O(N)?
i,j,k = 0,0,0
ans = 0
while j < N:
  while i < N and a[i]<b[j] :
    i += 1
  while k < N and c[k]<=b[j]:
    k += 1
  ans += i * (N - k)
  j += 1
 

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

n=int(input())
a=list(input().split())
ans=1
for i in a:
    ans=ans*int(i)
if ans>1000000000000000000:
    print(-1)
    exit()
print(ans)

### FIXED CODE ###

n=int(input())
a=list(input().split())
ans=1
f=0
i=0
while(i<n):
    if f==0:
        ans=ans*int(a[i])
    if f==0 and ans>1000000000000000000:
        f=1
    if int(a[i])==0:
        print(0)
        exit()
    i+=1
if f==1:
    print(-1)
    exit()
print(ans)
### BUGGY CODE ###

import functools, fractions

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

gcd_max = 0

for i in range(n):
#  ad = a[:]
  ad = a[:i] + a[i + 1:]
#  if i == 0:
#    ad[0] = ad[1]
#  else:
#    ad[i] = ad[i - 1]
  gcd = functools.reduce(fractions.gcd, ad)
  if gcd > gcd_max:
    gcd_max = gcd

print(gcd_max)

### FIXED CODE ###

from fractions import gcd

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

gcdl = [0] * n
gcdr = gcdl[:]

gcdl[0]  = a[0]
gcdr[-1] = a[-1] 

for i in range(1, n):
  gcdl[i] = gcd(a[i], gcdl[i - 1])

for i in range(n - 2, -1, -1):
  gcdr[i] = gcd(a[i], gcdr[i + 1])

max_gcd = max(gcdl[-2], gcdr[1])

for i in range(1, n - 1):
  temp_gcd = gcd(gcdl[i - 1], gcdr[i + 1])
  if temp_gcd > max_gcd:
    max_gcd = temp_gcd

print(max_gcd)
### BUGGY CODE ###

import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9

    bit = dict()
    for i in range(N):
        bit[i] = dict()
        for j in range(60):
            bit[i][j] = 0
            
    last = A[N-1]
    for j in range(60):
        bit[N-1][j] = last % 2
        last //= 2
    
    ans = 0
    for i in reversed(range(N-1)):
        total = N - 1 - i
        num = A[i]
        for j in range(60):
            if num % 2 == 1:
                ans += (total - bit[i+1][j]) * pow(2, j, mod)
                ans %= mod
            else:
                ans += bit[i+1][j] * pow(2, j, mod)
                ans %= mod
            bit[i][j] = bit[i+1][j]  + (num % 2)
            num //=2
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9

    bit = dict()
    pow_list = dict()
    for j in range(60): 
        bit[j] = 0
        pow_list[j] = pow(2, j, mod)

    first = A[0]
    for j in range(60):
        bit[j] = first % 2
        first //= 2
    
    ans = 0
    for i in range(1, N):
        num = A[i]
        for j in range(60):
            if num % 2 == 1:
                ans += (i - bit[j]) * pow_list[j]
                ans %= mod
            else:
                ans += bit[j] * pow_list[j]
                ans %= mod
            bit[j] += (num % 2)
            num //=2
            
    print(ans)

    return 0

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

#スペース区切りの入力
N, K = (int(x) for x in input().split())
# 型変換
n = abs(N)
k = abs(K)

while n > abs(n - k):
  n = n - k
print(abs(n))

### FIXED CODE ###

#スペース区切りの入力
N, K = (int(x) for x in input().split())
# 変換
n = abs(N)
k = abs(K)

if (n % k) < (k - n % k):
  print(n % k)
else:
  print(k - n % k)
### BUGGY CODE ###

import copy

def check(arr, val):
    for i in arr:
        if not i == val:
            return False
    return True

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

for _ in range(k):
    aa = [0] * n
    for i in range(n):
        aa[max(0, i-a[i])] += 1
        r = i+a[i]+1
        if r < n:
            aa[r] -= 1
    for i in range(1, n):
        aa[i] += aa[i-1]
    a = aa.copy()
    if check(a, n):
        break

for i in a:
    print(i, end=' ')
print()

### FIXED CODE ###

import copy

def check(arr, val):
    for i in arr:
        if not i == val:
            return False
    return True

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

for _ in range(k):
    aa = [0] * n
    for i in range(n):
        aa[max(0, i-a[i])] += 1
        r = i+a[i]+1
        if r < n:
            aa[r] -= 1
    for i in range(1, n):
        aa[i] += aa[i-1]
    a = aa.copy()
    if check(a, n):
        break

for i in a:
    print(i, end=' ')
print()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)

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

memo = []
for i in range(n):
    memo.append([-1]*3)

def dp(i, a):
    if i == 0:
        return action[0][a]
    else:
        memo[i][a] = max(dp(i-1, (a+1)%3), dp(i-1, (a+2)%3)) + action[i][a]
        return memo[i][a]

print(max([dp(n-1,a) for a in range(3)]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

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

memo = []
for i in range(n):
    memo.append([-1]*3)

def dp(i, a):
    if i == 0:
        return action[0][a]
    elif memo[i][a] != -1:
        return memo[i][a]
    else:
        memo[i][a] = max(dp(i-1, (a+1)%3), dp(i-1, (a+2)%3)) + action[i][a]
        return memo[i][a]

print(max([dp(n-1,a) for a in range(3)]))
### BUGGY CODE ###

from itertools import combinations
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())

a = []
for i in range(1, n+1):
    a += [i, i, i]

x = list(set(combinations(a, 3)))

total = 0
for i, j, k in x:
    if i == j and j == k and k == i:
        total += gcd_list([i, j, k])

    elif i != j and j != k and i != k:
        total += 6 * gcd_list([i, j, k])
    
    else:
        total += 3 * gcd_list([i, j, k])
        
print(total)

### FIXED CODE ###

from itertools import combinations
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())

total = 0
for i in range(1, n+1):
    for j in range(i, n+1):
        for k in range(j, n+1):
            if  i == j and j == k and i == k:
                x = 1
            elif i != j and j != k and i != k:
                x = 6
            else:
                x = 3
            
            total += x * gcd_list([i, j, k])
        
print(total)
### BUGGY CODE ###

S = input()
s = len(S)
mod = 10 ** 9 + 7

dp = [[0] * 13 for _ in range(s)]

if S[0] == '?':
    for i in range(10):
        dp[0][i] += 1
else:
    dp[0][int(S[0]) % 13] += 1

for i in range(1, s):
    if S[i] == '?':
        for j in range(13):
            if dp[i - 1][j] == 0:
                continue
            for k in range(10):
                dp[i][(j * 10 + k) % 13] = (dp[i][(j * 10 + k) % 13] + dp[i - 1][j]) % mod
    else:
        for j in range(13):
            dp[i][(j * 10 + int(S[i])) % 13] = (dp[i][(j * 10 + int(S[i])) % 13] + dp[i - 1][j]) % mod

print(dp[-1][5] % mod)

### FIXED CODE ###

def main():
    S = [int(i) if i != '?' else -1 for i in input()]
    s = len(S)
    mod = 10 ** 9 + 7
    dp = [[0] * 13 for _ in range(s)]

    table = [[0] * 10 for _ in range(13)]
    for i in range(13):
        for j in range(10):
            table[i][j] = (i * 10 + j) % 13

    table2 = [[] for _ in range(13)]
    for i in range(13):
        for j in range(10):
            table2[table[i][j]].append(i)
    t = set(range(13))
    table2 = [t - set(i) for i in table2]

    if S[0] == -1:
        for i in range(10):
            dp[0][i] += 1
    else:
        dp[0][S[0] % 13] += 1

    for i in range(1, s):
        if S[i] == -1:
            temp = sum(dp[i - 1])
            for j in range(13):
                dp[i][j] = temp
                for k in table2[j]:
                    dp[i][j] -= dp[i - 1][k]
                dp[i][j] %= mod
        else:
            for j in range(13):
                dp[i][table[j][S[i]]] = dp[i - 1][j]

    print(dp[-1][5] % mod)


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

n = int(input())
bits = {0: 1}
for i in range(n):
    x = int(input())
    if bits.get(x, 0) == 1:
        bits[x] = 0
        print("Yes")
    else:
        y = x
        while y >= 0 and bits.get(y, 0) == 0:
            y -= 1
        if y < 0:
            print("No")
        else:
            bits[y] = 0
            for i in range(y+1, x+1):
                bits[i] = 1
            print("Yes")

### FIXED CODE ###

n = int(input())
bits = set()
c1 = 0
count = 0
ans = []
for i in range(n):
    x = int(input())
    if x in bits:
        y = x
        while c1 < y and y in bits:
            y -= 1
        if y <= c1:
            y = 0
        if y == 0 and count != x:
            c1 = max(x, c1)
            ans.append("No")
        else:
            bits.add(y)
            ans.append("Yes")
            count += 1
            if y == 0:
                if i <= n-2:
                    ans.append("No\n"*(n-2-i) + "No")
                break
            for i in range(y+1, x+1):
                bits.remove(i)
                count -= 1
    else:
        bits.add(x)
        count += 1
        ans.append("Yes")
print("\n".join(ans))
### BUGGY CODE ###

import sys
s= sys.stdin.readline().strip()
mod=10**9+7
n=13
dp=[0]*n
mul=1
dp[0]=1
for c in reversed(s):
  ndp=[0]*n
  if c=='?':
    for k in range(10):
      for j in range(n):
        ndp[(k*mul+j)%n]+=dp[j]
        ndp[(k*mul+j)%n]%=mod
  else:
    k=int(c)
    for j in range(n):
      ndp[(k*mul+j)%n]+=dp[j]
      ndp[(k*mul+j)%n]%=mod
  mul*=10
  mul%=n
  dp=ndp
print(dp[5])


### FIXED CODE ###

M=10**9+7
r=[[(j-k)*9%13for j in range(10)]for k in range(13)]
d=[1]+[0]*12
for c in input():
  d = [sum(d[j]for j in k)%M for k in r] if c>'9' else [d[(int(c)-k)*9%13]for k in range(13)]
print(d[5])
### BUGGY CODE ###

import itertools

n = int(input())
s = input()
s = [i for i in s]

set_ = set(itertools.combinations(s, 3))

print(len(set_))

### FIXED CODE ###

n = int(input())
s = input()
ans = 0

for i in range(1000):
    i = str(i).zfill(3)

    first = s.find(i[0])
    if first == -1:
        continue

    second = s.find(i[1], first+1)
    if second == -1:
        continue

    third = s.find(i[2], second+1)

    if third != -1:
        ans += 1

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

from itertools import combinations
n = int(input())
a = list(map(int,input().split()))
s = list(set(a))
ans = 10**6
if len(s)==1:
    print(n//2)
else:
    for t in combinations(s,2):
        b = 0
        c = 0
        for i in range(n):
            if i%2==0:
                if t[1]!=a[i]:
                    b+=1
                if t[0]!=a[i]:
                    c+=1
            else:
                if t[0]!=a[i]:
                    b+=1
                if t[1]!=a[i]:
                    c+=1
        ans = min(ans,b,c)
    print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
v = list(map(int,input().split()))

if len(set(v)) == 1:
    print(n//2)
else:

    c1 = Counter(v[::2])
    c2 = Counter(v[1::2])
    o = c1.most_common(2)
    e = c2.most_common(2)
    o.append((0,0))
    e.append((0,0))
    if o[0][0] == e[0][0]:
        print(min(n-o[1][1]-e[0][1],n-o[0][1]-e[1][1]))
    else:
        print(n-o[0][1]-e[0][1])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
for _n in range(n):
  sm = 0
  x = 0
  for i,_a in enumerate(a):
    if _n == i: 
      continue
    sm += abs(_a - x)
    x = _a
  sm += abs(x)
  print(sm)

### FIXED CODE ###

n = int(input())
a = [0] + list(map(int, input().split())) + [0]
sm = 0
x = 0
for _a in a:
  sm += abs(_a - x)
  x = _a
for i in range(1,n + 1):
  print(sm - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]))
### BUGGY CODE ###

n=int(input())
print(sum(range(n)))

### FIXED CODE ###

n=int(input())
print(n * (n-1) // 2)
### BUGGY CODE ###

#B - Between a and b ...
a,b,x = map(int, input().split())

if a==b:
    if a%x==0:
        print(1)
    else:
        print(0)
else:
    min_dev = 0
    for i in range(a,b+1):
        if i%x==0:
            min_dev = i
            break

    max_dev = 0
    for i in range(a,b+1)[::-1]:
        if i%x==0:
            max_dev = i
            break

    print((max_dev-min_dev)//x+1)


### FIXED CODE ###

#B - Between a and b ...
import math
a,b,x = map(int, input().split())

if a==b:
    if a%x==0:
        print(1)
    else:
        print(0)
else:
    """
    min_dev = 0
    for i in range(a,b+1):
        if i%x==0:
            min_dev = i
            break
    """
    if a==0:
        min_dev=0
    else:
        min_dev = math.ceil(a/x)

    """
    max_dev = 0
    for i in range(a,b+1)[::-1]:
        if i%x==0:
            max_dev = i
            break
    """
    max_dev = int(b//x)
    print(max_dev-min_dev+1)