Harryxun/stf_run huggingface dataset:
n = int(input())

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

l = [1]

for i in range(1, n):
    b_max1 = 2 * (l[i - 1] - a[i - 1])
    b_max2 = sum(a[i:])

    if b_max1 <= 0:
        l = -1

    l.append(min(b_max1, b_max2))

l.append(a[-1])

print(sum(l))

### FIXED CODE ###

n = int(input())

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

cumsum_a = a.copy()

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

ans = 0
childable_node = 1

for i in range(n + 1):
    if a[i] > childable_node:
        ans = -1
        break

    ans += childable_node

    if i < n:
        b_max1 = 2 * (childable_node - a[i])
        b_max2 = cumsum_a[i + 1]
        childable_node = min(b_max1, b_max2)

print(ans)
from math import gcd

def main():
    K=int(input())
    ans=0
    for a in range(1,K+1):
        for b in range(1,K+1):
            p=gcd(a,b)
            if p==1:
                ans+=p*K
            else:
                for c in range(1,K+1):
                    ans+=gcd(p,c)

print(ans)

### FIXED CODE ###

K = int(input())  #スペース抜きの複数行,１文字ずつ
import math
from functools import reduce

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

A = []
for i in range(1, K + 1):
    for j in range(i, K+1):
        for k in range(j, K + 1):
            if i == j and j == k and k == i:
                #print(i,j,k)
                A.append(gcd_list([i, j, k]))
            elif i != j and j != k and k != i:
                A.append(gcd_list([i, j, k])*6)
            else:
                #print(i,j,k)
                A.append(gcd_list([i, j, k])*3)           

print(sum(A))
from collections import Counter
n = int(input())
XY = [list(map(int,input().split())) for _ in range(n)]
XY.sort(key=lambda x: x[0], reverse=True)
dXY = Counter([])
for i in range(n-1):
    for j in range(1,n):
        dXY += Counter([str(XY[i][0]-XY[j][0])+'_'+str(XY[i][1]-XY[j][1])])
print(n-dXY.most_common()[0][1])

### FIXED CODE ###

from collections import Counter
n = int(input())
XY = [list(map(int,input().split())) for _ in range(n)]
dXY = Counter([])
for i in range(n):
    for j in range(n):
        if i!=j:
            dXY += Counter([str(XY[i][0]-XY[j][0])+'_'+str(XY[i][1]-XY[j][1])])
if n==1:
    print(1)
else:
    print(n-dXY.most_common()[0][1])
N,M=map(int,input().split())

flag=True
ex=[False]*(N)
for i in range(M):
    S,C=map(int,input().split())
    if S>N:
        flag=False
        break
    elif ex[S-1]==False or ex[S-1]==str(C):
        ex[S-1]=str(C)
    else:
        flag=False
        break

if N>1 and ex[0]==0:
    flag=False

if flag:
    for i in range(N-1):
        if ex[i+1]==False:
            ex[i+1]='0'
    if ex[0]==False:
        ex[0]=1
    Ex=''.join(ex)
    print(Ex)
else:
    print(-1)

### FIXED CODE ###

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

flag=True
ex=[False]*(N)
for i in range(M):
    S,C=map(int,input().split())
    if ex[S-1]==False or ex[S-1]==str(C):
        ex[S-1]=str(C)
    else:
        flag=False
        break

if N>1 and ex[0]==str(0):
    flag=False

if flag:
    for i in range(N-1):
        if ex[i+1]==False:
            ex[i+1]='0'
    if ex[0]==False and N>1:
        ex[0]='1'
    elif ex[0]==False:
        ex[0]='0'
    Ex=''.join(ex)
    print(Ex)
else:
    print(-1)
def resolve():
    n=int(input())
    C=sorted([complex(*map(int,input().split())) for _ in range(n)],key=cmath.phase)
    total = sum(C)
    score = 0
    ans = 0
    r=0

    for l in range(n):
        while(r<n and abs(score)<abs(score+C[r])):
            score+=C[r]
            r+=1
        ans=max(ans,abs(score),abs(total-score))
        if r==l:r+=1
        else: score-=C[l]

    print(ans)
resolve()

### FIXED CODE ###

import cmath
import itertools
# cmath.phase:C to (-pi,pi]
n = int(input())
C = sorted([complex(*map(int,input().split())) for _ in range(n)], key=cmath.phase)
score = 0
for i,j in itertools.product(range(n),range(n)):
    if i>j: continue # i+1<=j<=nでループ回すのをサボった
    score = max(score,abs(sum(C[:i]+C[j:])))
    score = max(score,abs(sum(C[i:j])))
print(score)
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
// #MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(int argc, char const *argv[]) {
  float n;
  std::cin >> n;
  std::cout << n*2*M_PI << '\n';
  return 0;
}


### FIXED CODE ###

import math

n = int(input())
print(2*n*math.pi)
s= [i+1 for i in range(13)]
h= [i+1 for i in range(13)]
c= [i+1 for i in range(13)]
d= [i+1 for i in range(13)]

n=input()
while True:
    i=input()
    if i == -1: break
    e,n =i.split()
    if e == 'S':s[int(n)-1]=0
    elif e == 'H':h[int(n)-1]=0
    elif e == 'C':c[int(n)-1]=0
    elif e == 'D':d[int(n)-1]=0

for i in s:
    if i != 0: print('S '+repr(i))
for i in h:
    if i != 0: print('H '+repr(i))
for i in c:
    if i != 0: print('C '+repr(i))
for i in d:
    if i != 0: print('D '+repr(i))

### FIXED CODE ###

s= [i+1 for i in range(13)]
h= [i+1 for i in range(13)]
c= [i+1 for i in range(13)]
d= [i+1 for i in range(13)]
 
n=int(input())
for cnt in range(n):
    e,n =input().split()
    if e == 'S':s[int(n)-1]=0
    elif e == 'H':h[int(n)-1]=0
    elif e == 'C':c[int(n)-1]=0
    elif e == 'D':d[int(n)-1]=0
 
for i in s:
    if i != 0: print('S '+repr(i))
for i in h:
    if i != 0: print('H '+repr(i))
for i in c:
    if i != 0: print('C '+repr(i))
for i in d:
    if i != 0: print('D '+repr(i))
n = input()
x = list(map(int,input().split()))
count = 0
for i in range(1,n):
  if all(x[j]>x[i]) for j in range(0,i-1):
    count+=1
print(count)

### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
count = 1
m = x[0]

for i in range(1,n):
  if m >=x[i]:
    count+=1
    m = x[i]
  
print(count)
x=int(input())
n=[]
for i in range(1,32):
  for j in range(2,10):
    if j**i<x:
      l.append(j**i)
print(max(l))

### FIXED CODE ###

x=int(input())
n=[]
for i in range(1,32):
  for j in range(2,10):
    if i**j<=x:
      n.append(i**j)
print(max(n))
a = int(input())
if a < 1200:
    print("ABC")
elif a < 2800:
    print("ARC")
else a 
    print("AGC")

### FIXED CODE ###

a = int(input())
if a < 1200:
    print("ABC")
elif a < 2800:
    print("ARC")
else:
    print("AGC")
if x = 0:
  print(1)
else:
  print(0)


### FIXED CODE ###

s = int(input()) 
if s == 0:
  print(1)
else:
  print(0)
K = int(input())
l = [1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]

print(l[K])

### FIXED CODE ###

K = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(l[(K-1)])
n=int(input())
a=map(int,input().split())

ans=0
for i in range(n):
  ans+= 1/a[i]

print(1/ans)

### FIXED CODE ###

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

ans=0
for i in range(n):
  ans+= 1/a[i]

print(1/ans)
import functools
import operator

N = int(input())
v = ((map(int, input().split())))
answer = functools.reduce(mul.v)
answer = answer if answer <= 1000000000000000000 else -1
print(answer)

### FIXED CODE ###

N = int(input())
v = list(map(int, input().split()))
limit = 10 ** 18

answer = 1
if 0 in v:
  answer = 0
else:
  for i in v:
    answer = answer * i
    if answer <= limit:
      continue
    else:
      answer = -1
      break
print(answer)
from functools import reduce
from operator import mul
N = int(input())
divide = []
for i in range(2,int( (10**12) ** (1/ 2) ) + 1):
    while( N % i == 0):
        divide.append(i)
        N = int( N/i )
    if N ==1:
        break

i = 0
check = []
while(i < len(divide)-1):
    a = divide[:i+1]
    x = reduce(mul,a)
    b = divide[i+1:]
    y = reduce(mul,b)
    check.append(x + y)
    i += 1
    
ans = min(check) - 2
print(ans)

### FIXED CODE ###

N = int ( input() )
check_list = []
for i in range( 1, int( N**( 1/2 )+1 ) ):
    check = 0
    if N % i == 0:
        check = i + int( N / i ) - 2
        check_list.append(check)

print( min(check_list) )
import math
    def Euclidean(x,y):
        if y == 0:
            return x
        else:
            return Euclidean(y,x%y)
     
    A,B,C,D = [int(x) for x in input().split()]
    count = B - A + 1
    E = Euclidean(C,D)
    F = C*D/E
     
    C_ = math.floor(B/C) - math.floor((A-1)/C)
    D_ = math.floor(B/D) - math.floor((A-1)/D)
    C_and_D = math.floor(B/F) - math.floor((A-1)/F)
    print(count - int(C_ + D_ - C_and_D))

### FIXED CODE ###

import math
def Euclidean(x,y):
    if y == 0:
        return x
    else:
        return Euclidean(y,x%y)

A,B,C,D = [int(x) for x in input().split()]
count = B - A + 1
E = Euclidean(C,D)
F = int(C*D/E)

C_ = B//C - (A-1)//C
D_ = B//D - (A-1)//D
C_and_D = B//F - (A-1)//F
print(count - (C_ + D_ - C_and_D))
A,B = map(int,input().split())
import fractions
def lcm(x,y):
    return (x,y)//fractions.gcd(x,y)
print(lcm(A,B))

### FIXED CODE ###

A,B = map(int,input().split())
import fractions
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)
print(lcm(A,B))
def mergesort(A, left, right):

    if left + 1 < right:
        mid = (left + right)/2
        
        mergesort(A, left, mid)
        mergesort(A, mid, right)
        merge(A, left, mid, right)


def merge(A, left, mid, right):
   
    n1 = mid -left
    n2 = right - mid
    L = []
    R = []
    x = [" "," ", 100000000000000000000]
    for i in range(0, n1):
        L.append(A[left + i])
    for i in range(0, n2):
        R.append(A[mid + i])
    L.append(x)
    R.append(x)
    i = 0
    j = 0
    for k in range(left, right):
        if int(L[i][-1]) <= int(R[j][-1]):
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1
        



# kannsei
def partition(A, p, r):
    x = int(A[r-1][2])
    i = p - 1
    for j in range(p, r-1):
        if int(A[j][2]) <= x:
            i = i + 1
            A[i],A[j]=A[j], A[i]
            
    A[i+1], A[r-1]=A[r-1], A[i+1]
    
    return i+1

def quicksort(A, p, r):
    if p < r-1:
        q = partition(A, p, r)
        
        quicksort(A, p, q)
        quicksort(A, q+1, r)





if __name__ == "__main__":
    num = int(raw_input())
    num_list = []
    num_list1 = []
    for i in range(num):
        num_list.append(raw_input())
    num_list1 = list(num_list)
    quicksort(num_list, 0, len(num_list))
 
    mergesort(num_list1, 0, len(num_list1))
    
    if num_list == num_list1:
        print ("Stable")
    else:
        print ("Not stable")

   print "\n".join(num_list)

### FIXED CODE ###

def mergesort(A, left, right):
 
    if left + 1 < right:
        mid = (left + right)/2
         
        mergesort(A, left, mid)
        mergesort(A, mid, right)
        merge(A, left, mid, right)
 
 
def merge(A, left, mid, right):

    n1 = mid -left
    n2 = right - mid
    L = []
    R = []
    x = "  10000000000"
    for i in range(0, n1):
        L.append(A[left + i])
    for i in range(0, n2):
        R.append(A[mid + i])
    L.append(x)
    R.append(x)
    i = 0
    j = 0
    for k in range(left, right):
        if int(L[i][2:]) <= int(R[j][2:]):
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1
            
            
def partition(A, p, r):
    x = int(A[r-1][2:])
    i = p - 1
    for j in range(p, r-1):
        if int(A[j][2:]) <= x:
            i = i + 1
            A[i],A[j]=A[j], A[i]
             
    A[i+1], A[r-1]=A[r-1], A[i+1]
    return i+1
 
def quicksort(A, p, r):
    if p < r-1:
        q = partition(A, p, r)
         
        quicksort(A, p, q)
        quicksort(A, q+1, r)
 
 
 
 
if __name__ == "__main__":
    num = int(raw_input())
    num_list = []
    num_list1 = []
    for i in range(num):
        num_list.append(raw_input())
    num_list1 = list(num_list)
    quicksort(num_list, 0, len(num_list))
  
    mergesort(num_list1, 0, len(num_list1))
     
    if num_list == num_list1:
        print ("Stable")
    else:
        print ("Not stable")
    print "\n".join(num_list)
str=list(input())
flag=True
if str[0]!='A':
    flag=False
str[0]='a'
cnt=0
for i in range(2,len(str)-1):
    if str[i]=='C':
        cnt+=1
        if cnt==1:
            str[i]='c'
if cnt!=1:
    flag=False

tmp="".join(str)
print(tmp)
if not tmp.islower():
    flag=False

if flag==True:
    print("AC")
else:
    print("WA

### FIXED CODE ###

str=list(input())
flag=True
if str[0]!='A':
    flag=False
str[0]='a'
cnt=0
for i in range(2,len(str)-1):
    if str[i]=='C':
        cnt+=1
        if cnt==1:
            str[i]='c'
if cnt!=1:
    flag=False

tmp="".join(str)
if not tmp.islower():
    flag=False

if flag==True:
    print("AC")
else:
    print("WA")
a, b = map(int, input().split(" ");
print( (a+b) % 24)

### FIXED CODE ###

a, b = map(int, input().split(" "));
print( (a+b) % 24);
N=int(input())
G=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  G[a].append([b,i])

ans=[None]*(N-1)
def dfs(now,color):
  cnt=1
  for to,j in G[now]:
    if cnt==color:
      cnt+=1
    ans[j]=cnt
    dfs(to,cnt)
    cnt+=1
dfs(0,0)
print(max(ans))
print(*ans,sep="\n")

### FIXED CODE ###

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

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

ans=[None]*(N-1)
def dfs(now,color):
  cnt=1
  for to,j in G[now]:
    if cnt==color:
      cnt+=1
    ans[j]=cnt
    dfs(to,cnt)
    cnt+=1

dfs(0,0)
print(max(ans))
print(*ans, sep="\n")
import math


def f(base, n):
    # 10進数 n を, base 進数に変換して各桁を足し合わせる
    lis = []
    while n > 0:
        # print('除', n // base, 'あまり', n % base)
        lis.append(n % base)
        n = n // base
    return sum(lis)


def solve():
    N, S = int(input()), int(input())
    # print(N, S)

    if N == S:
        return N + 1

    for b in range(2, int(math.sqrt(N))):
        if f(b, N) == S:
            return b

    largest = N + 2
    lowest = largest
    for p in range(1, int(math.sqrt(N))):
        buf = (N - S) / p
        if buf.is_integer():
            if f(buf + 1, N) == S:
                b = int(buf + 1)
                lowest = min(lowest, b)

    if not lowest == largest:
        return lowest

    return -1


if __name__ == '__main__':
    res = solve()
    print(res)


### FIXED CODE ###

import math


def f(base, n):
    # 10進数 n を, base 進数に変換して各桁を足し合わせる
    total = 0
    while n > 0:
        # print('除', n // base, 'あまり', n % base)
        total += n % base
        n = n // base
    return total


def solve():
    N, S = int(input()), int(input())
    # print(N, S)

    if N == S:
        return N + 1

    for b in range(2, int(math.sqrt(N)) + 1):
        if f(b, N) == S:
            return b

    largest = N**2
    lowest = largest
    for p in range(1, int(math.sqrt(N)) + 1):
        b = int((N - S) / p + 1)
        if b > 1 and f(b, N) == S:
            lowest = min(lowest, b)

    if not lowest == largest:
        return lowest

    return -1


if __name__ == '__main__':
    res = solve()
    print(res)
class Node:
    def __init__(self, id):
        self.children = []

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

nodes = [Node(i) for i in range(N+1)]
bridges = []
for A, B in (map(int, input().split()) for _ in range(N)):
    nodes[A].children.append(B)


### FIXED CODE ###

class Bridge:
    def __init__(self, nodeA, nodeB):
        self.edges = [BridgeEdge(nodeA, self), BridgeEdge(nodeB, self)]
        nodeA.addEdge(self.edges[1])
        nodeB.addEdge(self.edges[0])
        self.dir = True
        self.vec = None
    def __repr__(self):
        return str((self.vec, self.dir))

class BridgeEdge:
    def __init__(self, node, edge):
        self.edge = edge
        self.node = node
    def another(self):
        return self.edge.edges[1 if self.edge.edges[0] == self else 0]

class Node:
    def __init__(self, id):
        self.id = id
        self.bridges = []
        self.parent = None
        self.judge = True
    def addEdge(self, bridgeEdge):
        self.bridges.append(bridgeEdge)
    def __repr__(self):
        return str((self.id, None if self.parent is None else self.parent.node.id, self.judge))

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

nodes = [Node(i) for i in range(N+1)]
bridges = []
for A, B in (map(int, input().split()) for _ in range(M)):
    bridges.append(Bridge(nodes[A], nodes[B]))

s = [(0, nodes[1])]
idx = 0
while len(s) > 0:
    level, cur = s.pop()

    nxtlevel = level + 1
    for nxt in cur.bridges:
        if nxt.edge.vec is None:
            cur.judge ^= True
            nxt.edge.vec = (cur.id, nxt.node.id)
            if nxt.node.parent is None:
                nxt.node.parent = nxt.another()
                s.append((nxtlevel, nxt.node))

    if len(s) > 0:
        nl = s[-1][0]
    else:
        nl = 1
    while level >= nl:
        if not cur.judge:
            cur.judge ^= True
            cur.parent.node.judge ^= True
            cur.parent.edge.dir ^= True
        level -= 1
        cur = cur.parent.node
  
if all(node.judge for node in nodes[1:]):
    for br in bridges:
        if br.dir:
            print("{} {}".format(br.vec[0], br.vec[1]))
        else:
            print("{} {}".format(br.vec[1], br.vec[0]))
else:
    print("-1")
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
ans = 1
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
    
def lcm(m,n):
    return int(m * n/gcd(m,n))

for j in range(N):
    ans = lcm(ans,T[j])
        
print(ans)

### FIXED CODE ###

from functools import reduce
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def gcd(m,n):
    if n == 0:
        return m
    return gcd(n,m%n)
    
def lcm(m,n):
    return m * n//gcd(m,n)

print(reduce(lcm,T))
from collections import deque
n, m, k = [int(n) for n in input().split()]
A = deque([int(n) for n in input().split()])
B = deque([int(n) for n in input().split()])
dp = [0] * k

t, n = 0, 0
while True:
    a = A[0] if A else None
    b = B[0] if B else None
    if a and a < b:
        d = A.popleft()
    elif b:
        d = B.popleft()
    t += d
    if t > k:
        break
    n += 1
print(n)

### FIXED CODE ###

from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)
from collections import defaultdict
from itertools import product
 
H,W,K = map(int,input().split())
S = [input() for i in range(H)]
 
C = [[int(S[i][k]) for i in range(H)] for k in range(W)]
answer = H*W #出力がこれを超えることはない
for X in product([False,True],repeat = H-1):
  M = [[0]]
  ans = sum(X)
  if ans > answer:#初期値がanswerよりも大きかったら考える必要がない
    continue
  for i,x in enumerate(X):#配列Mの作成
    if x:
      M.append([])
    M[-1].append(i+1)
  D = [0]*len(M)
  for c in C:
    for k,m in enumerate(M):
      D[k] += sum(c[i] for i in m)#k番目の要素に足していく
      #Dにどんどん代入することによってどの列まで足すことができるか算出することができる
    if any(d>K for d in D):#一つでもKを超えていたら
      ans += 1
      if ans >answer:
        break
      D = [sum(c[i] for i in m) for m in M]#超えた行について再び調査
      if any(d>K for d in D):
        ans = answer + 1
        #デフォルトanswerの結果より高い値にしてこの結果が出力にならないように設定する
        break
  answer = min(answer,ans)#あるXに対してanswerを算出(更新)
print(answer)

### FIXED CODE ###

import numpy as np
a = [int(i) for i in list(input().split())]
b = int((a[0]*(a[0]-1) +a[1]*(a[1]-1))/2)

print(b)
def main():
    n, k = map(int, input().split())
    heights = list(map(int, input().split()))

    dp = [float('inf') for i in range(n)]
    dp[0] = 0
    for i in range(1, n):
        dp[i] = min(dp[j] + abs(heights[i] - heights[j]) for j in range(max(i - k, 0), i))
        # for j in range(1, k + 1):
        #     if i - j < 0:
        #         break
        #     dp[i] = min(dp[i], dp[i - j] + abs(heights[i] - heights[i - j]))

    print(dp[n - 1])


if __name__ == '__main__':
    main()
def main():
    n, k = map(int, input().split())
    heights = list(map(int, input().split()))

    dp = [float('inf') for i in range(n)]
    dp[0] = 0
    for i in range(0, n):
        for j in range(1, k + 1):
            if i + j == len(heights):
                break
            dp[i + j] = min(dp[i + j], dp[i] + abs(heights[i] - heights[i + j]))

    print(dp[n - 1])


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    heights = list(map(int, input().split()))

    dp = [float('inf') for i in range(n)]
    dp[0] = 0
    for i in range(1, n):
        dp[i] = min(dp[j] + abs(heights[i] - heights[j]) for j in range(max(i - k, 0), i))
        # for j in range(1, k + 1):
        #     if i - j < 0:
        #         break
        #     dp[i] = min(dp[i], dp[i - j] + abs(heights[i] - heights[i - j]))

    print(dp[n - 1])


if __name__ == '__main__':
    main()
a,b = input().split()
a = int(a)
b = int(b)
print ((a+b) //2 +1))

### FIXED CODE ###

a,b = input().split()
a = int(a)
b = int(b)
print ((a+b+1) //2 )
N = int(input())
if N == 0:
  print(0)
else:
  ans = ''
  flag = False
  while flag == False:
    if N%2 == 0:
      ans = '0'+ans
      N = N/(-2)
    else:
      ans = '1'+ans
      N -= 1
      if N == 0:
        flag = True
      else:
        N = N/(-2)
print(ans)

### FIXED CODE ###

N = int(input())
if N == 0:
  print(0)
else:
  ans = ''
  flag = False
  while flag == False:
    if N%2 == 0:
      ans = '0'+ans
      N = N/(-2)
    else:
      ans = '1'+ans
      N -= 1
      if N == 0:
        flag = True
      else:
        N = N/(-2)
  print(ans)
N = int(input())
prev_num = -1
curr_num = int(input())

max_count = 0
max_ind = -1

curr_count = 0
curr_ind = 0

for itr in range (1,N):
    prev_num = curr_num
    curr_num = int(input())

    if(prev_num >= curr_num):
        curr_count += 1
    else:
        if(max_count<curr_count):
            max_ind = curr_ind
            max_count = curr_count

        curr_ind = itr
        curr_count = 0

if(max_count<curr_count):
    max_count = curr_count
print (max_count)


### FIXED CODE ###

n = int(input())
values = [float(s) for s in input().split(" ")]

start = 0
ans = 0

for i in range(1,n):
    if values[i] > values[i-1]:
        start = i
    ans = max(ans,i-start)
print(ans)