Harryxun/stf_run huggingface dataset:
s=input()
t=input()
if len(t)==1:
  try:
    print(s.index(t)+1)
  except ValueError:
    print(-1)
    exit()
else:
  cd=0
  l=list()
  for _ in list(t):
    l.append([i for i,x in enumerate(list(s)) if x==_])
  try:
    ed=l[0][0]
  except IndexError:
    print(-1)
    exit()
  for i in range(len(t))[1:]:
    k=l[i]
    if k==[]:
      print(-1)
      exit()
    if max(k+[ed])==ed :
      cd+=1
      if i==len(t)-1:
        print((cd)*len(s)+ed+1)
        exit()
      else:
        ed=min(k)
    else:
      ex=list(sorted(k+[ed])).index(ed)
      ed=k[ex]
print((cd)*len(s)+ed+1)

### FIXED CODE ###

def f():
    s,t=input(),input()
    n,m=len(s),len(t)
    table=[[]for i in  range(26)]
    d={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

    for j in range(n):
        table[d[s[j]]].append(j)
    now=0
    ind=0
    if set(list(t))-set(list(s)):print(-1);exit()
    from bisect import bisect_left as bl
    for p in t:
        if ind>table[d[p]][-1]:now+=1;ind=0
        ind=table[d[p]][bl(table[d[p]],ind)]+1

    print(now*n+ind)
if __name__ == "__main__":
    f()
N = int(input())
A = list(map(int,input().split()))
count= 0
while(True):
    exist_odd = False
    for i in range(N):
        if(A[i]%2 != 0):
            exist_odd = True
    if(exist_odd == True):
        break
    for i in range(N):
        A[i] /= 2
    count += 1
print(count)


### FIXED CODE ###

str = input()
counter = 0
for i in range(len(str)):
    if(str[i]=="1"):
        counter += 1
print(counter)
A, B = map(int, input().split())

def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return gcd(a, b%a)

primes = []
for i in range(2, 10**3+10):
    if all(i%p for p in primes):
        primes.append(i)

g = gcd(A, B)
l = [0]*(g+1)
for p in primes:
    if g < p:
        break
    while g%p == 0:
        l[p] = 1
        g //= p
        if g == 1:
            break
    if g == 1:
        break

print(sum(l)+1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

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

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a%b)

g = gcd(A, B)
count = 0
for i in range(2, 10**6+3):
    if g%i == 0:
        count += 1
    while g%i == 0:
        g //= i
if g != 1:
    count += 1

print(count+1)
H, W = map(int, input().split())

pixel = [["."] * H for i in range(W)]

# 入力
for h in range(H):
    pixel[h] = list(input())

# 同じ行を2回繰り返して表示する
for h in range(H):
    print("".join(pixel[h]))

### FIXED CODE ###

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

# 絵を入力
C = [input() for _ in range(H)]
 
# 2回出力
for i in range(H):
    for j in range(2):
        print(C[i])
a, b, c = map(input().split())
if a * c > b:
    print(b//a)
else:
    print(c)


### FIXED CODE ###

a, b, c = map(int, input().split())
if a * c > b:
    print(b//a)
else:
    print(c)
N = int(input())
numbers = [int(x) for x in input().split()]

if any [x == 0 for x in numbers]:
  print(0)
else:
  t = numbers [0]
  for el in numbers:
  	while total < 10**18:
    	t *= el 
  	if t < 10**18:
    	print(t)
    else:
      print(-1)

### FIXED CODE ###

N = int(input())
liste = input().split()
number = [int(x) for x in liste]
total = 1
i = 0
if 0 in number:
    total = 0
else:
    while i < N:
            total *= number[i]
            i = i + 1
            if total > 10**18:
                total = -1
                break
print(total)
n, x = map(int,input().split())
m = []
ans = len(n)
for i in range(n):
    m.append(int(input()))
x -= sum(m)
ans+=(x//min(m))

### FIXED CODE ###

n, x = map(int,input().split())
m = []
ans = n
for i in range(n):
    m.append(int(input()))
x -= sum(m)
ans+=(x//min(m))
print(ans)
import numpy as np

line = input()

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

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

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

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

### FIXED CODE ###

line = input().split()

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

if K % 2 == 0:
    print(A-B)
    
else:
    print(B-A)
import itertools
n=int(input()
a=map(int,input().split())
b=map(int,input().split())
seq=range(n)
list(itertools.permutations(seq))
print(a)
print(list[0])

### FIXED CODE ###

import itertools
n=int(input())
a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
seq=range(1,n+1)
l=list(itertools.permutations(seq))
#print(l[0])

a_num=0
b_num=0
for i in range(len(l)):
  if l[i]==a:
    a_num=i
  if l[i]==b:
    b_num=i

print(abs(a_num-b_num))
import math

from decimal import Decimal, ROUND_HALF_UP
from functools import lru_cache


def quantize(f):
    return int(Decimal(str(f)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))


@lru_cache(maxsize=4096)
def get_cost(x, y):
    return int(math.pow(x - y, 2))


def get_costs(target, numbers):
    return sum([get_cost(target, n) for n in numbers])


def check(n, numbers):
    n_max = max(numbers)
    n_min = min(numbers)
    costs = []
    for n in range(n_min, n_max + 1):
        costs.append(get_costs(target=n, numbers=numbers))

    return min(costs)


def main():
    N = int(input())
    numbers = map(int, input().split())
    print(check(n=N, numbers=numbers))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math

from functools import lru_cache


@lru_cache(maxsize=4096)
def get_cost(x, y):
    return int(math.pow((x - y), 2))


def get_costs(target, numbers):
    return sum([get_cost(target, n) for n in numbers])


def check(n, numbers):
    n_max = max(numbers)
    n_min = min(numbers)
    costs = []
    for target in range(n_min, n_max + 1):
        costs.append(get_costs(target=target, numbers=numbers))

    return min(costs)


def main():
    N = int(input())
    numbers = list(map(int, input().split()))
    print(check(n=N, numbers=numbers))


if __name__ == '__main__':
    main()
N, M, X = map(int,input().split())

CAM = list([list(map(int,input().split())) for i in range(N)])
# print(CAM)
minn = 10**9
b = False
for i in range(2 ** N):
    bag = []
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            bag.append(CAM[j])  # フラグが立っていたら bag に果物を詰める

    s = 0
    x=0
    y=0
    z=0
    for i in range(len(bag)):
      s += bag[i][0]
      x += bag[i][1]
      y += bag[i][2]
      z += bag[i][3]
    if x >= X and y >= X and z >= X:
      minn = min(s,minn)
      b = True

print(minn if b == True else -1)

### FIXED CODE ###

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

CAM = list([list(map(int,input().split())) for i in range(N)])
# print(CAM)
minn = 10**18
b = False

for i in range(2 ** N):
  s = 0
  am = []

  for j in range(N):  # このループが一番のポイント
      if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
        am.append(CAM[j])

  j = False
  sss = [0] * (M+1)
  for kk in range(len(am)):
    s += am[kk][0]
    for m in range(0, M):
      sss[m+1] += am[kk][m+1]
  
  if len([i for i in sss[1:] if i >= X] ) == len(sss[1:]):
    b = True
    minn = min(s,minn)
  
  # print(sss)
  # if x >= X and y >= X and z >= X:
  #   minn = min(s,minn)
  #   b = True

print(minn if b == True else -1)
import sys

input = sys.stdin.readline

s = list(input().rstrip())

lis = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    for j in range(4):
        if (s[i] == lis[j]):
            s[i] = 'う～えす～ぎさ～ん'


ct = 0
ct_lis = []

for i, x in enumerate(s):
    if (x == 'う～えす～ぎさ～ん'):
        ct += 1
    else:
        ct_lis.append([ct])
        ct = 0

print(max(ct_lis)[0])


### FIXED CODE ###

import sys

input = sys.stdin.readline

s = list(input().rstrip())

lis = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    for j in range(4):
        if (s[i] == lis[j]):
            s[i] = 'AYATASO'
            break

ct = 0
ct_lis = []

for i, x in enumerate(s):
    if (x == 'AYATASO'):
        ct += 1
    else:
        ct_lis.append(ct)
        ct = 0

ct_lis.append(ct)

print(max(ct_lis))
#!/usr/bin/env python3
import sys
import math


def factorize(n: int):
    res = []
    for i in range(2, int(n ** 0.5//1 + 2)):
        if n % i:
            continue
        s = 0
        while n % i == 0:
            n /= i
            s += 1
        res.append([i, s])
    return res


def solve(A: int, B: int):
    g = math.gcd(A, B)
    f = factorize(g)
    print(1 + len(f))


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# import math

def solve(A: int, B: int):
    # math.gcd()は3.5から
    # g = math.gcd(A, B)
    g = gcd(A, B)
    f = factorize(g)
    print(1 + len(f))


def gcd(x: int, y: int):
    return gcd(y, x % y) if y else x


def factorize(n: int):
    res = []
    for i in range(2, int(n ** 0.5//1 + 2)):
        if n % i:
            continue
        s = 0
        while n % i == 0:
            n /= i
            s += 1
        res.append([i, s])
    if n != 1:
        res.append([n, 1])
    return res


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()
N= int(input())
    L = list(map(int, input().split()))
    L.sort()
    if sum(L[:-1]) > L[-1]:
      print("Yes")
    else:
      print("No")

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()
if sum(L[:-1]) > L[-1]:
  print("Yes")
else:
  print("No")
n,m,k = map(int, input().split())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))

a_li = [0] + a_li
b_li = [0] + b_li

time = 0
ans = 0
a = 0
temp = 0

a_wa = [0] * (n+10)
b_wa = [0] * (m+10)

s = 0
for i in range(n+1):
    s += a_li[i]
    a_wa[i] = s

s = 0
for i in range(m+1):
    s += b_li[i]
    b_wa[i] = s
    

for i in range(n+1):
    for j in range(min(ans-i, m), m+1):
        time = a_wa[i] + b_wa[j]
        if time <= k:
            ans = max(ans, i+j)
        else:
            break
            
print(ans)

### FIXED CODE ###

n,m,k = map(int, input().split())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))

a_li = [0] + a_li
b_li = [0] + b_li

time = 0
ans = 0
a = 0
temp = 0

a_wa = [0] * (n+10)
b_wa = [0] * (m+10)

s = 0
for i in range(n+1):
    s += a_li[i]
    a_wa[i] = s

s = 0
for i in range(m+1):
    s += b_li[i]
    b_wa[i] = s
    

for i in range(n+1):
    for j in range(max(min(temp-i, m), 0), m+1):
        time = a_wa[i] + b_wa[j]
        if time <= k:
            ans = max(ans, i+j)
            temp = ans
        else:
            break
            
print(ans)
if __name__ == '__main__':
    n = int(input())

    if n < 3:
        print(0)
    else:
        count = 1
        n2=n-1
        for i in range(1,n2):
            count+=n2//i

    print(count)



### FIXED CODE ###


if __name__ == '__main__':
    n = int(input())

    if n == 2:
        print(1)
    else:
        count = 1
        n2=n-1
        for i in range(1,n2):
            count+=n2//i
        print(count)
x=int(input())
p=[100,101,102,103,104,105]
ans=[False]*2001
ans[0]=True
for i in range(2000):
    if ans[i]:
        for j in p:
            if i+j>2000:
                continue
            else:
                ans[i+j]=True
if x>2000:
    print(1)
elif ans(x):
    print(1)
else:
    print(0)


### FIXED CODE ###

x=int(input())
p=[100,101,102,103,104,105]
ans=[False]*2001
ans[0]=True
for i in range(2000):
    if ans[i]:
        for j in p:
            if i+j>2000:
                continue
            else:
                ans[i+j]=True
if x>2000:
    print(1)
elif ans[x]:
    print(1)
else:
    print(0)
a = int(input())
b = int(input())
if b % a == 0:
  print (a + b)
else:
  print (b - a)

### FIXED CODE ###

a, b = map(int, input().split(' '))
if b % a == 0:
  print (a + b)
else:
  print (b - a)
n = int(input())
l = list(input())
l = collections.Counter(list(l))
for i in range (n-1):
    l_temp = list(input())
    l_temp = collections.Counter(list(l_temp))
    l = l & l_temp
print(l)

### FIXED CODE ###

import collections
n = int(input())
l = list(input())
l = collections.Counter(list(l))
for i in range (n-1):
    l_temp = list(input())
    l_temp = collections.Counter(list(l_temp))
    l = l & l_temp
alphabet = [chr(ord('a') + i) for i in range(26)]
ans = []
for i in range (len(alphabet)):
    if l[alphabet[i]]>0:
        ans.extend([alphabet[i]]*l[alphabet[i]])
print(''.join(ans))
h, w=map(int, input().split())
if h == 1 and w ==:
    print(1)
elif w == 1:
    print(1)
elif (h * w) % 2 ==1:
    print(int((h * w //2) + 1))
else:
    print(int(h * w //2))

### FIXED CODE ###

h, w=map(int, input().split())
if h == 1 or w ==1:
    print(1)
elif (h * w) % 2 ==1:
    print(int((h * w //2) + 1))
else:
    print(int(h * w //2))
S = input()
if S.endswith('s'):
  print(S+'es')
else
 print(S+'s')

### FIXED CODE ###

S = input()
if S.endswith('s'):
  print(S+'es')
else:
 print(S+'s')
n, k = map(int,input().split())
x = list(map(int,input().split()))
x.append(0)
x.sort()
ans = 100
for i in range(n-k+1):
    cnt = 0
    cnt += abs(x[i])
    for j in range(i,k+i):
        cnt += abs(x[j+1] - x[j])    
    if cnt < ans:
        ans = cnt

print(min(ans))

### FIXED CODE ###

n, k = map(int,input().split())
x = list(map(int,input().split()))
result = []
for i in range(n-k+1):
    l, r = x[i], x[i+k-1]
    if l * r >= 0:
        result.append(max(abs(l), abs(r)))
    else:
        result.append(abs(2*l-r))
        result.append(abs(2*r-l))
print(min(result))
A , B = map ( int , input ( )  . split( ) )
 
if (A  <= 9 and B <= 9 ):
print ( A * B )
 
else:
print ( -1 )

### FIXED CODE ###

A , B = map ( int , input ( )  . split( ) )
 
if ( A<= 9 and B <= 9) :
    print ( A * B )
else:
    print ( -1 )
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def gcd(x, y):
  b = max(x, y)
  s = min(x, y)
  r = b % s
  while r != 0:
    b = s
    s = r
    r = b % s
  return s

def lcm(x, y):
  return (x * y) // gcd(x,y)

class Inv:
  def __init__(s, mod):
    s.MOD = mod
  def modpow(s, a, n):
    res = 1
    while n > 0:
      if n & 1:
        res = res * a % s.MOD
      a = a * a % s.MOD
      n >>= 1
    return res
  def invx(s, a):
    return s.modpow(a, s.MOD - 2)
  def invL(s, a, n):
    ia = s.invx(a)
    L = [1] * (n + 1)
    for i in range(1, n + 1):
      L[i] = L[i - 1] * ia % s.MOD
    return L

t = lcm(A[0], A[1])
inv = Inv(MOD)
for i in range(2, N):
  t = lcm(t, A[i]) % MOD

ans = 0
for i in range(N):
  ans = (ans + t * inv.invx(A[i])) % MOD
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

if N == 1:
  print(1)
  exit()

import math
def prime(x):
  p = {}
  cnt = 2
  Flag = True
  while Flag:
    last = math.ceil(x ** 0.5) 
    if cnt > last:
      break
    for i in range(cnt, last + 1):
      if x % i == 0:
        x //= i
        p[i] = 1
        cnt = i + 2
        while x % i == 0:
          x //= i
          p[i] += 1
        cnt = i + 1
        break
      if i == last:
        Flag = False
  if x != 1:
    p[x] = 1
  return p


class Inv:
  def __init__(s, mod):
    s.MOD = mod
  def modpow(s, a, n):
    res = 1
    while n > 0:
      if n & 1:
        res = res * a % s.MOD
      a = a * a % s.MOD
      n >>= 1
    return res
  def invx(s, a):
    return s.modpow(a, s.MOD - 2)
  def invL(s, a, n):
    ia = s.invx(a)
    L = [1] * (n + 1)
    for i in range(1, n + 1):
      L[i] = L[i - 1] * ia % s.MOD
    return L

p = prime(A[0])

for i in range(1, N):
  q = prime(A[i])
  for n in q:
    if n in p:
      p[n] = max(p[n], q[n])
    else:
      p[n] = q[n]

inv = Inv(MOD)
t = 1
for n in p:
  t = t * inv.modpow(n, p[n]) % MOD

ans = 0
for i in range(N):
  ans = (ans + t * inv.invx(A[i])) % MOD
print(ans)
n, k = map(int,input().split())
h = list(map(int,input().split()))
inf = float("inf")
dp = [inf]*(n+1)
if n == 2:
    print(abs(h[1]-h[0]))
    sys.exit()

for i in range(1, k+1):
    dp[i] = abs(h[i]-h[0])

for i in range(2,n):
    for j in range(k+1):
        dp[i] = min(abs(h[i]-h[i-j])+dp[i-j], dp[i])

print(dp[n-1]) 

### FIXED CODE ###

n, k = map(int,input().split())
h = list(map(int,input().split()))
inf = float("inf")
dp = [0]+[inf]*(n-1)

for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(abs(h[i]-h[j])+dp[j], dp[i])

print(dp[n-1])
visit_list = []


def topological_sort():
    for s in range(n):
        if color[s] == 0:
            dfs(s)

def dfs(u):
    color[u] = 1
    for v in graph[u]:
        if color[v] == 0:
            dfs(v)
    visit_list.append(u)        
 
 
n = int(input())
color = [0] * n
graph = [[] * n for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    graph[a].append(b)
    graph[b].append(a)    

topological_sort()
c = [int(i) for i in input().split()]
c.sort()
t_list = [[visit_list[i], str(c[i])] for i in range(n)]
t_list.sort()
print(sum(c) - c[-1])
print(" ".join(list(map(lambda x: x[1], t_list))))

### FIXED CODE ###

n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
c = [int(i) for i in input().split()]
c.sort()
c.reverse()
ans_list = [0 for _ in range(n)]
ans = 0
p_list = [0]
ans_list[0] = c.pop(0)
while len(p_list) > 0:
    p = p_list.pop(0)
    for g in graph[p]:
        if ans_list[g] == 0:
            ans_list[g] = c.pop(0)
            ans += ans_list[g]
            p_list.append(g)
print(ans)
print(' '.join([str(i) for i in ans_list]))
import heapq
from itertools import permutations
n, m, r = map(int, input().split())
R = list(map(lambda x: int(x)-1, input().split()))
edges = [[]for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    edges[a].append((c, b-1))
    edges[b].append((c, a-1))


def dijkstra(init_v):
    next_v = [(0, init_v)]
    INF = 10**18
    dist = [INF]*n
    dist[init_v] = 0
    while next_v:
        d, v = heapq.heappop(next_v)
        if dist[v] < d:
            continue
        for d, v2 in edges[v]:
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            heapq.heappush(next_v, (dist[v2], v2))
    return dist


dists = []
for x in R:
    dist = dijkstra(x)
    dists.append(dist)

INF = 10**18
ans = INF
for subset in permutations(range(r)):
    d = 0
    for v, v2 in zip(subset, subset[1:]):
        d += dists[v][R[v2]]
    if d < ans:
        ans = d

print(ans)


### FIXED CODE ###

import heapq
from itertools import permutations
n, m, r = map(int, input().split())
R = list(map(lambda x: int(x)-1, input().split()))
edges = [[]for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append((c, b))
    edges[b].append((c, a))


def dijkstra(init_v):
    next_v = [(0, init_v)]
    INF = 10**18
    dist = [INF]*n
    dist[init_v] = 0
    while next_v:
        d, v = heapq.heappop(next_v)
        if dist[v] < d:
            continue
        for d, v2 in edges[v]:
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            heapq.heappush(next_v, (dist[v2], v2))
    return dist


dists = []
for x in R:
    dist = dijkstra(x)
    dists.append(dist)

INF = 10**18
ans = INF
for subset in permutations(range(r)):
    d = 0
    for v, v2 in zip(subset, subset[1:]):
        d += dists[v][R[v2]]
    if d < ans:
        ans = d

print(ans)
def main():
    n = int(input())
    a = list(map(int, input().split()))

    def dp(i, j):
        if i == 0 and j == 0:
            return 0
        if i == 0 and j == 1:
            return -float('inf')
        if j == 0:
            return max(dp(i - 1, 0) + a[i - 1], dp(i - 1, 1) - a[i - 1])
        if j == 1:
            return max(dp(i - 1, 0) - a[i - 1], dp(i - 1, 1) + a[i - 1])

    score = dp(n, 0)

    print(score)


main()

### FIXED CODE ###

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

    pos = [0] * n
    neg = [0] * n

    pos[0] = aa[0]
    neg[0] = -aa[0]

    for i, a in enumerate(aa[1:-1], start=1):
        pos[i] = max(pos[i - 1] + a, neg[i - 1] - a)
        neg[i] = max(pos[i - 1] - a, neg[i - 1] + a)

    pos[n - 1] = pos[n - 2] + aa[n - 1]
    neg[n - 1] = neg[n - 2] - aa[n - 1]

    score = max(pos[n - 1], neg[n - 1])

    print(score)


main()
#min
minsum=0
for i in range(n):
    if n-(i+1)>=k-1:
        minsum+=(a[i] * comb(n-i-1,k-1))%M
        minsum%=M
b=sorted(a,reverse=True)
#max
maxsum=0
for i in range(n):
    if n-(i+1)>=k-1:
        maxsum+=(b[i] * comb(n-i-1,k-1))%M
        maxsum%=M
print((maxsum-minsum)%M)

### FIXED CODE ###

c=input()
print(chr(ord(c)+1))
a,b = map(int, raw_input().split)
gA = []
gb = []
for i in range(a):
    gA.append(map(int, raw_input().split()))
for i in range(b):
    gb.append(input())
for i in range(a):
    ans = 0
    for j in range(b):
        ans += gA[i][j] * gb[j]
    print ans

### FIXED CODE ###

m,n = map(int, raw_input().split())
a = []
b = []
for i in range(m):
    a.append(map(int, raw_input().split()))
for i in range(n):
    b.append(input())
for i in range(m):
    ans = 0
    for j in range(n):
        ans += a[i][j] * b[j]
    print ans
s = input()

count = 0

def str_del(str,index):
    str = str[:index]+str[index+1:]
    return str

def remove_cube(string):
  for i in range(0, len(string)):
    print(len(string))
    if i+1 >= len(string):
      return string
    elif string[i] != string[i+1]:
      string = str_del(string, i)
      string = str_del(string, i)
      return string

string = s
can_remove = True
while can_remove:
  removed = remove_cube(string)
  if removed != string:
    string = removed
    count += 2
    can_remove = True
  else:
    can_remove = False

print(count)


### FIXED CODE ###

s = input()

count0 = s.count('0')
count1 = s.count('1')
print(min(count0, count1) * 2)
N = int(input())
A = []#生徒たちが出席した順番
rev = [0]*N #早く来た順の生徒の番号

i = 0
for x in input().split():
    i += 1
    A.append(int(x))
    students.append(int(i))

for i in range(N):
    rev[A[i]-1] = i + 1

print(' '.join(map(str,rev)))

### FIXED CODE ###

N = int(input())
A = []#生徒たちが出席した順番
rev = [0]*N #早く来た順の生徒の番号

for x in input().split():
    A.append(int(x))

for i in range(N):
    rev[A[i]-1] = i+1

print(' '.join(map(str,rev)))