Harryxun/stf_run huggingface dataset:
n=int(input())
l=list(map(int,input().split()))
f=1
for i in range(n-1):
	if l[i]==l[i+1]:
      f=0
      break
if f:
	print("YES")
else:
	print("NO")

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
if len(set(l))==n:
    print("YES")
else:
    print("NO")
import numpy as np
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n, m = map(int, input().split())
a = np.array(list(map(int, input().split())))
a_d = a // 2

ans = m / lcm(*a_d) / 2
if ans.is_integer():
    ans = m // lcm(*a_d) // 2 - 1
    print(int(ans))
else:
    ans = round(m / lcm(*a_d) / 2)
    print(int(ans))

### FIXED CODE ###

from fractions import gcd

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

n, m = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i //= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(j, L)
        if m < L:
            print(0)
            break
    else:
        print((m // L + 1) // 2)
else:
    print(0)
def main():
    n = int(input())
    p = list(range(1,n+1))
    q = p[1:]
    q.append(p[0])
    s = 0
    for i, v in enumerate(q):
        s += (i+1) % v
    print(s)

if __name__ == "__main__":
    main()

### FIXED CODE ###

n=int(input());print(int(n*(n-1)//2))
import numpy as np

N = int(input())
a = np.fromstring(input(), sep=" ", dtype=np.int64)
b = np.bitwise_xor.reduce(a)
for n in range(N):
    print(b ^ a[n])


### FIXED CODE ###

a = input()
if(a == a.upper()):
    print("A")
else:
    print("a")
a = []
count = 0
while True:
    count += 1
    n = input()
    if n == 0:
        break
    print("Case "+str(count)+": "+n)

### FIXED CODE ###

count = 0
while True:
    count += 1
    a = int(input())
    if a == 0:
        break
    print("Case "+str(count)+": "+str(a))
import math

r=input()
l=2*math.pi*r
print(l)

### FIXED CODE ###

import math

r=input()
r=int(r)
l=2*math.pi*r
print(l)
N,M = map(int,input().split())
*A, = map(int,input().split())
B = sorted((([2,5,5,4,5,6,3,7,6][a-1],a) for a in A),key = lambda x:(x[0],-x[1]))
i = 1
while i<len(B):
    if B[i][0]==B[i-1][0]:
        B.pop(i)
    else:
        i+=1
i = [0]*(len(B)-1)
ans_tmp = (0,[])
while i[-1]<B[0][0]:
    tmp = N - sum(j*b[0] for j,b in zip(i,B[1:]))
    if tmp%B[0][0] == 0:
        tmp2 = tmp//B[0][0] + sum(j for j in i)
        if ans_tmp[0] < tmp2:
            ans_tmp = (tmp2,[tmp//B[0][0]]+i)
    i[0]+=1
    for j in range(len(i)-1):
        if i[j]==B[0][0]:
            i[j+1]+=1
            i[j]=0
ans = ""
for i,n in sorted(zip([b for _,b in B],ans_tmp[1]),key=lambda x:-x[0]):
    ans += str(i)*n
print(ans)

### FIXED CODE ###

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

cost = sorted(list(zip([[2,5,5,4,5,6,3,7,6][a-1] for a in A],A)),key = lambda x: (x[0],-x[1]))

#同じ画数の数字を除く
tmp = len(cost)
i = 1
while i < tmp:
    if cost[i][0] == cost[i-1][0]:
        cost.pop(i)
        tmp = len(cost)
    else:
        i += 1
cost.sort(key = lambda x:-x[1])

dp = [0]+[-10]*(N)
for i in range(2,N+1):
    dp[i] = max([-10]+[dp[i-a]+1 for a,_ in cost if i >= a])

n = N
out = ""
i = 0
while n:
    c , a = cost[i]
    if (n>=c) and (dp[n-c] == dp[n]-1):
        n -= c
        out += str(a)
    else:
        i+=1
print(out)
import numpy as np

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

K_str = format(K, 'b')
max_order = len(K_str)

B = np.array([list(format(a, '0{}b'.format(max_order)))
              for a in A]
             ).astype('i')[:, :max_order]
B = B.sum(axis=0)
B = np.where(B < N/2, 1, 0)

X_str = '1001'
X = int(X_str, 2)

print(sum(map(lambda a: X ^ a, A)))


### FIXED CODE ###

import numpy as np

N, K = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]

K = format(K, 'b')
B = [format(a, 'b') for a in A]
max_order = len(max(B + [K], key=len))

K = K.zfill(max_order)
B = np.array([list(b.zfill(max_order)) for b in B], dtype='i')
B = B.sum(axis=0)
B = np.where(B < N/2, '1', '0')

for i, k, b in zip(range(max_order), K, B):
    if k < b:
        B[i] = '0'
    elif k > b:
        break

X = int(''.join(map(str, B)), 2)

print(sum(map(lambda a: X ^ a, A)))
X, Y, Z, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A = sorted([int(x) for x in A], reversed=True)
B = sorted([int(x) for x in B], reversed=True)
C = sorted([int(x) for x in C], reversed=True)

res = []
i, j, k = 0, 0, 0
while len(res) < K:
  res.append(A[i]+B[j]+C[k])
  res.append(A[i+1]+B[j]+C[k])
  res.append(A[i]+B[j+1]+C[k])
  res.append(A[i]+B[j]+C[k+1])
  i,j,k = i+1, j+1, k+1
res = sorted(res, reversed=True)[:K]
for i in res:
  print(i)

### FIXED CODE ###

from heapq import *

X, Y, Z, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A = sorted([int(x) for x in A], reverse=True)
B = sorted([int(x) for x in B], reverse=True)
C = sorted([int(x) for x in C], reverse=True)

res = []
memo = []
ans = []
heappush(res, (-A[0]-B[0]-C[0], 0, 0, 0))
while len(ans) < K:
  e, i, j, k = heappop(res)
  ans.append(-e)
  if i+1 < X and [i+1, j, k] not in memo:
    heappush(res, (-A[i+1]-B[j]-C[k], i+1, j, k))
    memo.append([i+1, j, k])
  if j+1 < Y and [i, j+1, k] not in memo:
    heappush(res, (-A[i]-B[j+1]-C[k], i, j+1, k))
    memo.append([i, j+1, k])
  if k+1 < Z and [i, j, k+1] not in memo:
    heappush(res, (-A[i]-B[j]-C[k+1], i, j, k+1))
    memo.append([i, j, k+1])

for i in ans:
  print(i)
"""
    S：長さNの文字列
    if S[i] = '0':
        color = 'red'
    elif S[i] = '1':
        color = 'blue'
    
    I can remove set of boxes which put together red and blue box.

    output : How many can I remove box?
"""
s = input()
count = 0

while len(s) > 0:
    i = 0

    while i < len(s):
        if i == len(s)-1:
            break
        if (s[i+1] == '0' and s[i+2] =='1') or (s[i+1] == '1' and s[i+2] =='1'):
            s = s[:i+1]+s[i+3:]
            count += 1
            break
        i += 1
    if i == len(s)-1:
            break

print(count*2)

### FIXED CODE ###

s = input()
count1 = s.count('1')
count0 = s.count('0')

if count0 >= count1:
    print(count1*2)
else:
    print(count0*2)
n = input()
a = []
for i in range(n):
  a.append(input())
a = a.sort()[:3]
b = []
for i in [0,1,2]:
  for j in [0,1,2]:
    if i != j:
      b.append(int(str(a[i] + a[j])))
b.sort()
return(b[2])


### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a.sort()
a = a[:4]
b = []
for i in [0,1,2,3]:
  for j in [0,1,2,3]:
    if i != j:
      b.append(int(str(a[i]) + str(a[j])))
b.sort()
print(b[2])
A, B, C = input().split()]

if A[len(A)-1] == B[0] and B[len(B)-1] == C[0]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

A, B, C = input().split()
     
if A[len(A)-1] == B[0] and B[len(B)-1] == C[0]:
  print("YES")
else:
  print("NO")
S=int(input())
h=int(S / 3600)
m=int((s / 3600) /60)
s=int(((s/3600)/60)/60)

### FIXED CODE ###

S=int(input())
h=S//3600
m=(S%3600)//60
s=S%60
print(h,m,s,sep=":")
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    for i in range(n):
        a[i] -= i + 1
    a.sort()
    t1 = 0
    t2 = 0
        t2 += abs(a[i] - a[n//2 - 1])
    print(min(t1, t2))


if __name__ == '__main__':
    solve()


### FIXED CODE ###

def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    b = []
    for i, v in enumerate(a):
        b.append(v - (i + 1))
    b.sort()
    t = b[len(b) // 2]
    s = 0
    for i, v in enumerate(a):
        s += abs(v - (t + (i + 1)))
    print(s)


if __name__ == '__main__':
    slove()
n, m = map(int, input().split())
import numpy as np
g = np.zeros((n+1, n+1))
for _ in range(m):
    a, b = map(int, input().split())
    g[a][b] = 1
    g[b][a] = 1
ans = "IMPOSSIBLE"
for i in range(n+1):
    if g[1][i] == 1:
        if g[i][n] == 1:
            ans = "POSSIBLE"
print(ans)


### FIXED CODE ###

n, m = map(int, input().split())
g = {}
for _ in range(m):
    a, b = map(int, input().split())
    if a not in g:
        g[a] = [b]
    if b not in g:
        g[b] = [a]
    if a in g:
        g[a].append(b)
    if b in g:
        g[b].append(a)
ans = "IMPOSSIBLE"
for i in g[1]:
    if n in g[i]:
        ans = "POSSIBLE"
print(ans)
n=list(input())
for i in range(3):
  if n[i]=="1":
    n[i]=9
  else:
    n[i]=1
s=" "
for i in range(3):
  s+="n[i]"
print(int(s))

### FIXED CODE ###

n=input()
ans=""
for i in range(3):
  if n[i]=="1":
    ans+="9"
  else:
    ans+="1"
print(ans)
def main():
    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]
    for m in range(0, M):
        tmp = [int(x) for x in input().split()]
        A.extend([tmp[1]] * tmp[0])

    A = A.sort(A, reverse = True)
    sum_a = 0
    for i in range(0, N):
        sum_a += A[i]

    print(sum_a)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    age, cost = map(int, input().split())

    if age <= 5:
        print(0)
    elif age >= 6 and age <= 12:
        print(cost // 2)
    else:
        print(cost)

if __name__ == "__main__":
    main()
INF = 10 ** 10

N = int(input())

L = [tuple(map(int,input().split())) for _ in range(N)]

L.sort(key=lambda x:(-x[0], x[1]))

MAX_L = 0
MIN_R = INF
MAX = 0
a = 0
b = 0

for i in range(N):
    if MAX_L < L[i][0]:
        MAX_L = L[i][0]
        a = i
    if MIN_R > L[i][1]:
        MIN_R = L[i][1]
        b = i
    MAX = max(MAX, L[i][1] - L[i][0] + 1)

ans = MAX + max(0, MIN_R - MAX_L + 1)

p = 0

for i in range(N-1):
    p = max(p, L[i+1][0])
    ans = max(ans, max(0, L[i][1] - L[0][0] + 1) + max(0, L[-1][1] - L[i+1][0] + 1))


    print(ans)INF = 10 ** 10

N = int(input())

L = [tuple(map(int,input().split())) for _ in range(N)]

L.sort(key=lambda x:(-x[0], x[1]))

MAX_L = 0
MIN_R = INF
MAX = 0
a = 0
b = 0

for i in range(N):
    if MAX_L < L[i][0]:
        MAX_L = L[i][0]
        a = i
    if MIN_R > L[i][1]:
        MIN_R = L[i][1]
        b = i
    MAX = max(MAX, L[i][1] - L[i][0] + 1)

ans = MAX + max(0, MIN_R - MAX_L + 1)

p = 0

for i in range(N-1):
    p = max(p, L[i+1][0])
    ans = max(ans, max(0, L[i][1] - L[0][0] + 1) + max(0, L[-1][1] - L[i+1][0] + 1))


    print(ans)

### FIXED CODE ###

INF = 10 ** 10

N = int(input())
 
L = [tuple(map(int,input().split())) for _ in range(N)]
 
L.sort(key=lambda x:(-x[0], x[1]))
 
MAX_L = 0
MIN_R = INF
MAX = 0
a = 0
b = 0
 
for i in range(N):
    if MAX_L < L[i][0]:
        MAX_L = L[i][0]
        a = i
    if MIN_R > L[i][1]:
        MIN_R = L[i][1]
        b = i
    MAX = max(MAX, L[i][1] - L[i][0] + 1)
 
ans = MAX + max(0, MIN_R - MAX_L + 1)
 
p = INF
 
for i in range(N-1):
    p = min(p, L[i][1])
    ans = max(ans, max(0, p - L[a][0] + 1) + max(0, L[b][1] - L[i+1][0] + 1))
 
print(ans)
y,m,d=map(input().split("/"))
print(str(y+1)+"/"+str(m)+"/"+str(d))

### FIXED CODE ###

print(input().replace('2017', '2018'))
import sys

input = sys.stdin.readline

def main():
    x, n = map(int, input().rstrip().split())
    if n == 0:
        print(x)
        sys.exit()
    else:
        p = list(map(int, input().rstrip().split()))
        if x > max(p):
            print(x)
            sys.exit()
        else:
            p_x = set(range(min(p),max(p)+1))
            p_temp = set(p)
            p_diff = p_x - p_temp
            p_temp = list(p_diff)
            p_dir = []

        for i in range(len(p_temp)):
            p_dir.append(abs(p_temp[i] - x))
        print(p_temp[p_dir.index(min(p_dir))])
  
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

input = sys.stdin.readline

def main():
    x, n = map(int, input().rstrip().split())
    if n == 0:
        print(x)
        sys.exit()
    else:
        p = list(map(int, input().rstrip().split()))
        if x > max(p):
            print(x)
            sys.exit()
        else:
            p_x = set(range(102))
            p_temp = set(p)
            p_diff = p_x - p_temp
            p_temp = list(p_diff)
            p_temp = sorted(p_temp)
            p_dir = []

        for i in range(len(p_temp)):
            p_dir.append(abs(p_temp[i] - x))
        print(p_temp[p_dir.index(min(p_dir))])
  
if __name__ == "__main__":
    main()
N, K = map(int,input().split())

dic = {}
i = 0
while (2 ** i) <= (10 ** 5):
    dic[i] = 0
    i += 1

for i in range(1, N+1):
    cnt = 0
    while i * (2 ** cnt) < K:
        cnt += 1
    dic[cnt] += 1

ans = 0
for k, v in dic.items():
    if v > 0:
        ans += v * (0.5 ** k)

ans /= N
print(ans)

### FIXED CODE ###

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

ans = 0
for i in range(1, N+1):
    cnt = 0
    while i * (2 ** cnt) < K:
        cnt += 1
    ans += (0.5 ** cnt) / N

print(ans)
def main():
    a, b, c, d = map(int, input().split())
    num_list = [a, b, c, d]
    if (a-b-c-d == 7): print('{}-{}-{}-{}=7'.format(*num_list))
    elif (a-b-c+d == 7): print('{}-{}-{}+{}=7'.format(*num_list))
    elif (a-b+c-d == 7): print('{}-{}+{}-{}=7'.format(*num_list))
    elif (a+b-c-d == 7): print('{}+{}-{}-{}=7'.format(*num_list))
    elif (a-b+c+d == 7): print('{}-{}+{}+{}=7'.format(*num_list))
    elif (a+b-c+d == 7): print('{}+{}-{}+{}=7'.format(*num_list))
    elif (a+b+c+d == 7): print('{}+{}+{}+{}=7'.format(*num_list))
                    

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    num = input()
    a, b, c, d = [int(i) for i in num]
    num_list = [a, b, c, d]
    if (a-b-c-d == 7): print('{}-{}-{}-{}=7'.format(*num_list))
    elif (a-b-c+d == 7): print('{}-{}-{}+{}=7'.format(*num_list))
    elif (a-b+c-d == 7): print('{}-{}+{}-{}=7'.format(*num_list))
    elif (a+b-c-d == 7): print('{}+{}-{}-{}=7'.format(*num_list))
    elif (a-b+c+d == 7): print('{}-{}+{}+{}=7'.format(*num_list))
    elif (a+b+c-d == 7): print('{}+{}+{}-{}=7'.format(*num_list))
    elif (a+b-c+d == 7): print('{}+{}-{}+{}=7'.format(*num_list))
    elif (a+b+c+d == 7): print('{}+{}+{}+{}=7'.format(*num_list))
                    

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

count = x.count("1")

mod1 = 0 # 1少ない
mod2 = 0 # 1多い

#　初回の各桁のbitを反転させた場合のmod結果を格納するリスト
mod1_list = [0]*n
mod2_list = [0]*n

now1 = 1

x = x[::-1]

# mod1の計算
for i in range(n):
    mod1_list[i] = now1
    if x[i] == "1":
        mod1 += now1%(count+1)
    now1 *= 2
    now1 %= (count+1)

mod1 %= (count+1)

now2 = 1

# mod2の計算
if count >= 3:
    for i in range(n):
        mod2_list[i] = now2
        if x[i] == "1":
            mod2 += now2%(count-1)
        now2 *= 2
        now2 %= (count-1)
    
    mod2 %= (count-1)

mod1_list = mod1_list[::-1]
mod2_list = mod2_list[::-1]
x = x[::-1]

for i in range(n):
    total = 1
    if x[i] == "1":
        now = mod2-mod2_list[i]
        now %= (count-1)
    else:
        now = mod1+mod1_list[i]
        now %= (count+1)
        
    while now != 0:
        now = now%(bin(now).count("1"))
        total += 1

    print(total)

### FIXED CODE ###

n = int(input())
x = input()

count = x.count("1")

mod1 = 0 # 1少ない
mod2 = 0 # 1多い

#　初回の各桁のbitを反転させた場合のmod結果を格納するリスト
mod1_list = [0]*n
mod2_list = [0]*n

now1 = 1

x = x[::-1]

# mod1の計算
for i in range(n):
    mod1_list[i] = now1
    if x[i] == "1":
        mod1 += now1%(count+1)
    now1 *= 2
    now1 %= (count+1)

mod1 %= (count+1)

now2 = 1

# mod2の計算
if count >= 3:
    for i in range(n):
        mod2_list[i] = now2
        if x[i] == "1":
            mod2 += now2%(count-1)
        now2 *= 2
        now2 %= (count-1)
    
    mod2 %= (count-1)

mod1_list = mod1_list[::-1]
mod2_list = mod2_list[::-1]
x = x[::-1]

for i in range(n):
    total = 1
    if x[i] == "1":
        if count == 1:
            print(0)
            continue
        elif count == 2:
            print(1)
            continue
        now = mod2-mod2_list[i]
        now %= (count-1)
    else:
        now = mod1+mod1_list[i]
        now %= (count+1)

    while now != 0:
        now = now%(bin(now).count("1"))
        total += 1

    print(total)
n=int(input())
l=[]
for i in range(n):
  s=int(input())
  l.append(s)
 
 
a=round(sum(l)/n)
k=0
for j in l:
  k = k + (j-a)**2
print(k)


### FIXED CODE ###

n=int(input())
l= list(int(i) for i in input().split())
a=int(round(sum(l)/n))
k=0
for j in l:
  k = k + (j-a)**2
print(k)
A,B,C=input().split()
if A==B and B==C:
  print("No")
elif:A==B or B==C or C==A:
    print("Yes")
else:
  print("No")
  

### FIXED CODE ###

A,B,C=input().split()
if A==B and B==C:
  print("No")
elif A==B or B==C or C==A:
    print("Yes")
else:
  print("No")
in = input()
plus = in.count("+")
print(plus*2-4)


### FIXED CODE ###

i = input()
p = i.count("+")
print(2*p-4)
S = list(input())
T = list(input())
s = []
t = []
for i in S:
  s.append(int(ord(i)))
for i in T:
  t.append(int(ord(i)))

s.sort(reverse = True)
t.sort(reverse = True)
for i in range(max(len(s),len(t))):
  if t[i] > s[i]:
    print("Yes")
    exit(0)
  elif s[i] != t[i]:
    break
  
if len(t) > len(s):
  for i in s:
    if i == len(s):
      print("Yes")
    elif i not in t:
      print("No")
      exit(0)
    else:
      t.remove(i)
else:
  print("No")
  exit(0)
print("No")



### FIXED CODE ###

S = list(input())
T = list(input())
s = []
t = []
for i in S:
  s.append(int(ord(i)))
for i in T:
  t.append(int(ord(i)))

s.sort()
t.sort()
for i in range(max(len(s),len(t))):
  if i >= min(len(s),len(t)):
    break
  elif max(t) > s[i]:
    print("Yes")
    exit(0)
  elif s[i] not in t:
    break
  else:
    t.remove(s[i])
    s.remove(s[i])
    
  
if len(t) > len(s):
  for i in s:
    if i not in t:
      print("No")
      exit(0)
    else:
      t.remove(i)
  print("Yes")
else:
  print("No")
n = int(input())
a_list = []
for i in range(n):
	a_list.append(int(input()))
r = -1
num = 1
count = 0
nums = []
while True:
	num = a_list[num-1]
	if num in nums:
		break
	nums.append(num))
	count += 1
	if num == 2:
		r = count
		break
print(r)

### FIXED CODE ###

n = int(input())
a_list = []
for i in range(n):
	a_list.append(int(input()))
r = -1
num = 1
count = 0
while True:
	num = a_list[num-1]
	count += 1
	if num == 2:
		r = count
		break
	if count == n:
		break
print(r)
a,b=map(int,input().split())
c=(a//(2b+1))+1
print(c)

### FIXED CODE ###

r=int(input())
print(3*r**2)
import sympy
N = int(input())

count = 0
for i in range(1,N):
    count += len(sympy.divisors(N-i))
print(count)


### FIXED CODE ###

S = input()

if S[-1] == "s" :
    print(S + "es")
else :
    print(S + "s")
import sys

rl = sys.stdin.readline

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

li = list(map(int, rl().split()))

dp = [1<<60]*n

dp[0] = 0
dp[1] = abs(li[0] - li[1])

if k < n:    
    for i in range(2, k):
        for j in range(i):
            a = dp[j] + abs(li[j] - li[i])
            if dp[i] > a:
                dp[i] = a
    for i in range(k, n):
        for j in range(i-k, i):
            a = dp[j] + abs(li[j] - li[i])
            if dp[i] > a:
                dp[i] = a
else:
    for i in range(n):
        for j in range(i):
            a = dp[j] + abs(li[j] - li[i])
            if dp[i] > a:
                dp[i] = a
        
print(int(dp[-1]))




### FIXED CODE ###

import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

n = int(rl())

li = list(map(int, rl().split()))

dp = np.zeros(n)

dp[0] = 0
dp[1] = abs(li[0] - li[1])

for i in range(2, n):
    dp[i] = min(dp[i-2] + abs(li[i] - li[i-2]), dp[i-1] + abs(li[i] - li[i-1]))
print(int(dp[n-1]))
from collections import deque
sys.setrecursionlimit(10 ** 7)
def bfs():
    cnt = 0
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    while len(Q) > 0:
        q = Q.popleft()
        y,x =  q[0], q[1]
        if cnt >= H*W:
            for i in range(H):
                if len(box[i]) == 0:
                    continue
                else:
                    ans.append(max(box[i]))
            return
        for i in range(4):
            ny = y+dy[i]
            nx = x+dx[i]
            if ny >= 0 and ny < H and nx >= 0 and nx < W and S[ny][nx] == "#" and box[ny][nx] == 0:
                cnt += 1
                box[ny][nx] = -1
            if ny >= 0 and ny < H and nx >= 0 and nx < W and S[ny][nx] == "." and box[ny][nx] == 0:
                cnt += 1
                box[ny][nx] = box[y][x] + 1
                Q.append([ny,nx])


H,W = map(int,input().split())
S = [ []for _ in range(H)]
for i in range(H):
    S[i] = list(input())
ans = []
INF = 50**2
Q = deque()
#queueにスタート地点を追加
for i in range(H):
    for j in range(W):
        #各マス目に到達するために必要な移動回数
        box = [[0 for _ in range(W)] for __ in range(H)]
        box[i][j] = 0
        Q.append([i,j])
        bfs()
if len(ans)==0:
    print(0)
    exit()
print(max(ans))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)


from collections import deque
def bfs():
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    while len(Q) > 0:
        q = Q.popleft()
        y,x =  q[0], q[1]
        if S[y][x] == "#": return
        for i in range(4):
            ny = y+dy[i]
            nx = x+dx[i]
            if ny >= 0 and ny < H and nx >= 0 and nx < W and S[ny][nx] == "#" and box[ny][nx] == -1000:
                box[ny][nx] = -1
            if ny >= 0 and ny < H and nx >= 0 and nx < W and S[ny][nx] == "." and box[ny][nx] == -1000:
                box[ny][nx] = box[y][x] + 1
                Q.append([ny,nx])
    for i in range(H):
        if len(box[i]) == 0:
            continue
        else:
            ans.append(max(box[i]))
    return


H, W = map(int,input().split())
S = [ [] for _ in range(H)]
for i in range(H):S[i] = list(input())
ans = []
Q = deque()
for i in range(H):
    for j in range(W):
        #各マス目に到達するために必要な移動回数
        box = [[-1000 for _ in range(W)] for __ in range(H)]
        Q.append([i,j])
        box[i][j] = 0
        bfs()
if len(ans)==0:
    print(0)
    exit()
print(max(ans))