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

N = int(input())
S = input()
r = g =  b = 0
for s in S:
    if s == 'R':
        r += 1
    elif s == 'G':
        g += 1
    else:
        b += 1

double = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = (j - i) * 2 + i
        if k >= N:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            double += 1
print(r * g * b - double)

### FIXED CODE ###

N = int(input())
S = input()
r = g =  b = 0
for s in S:
    if s == 'R':
        r += 1
    elif s == 'G':
        g += 1
    else:
        b += 1

double = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = (j - i) * 2 + i
        if k >= N:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            double += 1
print(r * g * b - double)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
setA = list(set(A))
countA = [A.count(a) for a in setA]

for i in range(N):
  ans = 0
  index = setA.index(A[i])

  for i in range(len(setA)):
    if i == index:
      c = countA[i] - 1
    else:
      c = countA[i]
    if c > 1:
      ans += c * (c-1) // 2
  print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
A = list(map(int, input().split()))
countA = Counter(A)
ansA = [v*(v-1)//2 for k,v in countA.items()]
sumA = sum(ansA)

for i in range(N):
  t =  countA[A[i]]
  ans = sumA - t*(t-1)//2 + (t-1)*(t-2)//2
  print(ans)
### BUGGY CODE ###

N, M, P = map(int, input().split())
INF = 10**18

edges = []
E = [[] for _ in range(N)]
R = [[] for _ in range(N)]
for _ in range(M):
    fr, to, c = map(int, input().split())
    fr -= 1
    to -= 1
    edges.append((fr, to, -(c - P)))
    E[fr].append(to)
    R[to].append(fr)

def existsPath(s, edges):
    visited = [False] * N
    visited[s] = True
    st = [s]
    while st:
        now = st.pop()
        for to in edges[now]:
            if visited[to]:
                continue
            st.append(to)
            visited[to] = True
    return visited

canGoFrom1 = existsPath(0, E)
canGoFromN = existsPath(N - 1, R)

minDist = [INF] * N
minDist[0] = 0
for i in range(N):
    for fr, to, c in edges:
        d = minDist[fr] + c
        if minDist[to] > d:
            if i == N - 1 and canGoFrom1[fr] and canGoFromN[to]:
                print('-1')
                exit()
            minDist[to] = d

print(max(0, -minDist[N - 1]))


### FIXED CODE ###

N, M, P = map(int, input().split())
INF = 10**18

edges = []
E = [[] for _ in range(N)]
R = [[] for _ in range(N)]
for _ in range(M):
    fr, to, c = map(int, input().split())
    fr -= 1
    to -= 1
    edges.append((fr, to, -(c - P)))
    E[fr].append(to)
    R[to].append(fr)

def existsPath(s, edges):
    visited = [False] * N
    visited[s] = True
    st = [s]
    while st:
        now = st.pop()
        for to in edges[now]:
            if visited[to]:
                continue
            st.append(to)
            visited[to] = True
    return visited

canGoFrom1 = existsPath(0, E)
canGoFromN = existsPath(N - 1, R)

minDist = [INF] * N
minDist[0] = 0
for i in range(N):
    for fr, to, c in edges:
        d = minDist[fr] + c
        if minDist[to] > d:
            if i == N - 1 and canGoFrom1[fr] and canGoFromN[to]:
                print('-1')
                exit()
            minDist[to] = d

print(max(0, -minDist[N - 1]))
### BUGGY CODE ###


#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    As = [tuple(map(int, input().split())) for _ in range(N-1)]

    m = [[0 for _ in range(N)] for _ in range(N)]
    for a, b in As:
        m[a-1][b-1] = 1
        m[b-1][a-1] = 1

    ans = [[0 for _ in range(N)] for _ in range(N)]

    from collections import deque

    max_c = 1
    l = deque([(0,0)])
    while (len(l)):
        v0, c0 = l.popleft()
        c1 = 1
        for v1 in range(N):
            if m[v0][v1]:
                m[v0][v1] = 0
                m[v1][v0] = 0
                if c1 == c0:
                    c1 += 1
                max_c = max(max_c, c1)
                ans[v0][v1] = c1
                ans[v1][v0] = c1
                l.append((v1, c1))
                c1 += 1

    print(max_c)
    for u, v in As:
        print(ans[u-1][v-1])



# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc146","d",main)


### FIXED CODE ###


#%%
import sys
sys.setrecursionlimit(100000)

def input():
    return sys.stdin.readline().rstrip()

def main():
    N = int(input())

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

    ans = [[None] for _ in range(N-1)]

    def dfs(v0, c0):
        c = 1
        for v1, e in g[v0]:
            if c==c0:
                c += 1
            ans[e] = c
            if v1 < N-1:
                dfs(v1, c)
            c += 1

    dfs(0, 0)

    print(max(ans))
    for c in ans:
        print(c)



# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc146","d",main)
### BUGGY CODE ###

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

# dp用配列
dp=[]
for k in range(N+1):
    dp.append([0]*(W+1))


for i in range(N):
    w_i,v_i = map(int,input().split())
    for w in range(W+1):
        if w>=w_i:
            dp[i+1][w] = max(dp[i][w-w_i] + v_i , dp[i][w])
        else:
            dp[i+1][w] =dp[i][w]

# print(*dp,sep="\n")

print(dp[N][W])
        


### FIXED CODE ###

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

# dp用配列
dp=[]
for k in range(N+1):
    dp.append([0]*(W+1))


for i in range(N):
    w_i,v_i = map(int,input().split())
    for w in range(W+1):
        if w>=w_i:
            dp[i+1][w] = max(dp[i][w-w_i] + v_i , dp[i][w])
        else:
            dp[i+1][w] =dp[i][w]

# print(*dp,sep="\n")

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

n = int(input())
a = list(map(int, input().split()))
m = []
for l in range(n):
    for r in range(l, n):
        b = a[l:r+1]
        m.append(b[len(b)//2])
m.sort()
print(m[len(m)//2])




### FIXED CODE ###

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            #i & -iでLSB(least significant bit/最下位 bit)が求まる
            #区間和はLSBだけ引いていく
            i -= i & -i
        return s

    #a_i(1<=i<=n)にxを加算
    #点に対する更新
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

def invnumber(n, S):
    bit = Bit(2*n+1)
    invs = 0
    for i in range(n):
        s = S[i]+n #BITで扱うため
        invs += bit.sum(s) # #i<j
        bit.add(s, 1)
    return invs

n = int(input())
a = list(map(int, input().split()))
r = max(a)+1
l = 0
c = (n*(n+1)//2+1)//2
while r-l > 1:
    m = (l+r)//2
    S = [0]*(n+1)
    for i in range(1, n+1):
        if a[i-1] >= m:
            S[i] = S[i-1] + 1
        else:
            S[i] = S[i-1] - 1
    if invnumber(n+1, S) >= c:
        l = m
    else:
        r = m
print(l)
### BUGGY CODE ###

N,M=map(int,input().split())
ac=0
wa=0
mydict={}
w=[]
p=[]
for i in range(M):
    P,S=input().split()
    if S=="WA":
        if w.count(P)==0:
            mydict[P]=1
            w.append(P) 
        else:
            mydict[P]=mydict[P]+1
    else:
        if p.count(P)==0:
            ac=ac+1
            p.append(P)
            if w.count(P)!=0:
                wa=wa+mydict[P]
        else:
            pass
print(ac,wa)

        





### FIXED CODE ###

N,M=map(int,input().split())
ac=0
wa=0
a=[0]*N
w=[0]*N
for i in range(M):
    P,S=input().split()
    if S=="WA":
        w[int(P)-1]+=1
    else:
        if a[int(P)-1]==0:
            a[int(P)-1]+=1
            ac=ac+1
            wa+=w[int(P)-1]
        else:
            pass
print(ac,wa)
### BUGGY CODE ###

from collections import defaultdict
import sys

input = sys.stdin.buffer.readline
mod = 10 ** 9 + 7


def modinv(a, mod):
    return pow(a, mod - 2, mod)


# 素因数分解
def prime_factor(n):
    # (素因数, 数)のリストで出てくる
    d = defaultdict(int)
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            d[i] += 1
            n //= i
    if n != 1:
        d[n] += 1
    return list(d.items())


n = int(input())
if n == 1:
    print(1)
    exit()
A = list(map(int, input().split()))
LCM = defaultdict(int)
for i in range(n):
    temp = prime_factor(A[i])
    for key, value in temp:
        t = LCM[key]
        LCM[key] = max(t, value)
lcm = 1
for key, val in LCM.items():
    lcm *= pow(key, val)
ans = 0
for i in range(n):
    gyaku = modinv(A[i], mod)
    ans += lcm * gyaku
    ans %= mod
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
from fractions import gcd
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
def gyaku(a):
    return pow(a,mod-2,mod)
if n==1:
    print(1)
else:
    gya=[0]*(n)
    g=A[0]
    l=A[0]
    gya[0]=gyaku(A[0])
    for i in range(n-1):
        g=gcd(l,A[i+1])
        l*=(A[i+1]//g)
        gya[i+1]=gyaku(A[i+1])
    ans=0
    for i in range(n):
        ans+=l*gya[i]
        ans%=mod
    print(ans)
### BUGGY CODE ###

#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
#if l[i] == l[j]: continue
n = int(input())
a = list(map(int, input().split()))
ans = 0
min = 0

for i in range(len(a) - 1):
    min += a[i]
    num = (sum(a) - min) * a[i]
    ans += num 


print(ans % 1000000007)


### FIXED CODE ###

#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
#if l[i] == l[j]: continue
n = int(input())
a = list(map(int, input().split()))
ans = 0
min = 0
new_list = list(reversed(a))

for i in range(len(new_list) - 1):
    min += new_list[i]
    ans +=  min * new_list[i+1]


print(ans % 1000000007)
### BUGGY CODE ###

n, k = map(int, input().split())
array = list(map(int, input().split()))
dp = [float('inf')]*n
dp[0] = 0
for i in range(1, n):
  for j in range(1, k+1):
    if j > i:
      continue
    dp[i] = min(dp[i-j] + abs(array[i]-array[i-j]), dp[i])
print(dp[-1])

### FIXED CODE ###

import sys
import numpy as np
# inputを高速化する。
input = sys.stdin.readline
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
# dpの配列を作る。
dp = np.zeros(n, dtype=int)
# hの配列を作る。
h = np.array(h)
for i in range(1, n):
    # start は負になることはない。
    start = max(0, i-k)
    # 行列として足し算できるのでforを使う必要がない。
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))
print(dp[n-1])
### BUGGY CODE ###

def main():
    N,W = map(int, input().split())
    w,v = [0]*N,[0]*N
    for i in range(N):
        w[i],v[i] = map(int, input().split())
    # dp[i][w] := 容量をwとして荷物0~iの中から荷物を選んだ時の価値の最大値
    # 初期値dp[0][W] = 0の価値(もし0の重さがMAXを超えるなら選べない)
    dp = [[0]*(W+1) for i in range(N)]
    for x in range(W+1):
        dp[0][x] = 0 if w[0]>x else v[0]
    for i in range(N-1):
        for j in range(W+1):
            if w[i+1]<=j:
                # i+1番目を選ぶ
                dp[i+1][j] = max(dp[i+1][j], (dp[i][j-w[i+1]])+v[i+1])
            # i+1番目を選ばない
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
    print(dp[-1][W])

main()


### FIXED CODE ###

def main():
    N,W = map(int, input().split())
    w,v = [0]*N,[0]*N
    for i in range(N):
        w[i],v[i] = map(int, input().split())
    # dp[i][w] := 容量をwとして荷物0~iの中から荷物を選んだ時の価値の最大値
    # 初期値dp[0][W] = 0の価値(もし0の重さがMAXを超えるなら選べない)
    dp = [[0]*(W+1) for i in range(N)]
    for x in range(W+1):
        dp[0][x] = 0 if w[0]>x else v[0]
    for i in range(N-1):
        for j in range(W+1):
            if w[i+1]<=j:
                # i+1番目を選ぶ
                dp[i+1][j] = max(dp[i+1][j], (dp[i][j-w[i+1]])+v[i+1])
            # i+1番目を選ばない
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
    print(dp[-1][W])

main()
### BUGGY CODE ###

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

a = [0]
a.extend(list(map(int, input().split())))
a1 = []
for i in range(0, len(a)):
    a1.append(0)
step = 1
t = 0
if k<=12:
    for i in range(0, k):
        step = a[step]
    print(step)
else:

    for i in range(0, 10):
        step = a[step]

        step1 = step
    while(True):
        t += 1
        step1 = a[step1]
        if step1 == step:
            break
    result = step
    k = (k-10) % t
    for i in range(0, k):
        result = a[result]

    print(result)


### FIXED CODE ###

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

a = [0] + list(map(int, input().split()))
a1 = [0] * (n+1)

step = 1
start = 0
while(True):
    start += 1
    a1[step] += 1
    step = a[step]
    if a1[step] == 1:
        break
c = step
gap = 0
while(True):
    gap += 1
    step = a[step]
    if step == c:
        break
result = 1
if k > start:
    k = (k-start) % gap
    result = c
for _ in range(k):
    result = a[result]

print(result)
### BUGGY CODE ###

n, q = [int(i) for i in input().split()]
s = input()
hoges = [s[i:i+2] == 'AC' for i in range(n - 1)]
hoges.insert(0, False)
for _ in range(q):
    l, r = [int(i) for i in input().split()]
    print(sum(hoges[l:r]))

### FIXED CODE ###

import sys
from itertools import accumulate


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input().strip()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    hoges = [0] + [1 if s[i : i + 2] == "AC" else 0 for i in range(n - 1)]
    hoges = list(accumulate(hoges))
    for (l, r) in qs:
        print(hoges[r - 1] - hoges[l - 1])


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

import itertools
import heapq
import sys
import functools
import operator
import numpy as np
input = sys.stdin.readline
#-------------
n,k = map(int,input().split())
a = list(map(int,input().split()))
#-------------
b = np.abs(a)
b = sorted(a,reverse = True)
b_k = b[k-1] 
a_new = [a[_] for _ in range(len(a)) if np.abs(a)[_] >= b_k]
a_new.sort()
C=[]
D=[]
for i in range(len(a)):
  for j in range(k):
    C.append(a[i+j-k])
  D.append(C)
  C=[]    
A = (functools.reduce(operator.mul,D[_]) for _ in range(len(D)))
l_max = max(A)
waru = 10**9 + 7
print(l_max % waru)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
### BUGGY CODE ###

from collections import deque

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
d = deque(a)

cnt = 0
while len(d) > 0:
    dd = d.pop()
    flg = 0
    for i in reversed(range(len(d))):
        if d[i] == dd:
            del d[i]
            flg = 1
        elif d[i] % dd == 0:
            del d[i]
    if flg == 0:
        cnt = cnt + 1


print(cnt)

### FIXED CODE ###

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

check = [0]*(a_max+1)

for i in a:
    if check[i] != 0:
        check[i] = 2
        continue
    if check[i] == 0:
        check[i] = 1
        for j in range(1,a_max//i):
            check[(j+1)*i] = 2

print(check.count(1))
### BUGGY CODE ###

import bisect

a,b,q = map(int,input().split())

s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
#x = [int(input()) for i in range(q)]

ans = 10**100

for i in range(q):
    x = int(input())
    ans = 10**100
    s_idx = bisect.bisect_left(s,x)
    t_idx = bisect.bisect_left(t,x)
    s_idx -= 1
    t_idx -= 1
    #print(x[i],s_idx,t_idx)
    for j in range(2):
        for k in range(2):
            ans = min(ans,abs(x - s[min(s_idx+j,a-1)]) + abs(s[min(s_idx+j,a-1)] - t[min(t_idx+k,b-1)]),abs(x - t[min(t_idx+k,b-1)]) + abs(s[min(s_idx+j,a-1)] - t[min(t_idx+k,b-1)]))
            
    print(ans)

### FIXED CODE ###

import bisect

a,b,q = map(int,input().split())

s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
x = [int(input()) for i in range(q)]

ans = 10**100

for i in range(q):
    ans = 10**100
    s_idx = bisect.bisect_left(s,x[i])
    t_idx = bisect.bisect_left(t,x[i])
    s_idx -= 1
    t_idx -= 1
    #print(x[i],s_idx,t_idx)
    for j in range(2):
        for k in range(2):
            ans = min(ans,abs(x[i] - s[min(s_idx+j,a-1)]) + abs(s[min(s_idx+j,a-1)] - t[min(t_idx+k,b-1)]))
            ans = min(ans,abs(x[i] - t[min(t_idx+k,b-1)]) + abs(s[min(s_idx+j,a-1)] - t[min(t_idx+k,b-1)]))
            
    print(ans)
### BUGGY CODE ###

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

res = 0
for a in A:
    res = max(res, A.count(a) + A.count(a+1) + A.count(a-1))


print(res)



### FIXED CODE ###

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

L = [0 for i in range(max(A) + 10)]

for a in A:
    L[a] += 1
    L[a - 1] += 1
    L[a + 1] += 1

print(max(L))
### BUGGY CODE ###

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


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

ans = 0

if s == 3*k:
    ans = 1
elif s > 3*k:
    ans = 0
elif s == k:
    ans = int((k + 1) * (k + 2) / 2)
else:
    l = k
    while l >= 0:
        t_sum = s - l
        m = k
        if t_sum > 2*k:
            break
        if m < k:
            m = k
        while m >= 0:
            n = s - l - m
            if n > k:
                n = k
            if l + m + n < s:
                break
            while n >= 0:
                if l + m + n == s:
                    ans += 1
                if l + m + n < s:
                    break

                n -=1
            m -= 1
        l -= 1

print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Mon Aug  3 13:34:09 2020

@author: ito
"""


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

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

ans = 0

for x in range(k+1):
    for y in range(k+1):
        
        sat_z = s - x - y
        
        if sat_z >= 0 and sat_z <= k:
            ans += 1
            
print(ans)
### BUGGY CODE ###

N = int(input())

ans = [i for i in range(N)]
print(sum(ans))

### FIXED CODE ###

N = int(input())

print(N * (N-1) // 2)
### BUGGY CODE ###

n, m = map(int, input().split())

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

L = []
for i in range(m):
    b,c = map(int, input().split())
    L.append((b,c))
    
A = sorted(A)

from bisect import bisect_left
for l in L:
    tmp0 = l[0]
    tmp1 = l[1]
    A_len = bisect_left(A, tmp1)
    if tmp0 < A_len:
        A = A[tmp0:A_len]+[tmp1] *tmp0+A[A_len:]
    else:
        A = [tmp1] *A_len+A[A_len:]
        
print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

D = {}
for i in range(M):
    b,c = map(int, input().split())
    if c in D:
        D[c] += b
    else:
        D[c] = b
        
for a in A:
    if a in D:
        D[a] += 1
    else:
        D[a] = 1
        
D_sort = sorted(D.items(), reverse=True)
check = 0
ans = 0
for d in D_sort:
    check += d[1]
    if check <= N:
        ans += d[0] * d[1]
    else:
        ans += d[0] * (d[1] - (check - N))
        break
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
for i in range(len(A)-1):
    if A[i+1:].count(A[i]) > 0:
        print ('NO')
        exit (0)
print ('YES')

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
S = set(A)
if len(A) == len(S):
    print ('YES')
else:
    print ('NO')
### BUGGY CODE ###

import math

N = int(input())
A, T = [0 for i in range(N)], [0 for i in range(N)]
T[0], A[0] = map(int, input().split())

for i in range(1, N):
  dt, da = map(int, input().split())
  for j in range(10**9):
    if A[i-1] <= j * da and T[i-1] <= j * dt:
      n = j
      break
      
  T[i], A[i] = dt * n, da * n

print(A[N-1] + T[N-1])

### FIXED CODE ###

import math

N = int(input())
A, T = [0 for i in range(N)], [0 for i in range(N)]
T[0], A[0] = map(int, input().split())

for i in range(1, N):
  dt, da = map(int, input().split())
  for j in range(max(A[i-1]//da, T[i-1]//dt)-1, max(A[i-1]//da, T[i-1]//dt)+3):
    if A[i-1] <= j * da and T[i-1] <= j * dt:
      n = j
      break
      
  T[i], A[i] = dt * n, da * n

print(A[N-1] + T[N-1])
### BUGGY CODE ###

#abc098c

n=int(raw_input())
s=raw_input()
res=float('inf')
for i in xrange(len(s)):
 s1=s[:i]
 s2=s[i+1:]
 res=min(s1.count('W')+s2.count('E'),res)
print res


### FIXED CODE ###

#abc098c

n=int(raw_input())
s=raw_input()
cnt=s[1:].count('E')
res=cnt
for i in xrange(1,n):
 if s[i-1]=='W':
  cnt+=1
 if s[i]=='E':
  cnt-=1
 res=min(cnt,res)
print res
### BUGGY CODE ###

a,b,n = [int(i) for i in input().split()]

ans = [0 for _ in range(b)]

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

print(max(ans))

### FIXED CODE ###

a,b,n = [int(i) for i in input().split()]
 
x = min(n,b-1)
print(a*x // b)
### BUGGY CODE ###

S = input()
Q = int(input())
reverse = 0
for i in range(Q):
  Query = list(input().split())
  if Query[0] == "1":
    reverse = (reverse + 1) % 2
  if Query[0] == "2":
    f = int(Query[1])
    c = Query[2]
    if (f + reverse) % 2 == 1:
      S = c + S
    else:
      S = S + c
 
if reverse == 0:
  print(S)
else:
  print(S[::-1])

### FIXED CODE ###

from collections import deque
S = deque(input())
Q = int(input())
reverse = 0
for i in range(Q):
  Query = list(input().split())
  if Query[0] == "1":
    reverse = (reverse + 1) % 2
  if Query[0] == "2":
    f = int(Query[1])
    c = Query[2]
    if (f + reverse) % 2 == 1:
      S.appendleft(c)
    else:
      S.append(c)

S = "".join(list(S))
 
if reverse == 0:
  print(S)
else:
  print(S[::-1])
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
A = sorted(A, reverse=True)
B = [A.pop(0)]
num = 0
for i in range(N - 1):
    if i % 2 == 0:
        k = A.pop(-1)
    else:
        k = A.pop(0)
    if abs(B[-1] - k) <= abs(B[0] - k):
        num += abs(B[0] - k)
        B = [k] + B
    else:
        num += abs(B[-1] - k)
        B += [k]


print(num)



### FIXED CODE ###

from collections import deque
N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)

A = sorted(A)
q = deque()
q.append(A[0])
i = 1
j = N - 1
mi = True
while i < N and j >= 0 and i <= j:
    if mi:
        p1, p2 = q[0], q[-1]
        q1, q2, q3, q4 = abs(A[j] - p1), abs(A[j] - p2), abs(A[i] - p1), abs(A[i] - p2)
        qm = max(q1, q2, q3, q4)
        if qm == q1:
            q.appendleft(A[j])
            j -= 1
        elif qm == q2:
            q.append(A[j])
            j -= 1
        elif qm == q3:
            q.appendleft(A[i])
            i += 1
        else:
            q.append(A[i])
            i += 1

num = 0
pre = q[0]
for i in range(1, N):
    num += abs(q[i] - pre)
    pre = q[i]

print(num)