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

N = int(input())
A = []
# input
for i in range(N):
  A.append(int(input()))
  
max_A = max(A)
# output
for i in range(N):
  if A[i] < max_A:
    print(max_A)
  else:
    tmp = A.copy();
    tmp.remove(A[i]);
    print(max(tmp))

### FIXED CODE ###

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

tmp = A.copy();
tmp.sort()
max1_A = tmp[-1];
max2_A = tmp[-2];
max_count = A.count(max1_A);

# 最大値が複数ある場合
if max_count > 1:
  for i in range(N):
    print(max1_A)
# 最大値が1つある場合
else:
  for i in range(N):
    if A[i] < max1_A:
      print(max1_A)
    else:
      print(max2_A)
      break
  for j in range(i+1,N):
    print(max1_A)
### BUGGY CODE ###

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

for i,j in zip(x,range(n)):
    x.remove(i)
    t = sorted(x)
    print(t[int(n/2-1)])
    x.insert(j,i)

### FIXED CODE ###

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

s = sorted(x)
u = s[int(n/2)]
t =s[int(n/2-1)]

for i in (x):
    if i < u:
        print(u)
    else:
        print(t)
### BUGGY CODE ###

N,M=[int(i) for i in input().split()]
a=M//N
A=[]
for i in range(1,a+1):
    if M%i==0:
        A.append(i)
    else:
        continue
print(max(A))

### FIXED CODE ###

import math
A=[]
N,M=[int(i) for i in input().split()]
sqrt=math.sqrt(M)
for i in range(1,int(sqrt)+1):
    if M%i==0:
        A.append(i)
        A.append(M//i)
ans=[1]
for i in A:
    if i*N<=M:
        ans.append(i)
    else:
        continue
print(max(ans))
### BUGGY CODE ###

s_l = list(input())

ans = 0
for i in range(len(s_l)-1):
    for j in range(i,len(s_l)):
        val = int(''.join(s_l[i:j+1]))
        if val%2019 == 0 and val != 0:
            ans += 1

print(ans)

### FIXED CODE ###

s_l = list(input())
n = len(s_l)

# 公式解説参照
dp_dict = {0:1}
t = 0
for i in range(n):
    a = int(s_l[-(i+1)])
    t = (t + a*(pow(10,i,2019)))%2019
    dp_dict[t] = dp_dict.get(t,0) + 1

ans = 0
for val in dp_dict.values():
    ans += val*(val-1)//2

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

from bisect import bisect_left
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

D.sort()
T.sort()

ans = 'YES'

for t in T:
  b = bisect_left(D,t)
  if D[b] != t:
    ans = 'NO'
    break
  else:
    D.pop(b)
    D = D[b:]

print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

CD = Counter(D)
CT = Counter(T)
ans = CT - CD

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

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

for i in range(K):
    if A != 0:
        A -= 1
    elif B != 0:
        B -= 1
    else:
        pass

print("{} {}".format(A,B))

### FIXED CODE ###

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

if A <= K :
    K -= A
    A = 0
    if B <= K :
        K -= B
        B = 0
    else:
        B -= K
else:
    A -= K

print("{} {}".format(A,B))
### BUGGY CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [(p+1)/2 for p in P]
def s(i):
    return sum(P[:i])

S = []
for i in range(N+1):
    S.append(s(i))
B = []
for j in range(N-K+1):
    B.append(S[j+K]-S[j])
ans = max(B)
print(ans)
    



### FIXED CODE ###

from itertools import accumulate
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [0]+[(p+1)/2 for p in P]
S = list(accumulate(P))
B = []
for j in range(N-K+1):
    B.append(S[j+K]-S[j])
ans = max(B)
print(ans)
### BUGGY CODE ###

from collections import defaultdict

n, s = map(int, input().split())
aa = tuple(sorted(map(int, input().split())))

MOD = 998244353
dp = [[0 for i in range(s + 1)] for j in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(s + 1):
        # 選ばない場合
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= MOD

        # j + a[i]を選んだ場合
        if j + aa[i] <= s:
            dp[i + 1][j + aa[i]] += dp[i][j]
            dp[i + 1][j + aa[i]] %= MOD
print(dp[n][s])

### FIXED CODE ###

from collections import defaultdict

n, s = map(int, input().split())
aa = tuple(sorted(map(int, input().split())))

MOD = 998244353
dp = [[0 for i in range(s + 1)] for j in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(s + 1):
        # 選ばない場合
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= MOD

        # j + a[i]を選んだ場合
        if j + aa[i] <= s:
            dp[i + 1][j + aa[i]] += dp[i][j]
            dp[i + 1][j + aa[i]] %= MOD
print(dp[n][s])
### BUGGY CODE ###

N = int(input())

import numpy as np
def num_withdraw_dp(N):
    dp = np.full(N + 1, N, dtype='int')
    dp[0] = 0
    for n in range(1, N+1):
        dp[n] = min(dp[n], dp[n - 1] + 1)
        coin = 6
        while coin <= N:
            dp[n] = min(dp[n], dp[n - coin] + 1)
            coin *= 6
        coin = 9
        while coin <= N:
            dp[n] = min(dp[n], dp[n - coin] + 1)
            coin *= 9
    return dp[N]

print(num_withdraw_dp(N))

### FIXED CODE ###

N = int(input())

def num_withdraw_l(N):
    dp = [N] * (N + 1)
    dp[0] = 0
    for n in range(1, N+1):
        dp[n] = min(dp[n], dp[n - 1] + 1)
        coin = 6
        while coin <= N:
            dp[n] = min(dp[n], dp[n - coin] + 1)
            coin *= 6
        coin = 9
        while coin <= N:
            dp[n] = min(dp[n], dp[n - coin] + 1)
            coin *= 9
    return dp[N]

print(num_withdraw_l(N))
### BUGGY CODE ###

def prm(a):
  if a==1:
    return False
  for i in range(2,int(a**0.5+1)):
    if a%i==0:
      return False
  else:
    return True
x=int(input())
d=[1]*(x+1)
for i in range(1,x+1):
  if prm(i):
    d[i]+=1
  else:
    while not prm(i):
      for j in range(2,i):
        if i%j==0:
          d[j]+=1
          i=i//j
          break
ans=0
for i in range(x+1):
  ans = ans * d[i] % (10**9+7)
print(ans)

### FIXED CODE ###

def prm(a):
  if a==1 or a == 4:
    return False
  for i in range(2,int(a**0.5+1)):
    if a%i==0:
      return False
  else:
    return True
x=int(input())
d=[1]*(x+1)
for i in range(1,x+1):
  if prm(i):
    d[i]+=1
  else:
    while not prm(i) and i != 1:
      for j in range(2,i):
        if i%j==0:
          d[j]+=1
          i=i//j
          break
    if i!= 1:
      d[i]+=1
ans=1

for i in range(x+1):
  ans = ans * d[i] % (10**9+7)
print(ans)
### BUGGY CODE ###

x, k, d = map(int, input().split())
mind = 1000000000000000
c = 0
while k > 0:
    k -= 1
    if abs(x - d - 0) <= abs(x + d - 0):
        x -= d
    else:
        x += d
    if x == mind:
        break
    mind = min(mind, abs(x))

if k%2 == 0 or k == 0:
    print(abs(mind - 0))
else:
    mind = min(abs(mind + d - 0), abs(mind - d - 0))
    print(mind)
    

### FIXED CODE ###

x, k, d = map(int, input().split())
x = abs(x)
if (x - k*d) >= 0:
    x -= k*d
else:
    k -= int(x/d)
    x -= int(x/d) * d
    if (k%2) != 0:
        x -= d 
print(abs(x))
### BUGGY CODE ###

#coding:utf-8

k = int(input())
count = 0

def gcd(a,b):
    if a >= b:
        k1, k2 = a, b
    elif a < b:
        k1, k2 = b, a

    r = k1 % k2
    if r != 0:
        return gcd(k2,r)
    elif r == 0:
        return k2

for a in range(1,k+1):

    for b in range(1,k+1):

        f = gcd(a,b)

        for c in range(1,k+1):

            g = gcd(f,c)
            count += g

print("{}".format(count))

### FIXED CODE ###

#coding:utf-8

k = int(input())
count = 0

def gcd(a,b):
    if a >= b:
        k1, k2 = a, b
    elif a < b:
        k1, k2 = b, a

    r = k1 % k2
    if r != 0:
        return gcd(k2,r)
    elif r == 0:
        return k2

for a in range(1,k+1):

    for b in range(1,a+1):

        f = gcd(a,b)

        for c in range(1,b+1):

            g = gcd(f,c)
            
            if a == b and b != c:
                count += g * 3
            elif b == c and c != a:
                count += g * 3
            elif c == a and a != b:
                count += g * 3
            elif a == b and b == c:
                count += g
            else:
                count += g * 6

print("{}".format(count))
### BUGGY CODE ###

import numpy as np

n,m = map(int, input().split())
from_start = np.array([])
to_end = np.array([])

for _ in range(m):
  temp = []
  temp = list(map(int, input().split()))
  if temp[0]==1:
    from_start = np.append(from_start, temp[1])
  elif temp[1]==n:
    to_end = np.append(to_end, temp[0])

  if from_start in to_end:
    print('POSSIBLE')
    break
else:
  print('IMPOSSIBLE')


### FIXED CODE ###

n,m = map(int, input().split())
set_a = set()
set_b = set()
AB = [list(int(x) for x in input().split()) for _ in range(m)]


for a,b in AB:
  if a > b:
    a,b = b,a
  
  if a == 1:
    set_a.add(b)
  if b == n:
    set_b.add(a)

se = set_a & set_b
print('POSSIBLE' if se else 'IMPOSSIBLE')
### BUGGY CODE ###


import heapq
import collections
N =  int(input())
nums = list(map(int,input().split(" ")))
keta = [0] * 61
# ある桁の1の出現回数
# keta[k] → 2**k の桁
jijou = [1]
MOD = 10 ** 9 + 7
for i in range(60):
    temp = jijou[i] * 2
    temp%= MOD
    jijou.append(temp)

for num in nums:
    s = format(num,"b")
    l = len(s)
    for i in range(0,l):
        keta[i] += int(s[l - i - 1 ])
ans = 0
for j,num in  enumerate(nums[:-1]):
    s = format(num, "b")
    l = len(s)
    for i in range(0,61): #i →  2 ** i 乗 桁目に対応
        if l <= i:
            ans += (keta[i] * jijou[i]) % MOD
        else:
            if s[l - i - 1 ] == "0":
                ans += (keta[i] * jijou[i]) % MOD
            else:
#              (N - j + 1) - (keta[i] + 1 ) → 0が経っているところの個数
                ans += (( (N - j + 1) - (keta[i] + 1)  ) * ( jijou[i]) ) % MOD
                keta[i] -= 1
        ans %= MOD
    ans %= MOD


print(ans)

### FIXED CODE ###


import heapq
import collections
import math
import sys
N =  int(input())
input = sys.stdin.readline
# num = a << b →  a  * (2 ** b)
# 1 << i → i桁目のマスク
# mask = 1 << i
# num = a << b
# num & mask


#
nums = list(map(int,input().split(" ")))
keta = [0] * 62
# ある桁の1の出現回数
# keta[k] → 2**k の桁
jijou = []
MOD = 10 ** 9 + 7


for num in nums:
    s = format(num,"b")
    l = len(s)

    for i in range(0,l):
        if s[l - i - 1 ] == "1":
            keta[i] += 1

ans = 0
temp = 1
for i in range(62):

    ans += ( keta[i] * (N - keta[i])) * temp
    ans %= MOD
    temp *= 2
    temp %= MOD
print(ans)
### BUGGY CODE ###

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

dp = [1e9 for _ in range(2**n)]
#dp[status]
# status : c1c2c3...を開けることができる=1としたときの2進⇒10進数(maxは1がnこ並ぶから2**n -1)
dp[0] = 0
for i in range(1,m+1):
  a, _ = list(map(int,input().split()))
  C = list(map(int,input().split()))
  s = sum([2**(c-1) for c in C]) ## 内包forできれいに書いてる
  for j in range(2**n): ## ひとつ前のステータスを総当たりでいく
    dp[j|s] = min(dp[j|s], dp[j] + a)  ## このorの書き方が美しいのか

ans = dp[2**n-1] # 全部のカギを使ったときのstatusがすべて1の時
print(ans if ans < 1e9 else -1)

### FIXED CODE ###

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

dp = [1e9 for _ in range(2**n)]
#dp[status]
# status : c1c2c3...を開けることができる=1としたときの2進⇒10進数(maxは1がnこ並ぶから2**n -1)
dp[0] = 0
for i in range(1,m+1):
  a, _ = list(map(int,input().split()))
  C = list(map(int,input().split()))
  s = sum([2**(c-1) for c in C]) ## 内包forできれいに書いてる
  for j in range(2**n): ## ひとつ前のステータスを総当たりでいく
    dp[j|s] = min(dp[j|s], dp[j] + a)  ## このorの書き方が美しいのか

ans = dp[2**n-1] # 全部のカギを使ったときのstatusがすべて1の時
print(ans if ans < 1e9 else -1)
### BUGGY CODE ###

def prime_factorize(n):
    """Calculate prime factorization and return unique numbers and 1.
    """
    ans = set()
    ans_add = ans.add
    ans_add(1)
    while n % 2 == 0:
        ans_add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            ans_add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        ans_add(n)
    return ans


def main():
    x = int(input())
    # 素因数分解してユニークな因数を取る。
    insu = prime_factorize(x)
    # a^5 - b^5 も a - b も，ある因数の倍数となる。
    # ここは a >= b と仮定すると，a は正でなくてはならない。

    # a は足す一方なので，
    b_min = -int(x ** (1 / 5))
    for n in insu:
        b = b_min
        while 1:
            a = b
            while 1:
                a += n
                if a < 0:
                    continue
                cand = a ** 5 - b ** 5
                if cand == x:
                    return f'{a} {b}'
                elif cand > x:
                    break
            b += 1


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

def prime_factorize(n):
    """Calculate prime factorization and return unique numbers and 1.
    """
    ans = set()
    ans_add = ans.add
    ans_add(1)
    while n % 2 == 0:
        ans_add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            ans_add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        ans_add(n)
    return ans


def main():
    x = int(input())
    # 素因数分解してユニークな因数を取る。
    insu = prime_factorize(x)
    # a^5 - b^5 も a - b も，ある因数の倍数となる。
    # ここは a >= b と仮定すると，a は正でなくては，xが負になっちゃう。

    b_min = -int(x ** (1 / 5))
    for n in insu:
        b = b_min
        while 1:
            a = b
            while 1:
                a += n
                if a < 0:
                    continue
                cand = a ** 5 - b ** 5
                if cand == x:
                    return f'{a} {b}'
                elif cand > x:
                    break
            b += 1
            if (b + n) ** 5 - b ** 5 > x:
                break


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

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
grid = [list(map(int, input().split())) for _ in range(N)]
grid1 = []
grid2 = []
grid3 = []
ans = float('inf')
for i in range(N):
    for k in range(N):
        tmp = grid[i][k]
        tmp2 = i + k
        if tmp2 % 3 == 1:
            grid1.append(tmp)
        elif tmp2 % 3 == 2:
            grid2.append(tmp)
        else:
            grid3.append(tmp)
sum1 = sum(grid1)
sum2 = sum(grid2)
sum3 = sum(grid3)
for i in range(C):
    tmp1 = sum1
    for ii in grid1:
        tmp1 = tmp1 - ii + D[ii-1][i]
    for k in range(C):
        if i == k:
            continue
        tmp2 = sum2
        for kk in grid2:
            tmp2 = tmp2 - kk + D[kk-1][k]
        for l in range(C):
            if i == l or k == l:
                continue
            tmp3 = sum3
            for ll in grid3:
                tmp3 = tmp3 - ll + D[ll-1][l]
            ans = min(ans,tmp1+tmp2+tmp3)
print(ans)

### FIXED CODE ###

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
grid = [list(map(int, input().split())) for _ in range(N)]
grid1 = []
grid2 = []
grid3 = []
ans = float('inf')
for i in range(N):
    for k in range(N):
        tmp = grid[i][k]
        tmp2 = i + k
        if tmp2 % 3 == 1:
            grid1.append(tmp)
        elif tmp2 % 3 == 2:
            grid2.append(tmp)
        else:
            grid3.append(tmp)
sum1 = sum(grid1)
sum2 = sum(grid2)
sum3 = sum(grid3)
tmp1 = [sum1]*C
tmp2 = [sum2]*C
tmp3 = [sum3]*C
for i in range(C):
    for k in grid1:
        tmp1[i] = tmp1[i] - k + D[k-1][i]
for i in range(C):
    for k in grid2:
        tmp2[i] = tmp2[i] - k + D[k-1][i]
for i in range(C):
    for k in grid3:
        tmp3[i] = tmp3[i] - k + D[k-1][i]
for i in range(C):
    for k in range(C):
        if i == k:
            continue
        for l in range(C):
            if i == l or k == l:
                continue
            ans = min(ans,tmp1[i]+tmp2[k]+tmp3[l])
print(ans)
### BUGGY CODE ###

import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))
ans=0
for i in range(n+1):
  m=0
  b1=np.sort(a[:n+i])[i:]
  b2=np.sort(a[n+i:])[:n]
  m=np.sum(b1)-np.sum(b2)
  if ans<m or i==0:
    ans=m
print(ans)

### FIXED CODE ###

import heapq
n=int(input())
a=list(map(int,input().split()))
ans=[0 for i in range(n+1)]
ans[0]=sum(a[:n])
b=a[:n]
heapq.heapify(b)
sb=sum(b)
for i in range(n):
  sb+=a[n+i]
  c=heapq.heappushpop(b,a[n+i])
  sb-=c
  ans[i+1]=sb
b=a[2*n:]
for i in range(n):
  b[i]=-b[i]
heapq.heapify(b)
ans[n]+=sum(b)
sb=sum(b)
for i in range(n-1,-1,-1):
  sb-=a[n+i]
  c=heapq.heappushpop(b,-a[n+i])
  sb-=c
  ans[i]+=sb
print(max(ans))
### BUGGY CODE ###

a, b, c, n = map(int, input().split())
aa =[a,b,c]
aa.sort()
r = aa[2]
g = aa[1]
b = aa[0]
 
count = 0
for i_r in range(0,int(n/r)+1):
    if (n - r*i_r)<0:continue
    for i_g in range(0,int((n-r*i_r)/g)+1):
        if (n - r*i_r - g*i_g)<0:continue
        if 0==((n - r*i_r - g*i_g)%b):
 
            count = count + 1
 
print(count)

### FIXED CODE ###

a, b, c, n = map(int, input().split())
aa =[a,b,c]
aa.sort()
r = aa[2]
g = aa[1]
b = aa[0]
 
count = 0
for i_r in range(0,int(n/r)+1):
    if (n - r*i_r)<0:continue
    for i_g in range(0,int((n-r*i_r)/g)+1):
        if (n - r*i_r - g*i_g)<0:continue
        if 0==((n - r*i_r - g*i_g)%b):
 
            count = count + 1
 
print(count)
### BUGGY CODE ###

N,K = map(int,input().split())
p = list(map(int,input().split()))

m = p[0:K]
for i in range(1,N-K+1):
    if sum(m) < sum(p[i:K+i]):
        m = p[i:K+i]

for l in range(0,K):
     m[l] = (1+m[l])/2
n = sum(m)
print(n)


### FIXED CODE ###

N,K = map(int,input().split())
p = list(map(int,input().split()))

s = 0
for i in range(0,K):
    s = s + p[i]
t = s
for j in range(0,N-K):
    u = s + p[j+K] - p[j]
    if u > t:
        t = u
    s = u
print((t+K)/2)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

def par(a):
    if P[a] == a: return a
    t = par(P[a])
    P[a] = t
    return t
def unite(a, b):
    if par(a) != par(b): C[par(a)] += C[par(b)]
    P[par(b)] = par(a)

N, H, W = map(int, input().split())
P = [i for i in range(H+W)]
C = [1] * (H+W)
X = []
for _ in range(N):
    r, c, a = map(int, input().split())
    X.append((a, r-1, c+H-1))
X = sorted(X)
ans = 0
while X:
    a, r, c = X.pop()
    unite(r, c)
    if C[par(r)]:
        ans += a
        C[par(r)] -= 1
print(ans)


### FIXED CODE ###

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

def par(a):
    if P[a] < 0: return a
    t = par(P[a])
    P[a] = t
    return t
def unite(a, b):
    if par(a) == par(b): return 0
    C[par(a)], C[par(b)] = C[par(a)] + C[par(b)], C[par(a)] + C[par(b)]
    if P[par(b)] == P[par(a)]:
        P[par(b)] = par(a)
        P[par(a)] -= 1
    elif P[par(b)] > P[par(a)]:
        P[par(b)] = par(a)
    else:
        P[par(a)] = par(b)
N, H, W = map(int, input().split())
P = [-1 for i in range(H+W)]
C = [1] * (H+W)
X = []
for _ in range(N):
    r, c, a = map(int, input().split())
    X.append((a, r-1, c+H-1))
X = sorted(X)
ans = 0
while X:
    a, r, c = X.pop()
    unite(r, c)
    if C[par(r)]:
        ans += a
        C[par(r)] -= 1
print(ans)
### BUGGY CODE ###

import math
from functools import reduce
def gcd(*nums):
    return reduce(math.gcd, nums)

num = int(input())
ans = 0
for i in range(1, num + 1):
    for j in range(1, num + 1):
        for k in range(1, num + 1):
            ans += gcd(i, j, k)

print(ans)

### FIXED CODE ###

import math
num = int(input())
ans = 0
for i in range(1, num + 1):
    for j in range(1, num + 1):
        tmp = math.gcd(i, j)
        for k in range(1, num + 1):
            ans += math.gcd(tmp, k)

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

n=int(input())
s=list(input())
R=[]
G=[]
B=[]
count=0
for i in range(n):
    if s[i]=="R":
        R.append(i)
    elif s[i]=="G":
        G.append(i)
    else:
        B.append(i)
for r in R:
    for g in G:
        for b in B:
            middle=r+g+b-min(r,g,b)-max(r,g,b)
            mi=min(r,g,b)
            ma=max(r,g,b)
            if (middle-mi)!=(ma-middle):
                count+=1

print(count)

### FIXED CODE ###

n=int(input())
s=input()
r=0
g=0
b=0
for i in s:
    if i=="R":r+=1
    elif i=="G":g+=1
    elif i=="B":b+=1
ans=r*b*g

for j in range(n):
    for i in range(j):
        k=j+(j-i)
        if k<n:
            
            if s[i]==s[j]: continue
            if s[j]==s[k]: continue
            if s[k]==s[i]: continue
            ans-=1
print(ans)
### BUGGY CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 9)

H, W = list(map(int, input().split()))
G = [list(input()) for i in range(H)]

Visited = [[0] * W for i in range(H)]
direction = [[0, 1], [0, -1], [1, 0], [-1, 0]]


def dfs(ny, nx, color):
    for dy, dx in direction:
        if not ((0 <= ny + dy < H) and (0 <= nx + dx < W)):
            continue

        if G[ny + dy][nx + dx] == G[ny][nx]:
            continue

        if Visited[ny + dy][nx + dx] != 0:
            continue

        if G[ny + dy][nx + dx] == '#':
            Visited[ny + dy][nx + dx] = color
        else:
            Visited[ny + dy][nx + dx] = -color

        dfs(ny + dy, nx + dx, color)


Color = 1
for y in range(H):
    for x in range(W):
        if Visited[y][x] == 0:
            if G[y][x] == '#':
                Visited[y][x] = Color
            else:
                Visited[y][x] = -Color
            dfs(y, x, Color)
            Color += 1


D = defaultdict(int)
for row in Visited:
    for data in row:
        D[data] += 1

ans = 0
for key in D.keys():
    if -key in D.keys():
        ans += D[key] * D[-key]

print(ans // 2)


### FIXED CODE ###

def main():
    from collections import defaultdict
    import sys
    sys.setrecursionlimit(10 ** 9)
    
    H, W = list(map(int, raw_input().split()))
    G = [list(raw_input()) for i in range(H)]
    
    Visited = [[0] * W for i in range(H)]
    direction = [[0, 1], [0, -1], [1, 0], [-1, 0]]
    
    
    def dfs(ny, nx, color):
        for dy, dx in direction:
            if not ((0 <= ny + dy < H) and (0 <= nx + dx < W)):
                continue
    
            if G[ny + dy][nx + dx] == G[ny][nx]:
                continue
    
            if Visited[ny + dy][nx + dx] != 0:
                continue
    
            if G[ny + dy][nx + dx] == '#':
                Visited[ny + dy][nx + dx] = color
            else:
                Visited[ny + dy][nx + dx] = -color
    
            dfs(ny + dy, nx + dx, color)
    
    
    Color = 1
    for y in range(H):
        for x in range(W):
            if Visited[y][x] == 0:
                if G[y][x] == '#':
                    Visited[y][x] = Color
                else:
                    Visited[y][x] = -Color
                dfs(y, x, Color)
                Color += 1
    
    D = defaultdict(int)
    for i in range(1, Color + 1):
        D[i] = 0
        D[-i] = 0
    
    for row in Visited:
        for data in row:
            D[data] += 1
    
    ans = 0
    for key in D.keys():
        ans += D[key] * D[-key]
    
    print(ans // 2)
    
main()
### BUGGY CODE ###

# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():

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

    maxcnt=0
    for i in range(N):
        cnt=0

        j=i
        while j<=N-2:
            if H[j] >= H[j + 1]:
                cnt+=1
                j+=1
            else:
                break

        maxcnt=max(maxcnt,cnt)
    print(maxcnt)



resolve()

### FIXED CODE ###

# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():

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

    d=[1]*N


    for j in range(1,N):
        if H[j-1] >= H[j]:
            d[j]+=d[j-1]
        else:
            continue

    print(max(d)-1)



resolve()
### BUGGY CODE ###

import math
step_n, max_jump = map(int, input().split())

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

dp_table = [math.inf] * (step_n)
dp_table[0] = 0

def jump_cost(step_a, step_b):
    return abs(step_list[step_a] - step_list[step_b])

for i in range(1, step_n):
    min_from = max(0, i - max_jump)
    dp_table[i] = min(dp_table[j] + jump_cost(i, j) for j in range(min_from, i))

print(dp_table[step_n-1])



### FIXED CODE ###

import math
step_n, max_jump = map(int, input().split())

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

dp_table = [math.inf] * (step_n)
dp_table[0] = 0

for i in range(1, step_n):
    min_from = max(0, i - max_jump)
    dp_table[i] = min(dp_table[j] + abs(step_list[i] - step_list[j]) for j in range(min_from, i))

print(dp_table[step_n-1])