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

import math
def combinations(n, r):
  if n == r:
    return 1
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
s = [[sorted(input()),1]]
ans = 0
for i in range(N-1):
  s_i = sorted(input())
  flag = 0
  for j in range(len(s)):
    if s[j][0] == s_i:
      flag = 1
      s[j][1] += 1
      break
  if flag != 1:
    s.append([s_i,1])
for j in range(len(s)):
    tmp = s[j][1]
    if tmp != 1:
      ans += combinations(tmp,2)
print(ans)

### FIXED CODE ###

import math
def combinations(n, r):
  if n == r:
    return 1
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
s = [sorted(input())]
ans = 0
for i in range(N-1):
  s_i = sorted(input())
  s.append(s_i)
s = sorted(s)
count=1
for j in range(N-1):
  if s[j] == s[j+1]:
    count+=1
  else:
    if count != 1:
      ans += combinations(count,2)
    count=1
if count != 1:
  ans += combinations(count,2)
print(ans)
### BUGGY CODE ###

s = list(input())

index = 0
thanS = s[0]
count = 1
a = []
for i in range(1, len(s)):
    if thanS == s[i]:
        count += 1

    else:
        a.extend([s[index: index + count]])
        thanS = s[i]
        index = index + count
        count = 1

a.extend([s[index:]])
b = [0]

for i in range(len(a)):
    diff = len(a[i])
    if a[i][0] == "<":
        add = [b[-1] + 1 + j for j in range(diff)]
    else:
        if b[-1] <= diff:
            b[-1] = diff
        add = [diff - j for j in range(1, diff + 1)]
    b = b + add

print(sum(b))


### FIXED CODE ###

s = input()

index = 0
thanS = s[0]
count = 1
a = []
for i in range(1, len(s)):
    if thanS == s[i]:
        count += 1

    else:
        a.append(s[index: index + count])
        thanS = s[i]
        index = index + count
        count = 1

a.append(s[index:])
b = 0
add = 0

for i in range(len(a)):
    diff = len(a[i])
    if a[i][0] == "<":
        add += diff * (diff + 1) / 2
        b = diff
    else:
        if b < diff:
            add = add + diff * (diff + 1) / 2 - b
        else:
            add = add + (diff - 1) * diff / 2
        b = 0

print(int(add))
### BUGGY CODE ###

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

if B - A + 1 < 2 * K:
    for i in range(A, B+1):
        print(i)
else:
    for i in range(A, B+1):
        if A <= i < A + K or B - K < i <= B:
            print(i)

### FIXED CODE ###

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

if B - A + 1 < 2 * K:
    for i in range(A, B+1):
        print(i)
else:
    for i in range(A, A+K):
        print(i)
    for i in range(B-K+1, B+1):
        print(i)
### BUGGY CODE ###


def c():
    n = int(input())
    s = []
    for i in range(n):
        temp = input()
        if temp not in s:
            s.append(temp)
    print(len(s))

def b():
    a,b,c,d = map(int, input().split())
    while True:
        c -= b
        if c <= 0:
            print('Yes')
            break
        a -= d
        if a <= 0:
            print('No')
            break

def a():
    s, w = map(int, input().split())
    if w >= s:
        print('unsafe')
    else:
        print('safe')



c()

### FIXED CODE ###


def c():
    n = int(input())
    s = ['']*n
    for i in range(n):
        s[i] = input()
    s.sort()
    count = 1
    for i in range(1, n):
        if s[i - 1] != s[i]:
            count += 1
    print(count)

def b():
    a,b,c,d = map(int, input().split())
    while True:
        c -= b
        if c <= 0:
            print('Yes')
            break
        a -= d
        if a <= 0:
            print('No')
            break

def a():
    s, w = map(int, input().split())
    if w >= s:
        print('unsafe')
    else:
        print('safe')



c()
### BUGGY CODE ###

#!/usr/bin/env python
import sys
sys.setrecursionlimit(100000000)

n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
DP = {}

# num 番目までのコインを使い、yen 円支払うときに必要な枚数
def func(num, yen):
	if num < 0 or yen < 0:
		return 10 ** 18
	if num == 0 and yen == 0:
		return 0
	'''
	if not (num, yen) in DP:
		DP[(num, yen)] = min(func(num - 1, yen), func(num, yen - c[num]) + 1)
	return DP[(num, yen)]
	'''
	return min(func(num - 1, yen), func(num, yen - c[num]) + 1)

print(func(m - 1, n))



### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools as ite
import math
import random
import sys
import codecs
from collections import defaultdict

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

n, m = map(int, input().split())
c = list(map(int, input().split()))
DP = [0] + [n] * n
for i in range(m):
    for j in range(c[i], n + 1):
        DP[j] = min(DP[j], DP[j - c[i]] + 1)
print(DP[n])
### BUGGY CODE ###

n = int(input())
s = []
count = 0
for _ in range(n):
    si = input()
    tmp_list = []
    tmp_list_s = []

    for i in range(10):
        tmp_list.append(si[i])

    tmp_list_s = sorted(tmp_list)

    if tmp_list_s in s:
        count += s.count(tmp_list_s)
    s.append(tmp_list_s)

print(count)


### FIXED CODE ###

n = int(input())
ss = list(''.join(sorted(list(input()))) for _ in range(n))
words = {}
cnt = 0

for s in ss:
    if s in words:
        cnt += words[s]
        words[s] += 1
    else:
        words[s] = 1
print(cnt)
### BUGGY CODE ###

from collections import Counter

num = int(input())

tmp = []
for n in range(num):
  tmp.append(input())

count = Counter(tmp)

tmp2 = []
for k, v in count.items():
  if count.most_common(1)[0][1] == v:
    tmp2.append(k)

for t in sorted(tmp2):
  print(t)
  

### FIXED CODE ###

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

  tmp = [input() for i in range(num)]

  tmp2 = {}
  for t in tmp:
    if len(tmp2) == 0:
      tmp2[t] = 1
    else:
      if t in tmp2:
        tmp2[t] += 1
      else:
        tmp2[t] = 1

  _tmp2 = sorted(tmp2.items(), key=lambda x:x[1])
  tmp3 = sorted(tmp2.items())
  for t in tmp3:
    if _tmp2[-1][1] == t[1]:
      print(t[0])

main()
### BUGGY CODE ###

s = input()
q = int(input())
o = 0
for _ in range(q):
    qu = list(input().split())
    if len(qu) == 1:
        o = -1 if o == 0 else 0
    if len(qu) == 3:
        if qu[1] == '1':
            s = qu[2] + s if o == 0 else s + qu[2]
        if qu[1] == '2':
            s = s + qu[2] if o == 0 else qu[2] + s

print(s) if o == 0 else print(s[::-1])


### FIXED CODE ###

from collections import deque
S = list(input()) 
d = deque()
for s in S:
    d.append(s)
q = int(input())
o = 0

for _ in range(q):
    qu = list(input().split())
    if len(qu) == 1:
        o = -1 if o == 0 else 0
    if len(qu) == 3:
        if qu[1] == '1':
            d.appendleft(qu[2]) if o == 0 else d.append(qu[2])
        if qu[1] == '2':
            d.append(qu[2]) if o == 0 else d.appendleft(qu[2])

r = ''
if o == 0:
    for _ in range(len(d)):
        r += d.popleft()
else:
    for _ in range(len(d)):
        r += d.pop()

print(r)
### BUGGY CODE ###

import math
S = int(input())
x = int(math.ceil(math.sqrt(S)))
Z = x * x - S
z = int(math.ceil(math.sqrt(Z)))

if z == 0:
    oz = 0
else:
    while True:
        oz = Z // z
        if Z % z == 0:
            break
        z += 1

print("0 0 {} {} {} {}".format(x, z, oz, x))

### FIXED CODE ###

import math
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

S = int(input())
x = int(math.ceil(math.sqrt(S)))
Z = x * x - S

if Z == 0:
    z = 0
    oz = 0
else:
    fs = factorize(Z)
    z = 1
    oz = 1
    for k, c in fs:
        while c >= 2:
            z *= k
            oz *= k
            c -= 2
        if c > 0:
            if z < oz:
                z *= k
            else:
                oz *= k




print("0 0 {} {} {} {}".format(x, z, oz, x))
### BUGGY CODE ###

M = 10 ** 6 + 3
HASH_MAP = [None for i in range(M)]


def hash1(key):
    return key % M


def hash2(key):
    return 1 + (key % M-1)


def my_hash(key, i):
    return (hash1(key)+i*hash2(key)) % M


def make_num(s):
    return len(s) + ord(s[0]) + ord(s[-1])


def insert(key):
    i = 0
    key_n = make_num(key)
    while True:
        j = my_hash(key_n, i)
        if HASH_MAP[j] is None:
            HASH_MAP[j] = key
            return j

        i += 1


def search(key):
    i = 0
    key_n = make_num(key)
    while True:
        j = my_hash(key_n, i)
        if HASH_MAP[j] == key:
            return j
        elif HASH_MAP[j] is None or i >= M:
            return None

        i += 1


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

    for i in range(n):
        order = input().split()
        if order[0] == "insert":
            insert(order[1])
        else:
            if search(order[1]) is None:
                print("no")
            else:
                print("yes")


if __name__ == '__main__':
    main()



### FIXED CODE ###

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

    s_set = set()
    for i in range(n):
        order = input().split()
        if order[0] == "insert":
            s_set.add(order[1])
        else:
            if order[1] in s_set:
                print("yes")
            else:
                print("no")


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


n = int(input())

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

if n != 0 :
    ans = a_list[0]
else :
    ans = 0

for i in range(1, n):
    ans = ans * a_list[i]

if 10**18 < ans :
        ans = -1   


print(ans)

### FIXED CODE ###


n = int(input())

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

if n != 0 :
    ans = a_list[0]
else :
    ans = 0

if 0 in a_list :
    ans = 0

for i in range(1, n):
    ans = ans * a_list[i]

    if 10**18 < ans :
        ans = -1
        break

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

H, W, M = [int(i) for i in input().split()]

cnt_dict_h = {}
cnt_dict_w = {}
bomb_list = []

for i in range(M):
    h, w = [int(i)-1 for i in input().split()]
    bomb_list.append((h,w))
    cnt_dict_h.setdefault(h, 0)
    cnt_dict_h[h] += 1
    cnt_dict_w.setdefault(w, 0)
    cnt_dict_w[w] += 1

max_h_key_list = [kv for kv in cnt_dict_h.items() if kv[1] == max(cnt_dict_h.values())]
max_w_key_list = [kv for kv in cnt_dict_w.items() if kv[1] == max(cnt_dict_w.values())]

count_bombs = []
for h in max_h_key_list:
    for w in max_w_key_list:
        bomb__num = cnt_dict_h[h[0]]+cnt_dict_w[w[0]]
        if(h[0], w[0]) in bomb_list:
            count_bombs.append(bomb__num-1)
        else :
            count_bombs.append(bomb__num)
            
print(max(count_bombs))    

### FIXED CODE ###

H, W, M = [int(i) for i in input().split()]

sum_h = [0] * W
sum_w = [0] * H
bomb_list = set()

for _ in range(M):
    h, w = [int(i) for i in input().split()]
    h -= 1
    w -= 1
    bomb_list.add((h,w))
    sum_h[w] += 1
    sum_w[h] += 1

max_sum_h = max(sum_h)
max_sum_w = max(sum_w)
output = max_sum_h + max_sum_w - 1

max_bombs_h = [h for h in range(H) if sum_w[h] == max_sum_w]
max_bombs_w = [w for w in range(W) if sum_h[w] == max_sum_h]

for h in max_bombs_h:
    for w in max_bombs_w:
        if (h, w) not in bomb_list:
            output = max_sum_h + max_sum_w
            break
        else:
            continue
        break
        
print(output)
### BUGGY CODE ###

N,M = (int(x) for x in input().split())
A=[]
B=[]
for i in range(N):
    a,b = (int(x) for x in input().split())
    A.append(a)
    B.append(b)
ans = 0

while M > 0:
    ind = A.index(min(A))
    b = B.pop(ind)

    if M < b:
        b = M
        M = 0
    else:
        M -= b

    ans += A.pop(ind) * b
    
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
drink, sumA, sumB = [], 0, 0
for _ in range(N):
    A,B = map(int, input().split())
    drink.append([A, B])
    sumA += A*B
    sumB += B 

if M == sumB:
    print(sumA)
elif M > sumB // 2:
    drink.sort(reverse=True)
    ans, exM = sumA, sumB - M
    while exM > 0:
        AB = drink.pop(0)
        b = min(exM, AB[1])
        ans -= b * AB[0]
        exM -= b
    print(ans)
else:
    drink.sort()
    ans = 0
    while M > 0:
        AB = drink.pop(0)
        b = min(M, AB[1])
        ans += b * AB[0]
        M -= b
    print(ans)
### BUGGY CODE ###

N=int(input())
P=list(map(int,input().split()))
R=[[True for i in range(N)] for j in range(N)]
R1=[False for i in range(N)]

for i in range(N):
  if P[i]<=min(P[:i+1]):
    R[i]=True
  else:
    R[i]=False

print(R.count(True))

### FIXED CODE ###

N=int(input())
P=list(map(int,input().split()))
cnt=0
bar=P[0]
for i in range(N):
  if P[i]<=bar:
    bar=P[i]
    cnt+=1
print(cnt)
### BUGGY CODE ###

N,K=map(int,input().split())
if(N<K):
  K=N
h=list(map(int,input().split()))
dp=[0]*N
for i in range(1,N):
    dp[i]=min(dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i))
print(dp[N-1])                      
                      
                      
                  

### FIXED CODE ###

N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*N
for i in range(1,N):
    dp[i]=min(dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i))
print(dp[N-1])
### BUGGY CODE ###

s=input()
s=list(s)
count=0

def change():
  global count
  flg=False
  for i in range(len(s)-2):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      s[i]='B'
      s[i+1]='C'
      s[i+2]='A'
      count+=1
      flg=True
      
  return flg
      
while(change()):
  pass

print(count)

### FIXED CODE ###

s=input()
s=s.replace('BC','D')
s=list(s)
count=0
 
def change():
  global count
  flg=False
  acount=0
  for i in range(len(s)-1):
    if s[i]=='A' and s[i+1]=='D':
      s[i]='D'
      s[i+1]='A'
      count+=1
      flg=True
      count+=acount
    elif s[i]=='A':
      acount+=1
    else:
      acount=0
      
  return flg
      
change()
 
print(count)
### BUGGY CODE ###

# import atexit
# import io
import sys
#
# _INPUT_LINES = sys.stdin.read().splitlines()
# input = iter(_INPUT_LINES).__next__
# _OUTPUT_BUFFER = io.StringIO()
# sys.stdout = _OUTPUT_BUFFER
#
#
# @atexit.register
# def write():
#     sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
import math
ans = sys.maxsize
n,k = R()
for i in range(n,k+1):
    for j in range(i+1,k+1):
        ans = min(ans,(i*j)%2019)

print(ans)

### FIXED CODE ###

import atexit
import io
import sys

_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER


@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
ans = sys.maxsize
n,k = R()
for i in range(n,k):
    for j in range(i+1,k+1):
        ans = min(ans,(i*j)%2019)
        if ans==0:
            print(ans)
            exit()

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

import numpy as np
n=int(input())
a=list(map(int,input().split()))
sign=[(-1)**i for i in range(n)]
ans=[0 for i in range(n)]
for i in range(n):
    tmp=0
    for j in range(n):
        tmp+=a[(i+j)%n]*sign[j]
    ans[i]=tmp
for ai in ans:
    print(ai, end=' ')


### FIXED CODE ###

import numpy as np
n=int(input())
a=list(map(int,input().split()))
sign=[1 if i%2==0 else -1 for i in range(n)]
a=np.array(a)
sign=np.array(sign)
plusA=a*sign
# minusA=a*sign*-1
ruisekiPlusA=[0 for i in range(n+1)]
for i in range(1,n+1):
    ruisekiPlusA[i]=ruisekiPlusA[i-1]+plusA[i-1]

# print(plusA,minusA)
for i in range(n):
    if i%2==0:
        # print(minusA[:i],plusA[i:])
        # print(np.sum(minusA[:i])+np.sum(plusA[i:]),end=' ')
        print(ruisekiPlusA[n]-2*ruisekiPlusA[i],end=' ')
    else:
        # print(plusA[:i],minusA[i:])
        # print(np.sum(plusA[:i])+np.sum(minusA[i:]),end=' ')
        print(2*ruisekiPlusA[i]-ruisekiPlusA[n],end=' ')
### BUGGY CODE ###

from bisect import bisect_left

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

for i in range(M):
  b, c = map(int, input().split())
  index = bisect_left(A, c)
  
  if index <= b:
    A = [c for _ in range(index) ] + A[index:]
  else:
    A = [c for _ in range(b)] + A[b:]
  
  A.sort()

print(sum(A))

### FIXED CODE ###

from heapq import heappop, heappush, heapify

N, M = map(int, input().split())
A = list(map(int, input().split()))
heapify(A)
BC = []

for i in range(M):
  b, c = map(int, input().split())
  heappush(BC, (-c, b))

for i in range(M):
  mc, b = heappop(BC)
  c = -mc
  end = False

  for j in range(b):
    min = heappop(A)
    if c <= min:
      heappush(A, min)
      end = True
      break
    else:
      heappush(A, c)

  if end:
    break

print(sum(A))
### BUGGY CODE ###

N, *A = map(int, open(0).read().split())

A.sort()

ans = 0
for i in range(N):
    count = 1
    p = 0
    j = i + 1
    while j < N:
        if A[j] != A[i] + p:
            if p == 2:
                break
            p += 1
            continue
        count += 1
        j += 1
    ans = max(ans, count)

print(ans)

### FIXED CODE ###

import sys
import collections

N, *A = map(int, open(0).read().split())

B = collections.Counter(A).most_common()
B.sort(key=lambda x: x[0])

ans = 0
for i in range(len(B)):
    count = B[i][1]
    if i+1 < len(B) and B[i+1][0] == B[i][0]+1:
        count += B[i+1][1]
        if i+2 < len(B) and B[i+2][0] == B[i][0]+2:
            count += B[i+2][1]
    ans = max(ans, count)
print(ans)
### BUGGY CODE ###


s, t = input(), input()
ls, lt = map(len,[s,t])

cls_list = [ [ [] for j in range(lt+1) ] for i in range(ls+1) ]

def lenmax(*args):
    args_list = list(args)
    length_list = list(map(len, args_list))
    longest_length = max(length_list)
    longest_index = length_list.index(longest_length)
    return args_list[longest_index]
    

for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            cls_list[i+1][j+1] = lenmax(cls_list[i+1][j], cls_list[i][j+1], cls_list[i][j] + [s[i]])
        else:
            cls_list[i+1][j+1] = lenmax(cls_list[i+1][j], cls_list[i][j+1])

print("".join(cls_list[-1][-1]))

### FIXED CODE ###

s = input()
t = input()
ls, lt = len(s), len(t)

dp_list = [ [ 0 for i in range(ls+1) ] for j in range(lt+1) ]
index_list = [ [ None for i in range(ls) ] for j in range(lt) ]

for i in range(lt):
    for j in range(ls):
        if t[i] == s[j]:
            a = dp_list[i+1][j]
            b = dp_list[i][j+1]
            c = dp_list[i][j] + 1 
            p = [a,b,c].index(max(a,b,c))
            dp_list[i+1][j+1] = [a,b,c][p]
            index_list[i][j] = (1,p)

        else:
            a = dp_list[i+1][j]
            b = dp_list[i][j+1]
            p = [a,b].index(max(a,b))
            dp_list[i+1][j+1] = [a,b][p]
            index_list[i][j] = (0,p)

q = dp_list[-1][-1]
r = t   

a = 10**5

ans = ""
y, x = lt-1, ls-1
while y != -1 and x != -1:
    if index_list[y][x][1] == 2:
        x -= 1
        y -= 1
        ans += s[x+1]
    elif index_list[y][x][1] == 1:
        y -= 1
    elif index_list[y][x][1] == 0:
        x -= 1

print(ans[::-1])
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
i = 0
j = 1
ans = 0
p = 0
nextj = 0
while True:
    if j == n:
        i += 1
        p = 0
        j = min(n-1,min(i+a[i]+1,nextj))

    
    if p == 0 and a[i] + a[j] == j-i:
        ans += 1
        nextj = j
        p = 1
    elif p == 1 and a[i] + a[j] == j-i:
        ans += 1
    j += 1
    
    if i == n-1:
        print(ans)
        exit()
        

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
mae = {}
ans = 0
for i in range(n):
    mae[i+a[i]]=mae.get(i+a[i],0)+1
    ans += mae.get(i-a[i],0)
print(ans)
### BUGGY CODE ###

a = int(input())
ar = []
for i in range(a):
    l = list(map(int,input().split(" ")))
    ar.insert(0,l)
count = 0
for r in ar:
    i = r[0] + count
    j = r[1]
    while True:
        if i % j == 0:
            break
        else:
            i += 1
            count += 1
print(count)
            

### FIXED CODE ###

a = int(input())
ar = []
for i in range(a):
    l = list(map(int,input().split(" ")))
    ar.append(l)
ar.reverse()
count = 0
for r in ar:
    x = r[0] + count
    y = r[1]
    m = x % y
    if m != 0:
        count += y - m
print(count)
### BUGGY CODE ###

N, M = map(int, input().split())
L = [0] * M
R = [0] * M
count = 0
for i in range(M):
    L[i], R[i] = map(int, input().split())
for i in range(N):
    clear = 0
    for j in range(M):
        if L[j] <= i + 1 <= R[j]:
            clear += 1
        else:
            break
    if clear == M:
        count += 1
print(count)


### FIXED CODE ###

N, M = map(int, input().split())
L = [0] * M
R = [0] * M
count = 0
for i in range(M):
    L[i], R[i] = map(int, input().split())
Lmax = max(L)
Rmin = min(R)
if Lmax <= Rmin:
    print(Rmin - Lmax + 1)
else:
    print(0)
### BUGGY CODE ###

#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-

# abc125_c
import fractions, functools, itertools

# input
n = int(input())
A = [int(s) for s in input().split()]
# get ans
x = A[0]
y = A[1]
def divisors(n):
     for i in range(1, n+1):
        if n%i == 0:
            yield i
ds = set(divisors(x)) | set(divisors(y))
def condition(d):
    not_div = (a%d != 0 for a in A)
    not_div = (1 if b else 0 for b in not_div)
    return sum(not_div) <= 1
ans = max(filter(condition, ds))
# output
print(ans)



### FIXED CODE ###

#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-

# abc125_c
import fractions, functools, itertools

# input
n = int(input())
A = [int(s) for s in input().split()]
# get ans
gcd = fractions.gcd
L = list(itertools.accumulate(A, gcd))
R = list(itertools.accumulate(A[::-1], gcd))
R = R[::-1]
L.append(0)
R.append(0)
gs = [gcd(L[i-1], R[i+1]) for i in range(n)]
ans = max(gs)
# output
print(ans)
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
    a = int(input())
    # print(A, a)
    if a not in A:
        A.append(a)

    else:
        A.remove(a)
print(len(A))

### FIXED CODE ###

N = int(input())
A = {}
for _ in range(N):
    a = int(input())
    if a not in A:
        A[a] = 1
    else:
        A[a] += 1
count = 0
for val in A.values():
    if val % 2 == 0:
        continue
    else:
        count+= 1
print(count)
### BUGGY CODE ###

N = int(input())
A = (list(map(int, input().split(' '))))
D = [0]*(10**6+1)
ans = 0
for i in A:
    D[i] += 1
for i in A:
    flg = True
    if D[i] > 1:
        continue
    for j in range(1,int(i**0.5)+2):
        if not i%j:
            if j != i//j:
                if D[i//j] and i//j != i:
                    flg = False
                    break
            if D[j] and i != j:
                flg = False
                break
    if flg:
        ans += 1
print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = Counter(list(map(int,input().split(' '))))
ans = 0
m = max(A.keys())
L = [1]*(10**6+1)
for i in sorted(A.keys()):
    if not L[i]:
        continue
    if A[i] == 1:
        ans += 1
    for j in range(i,m+1,i):
        L[j] = 0
print(ans)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
sum=0
list=[0]*N
list2=[0]*N

for n in range(N):
  list[n]=A.count(n+1)

for n in range(N):
  sum += list[n]*(list[n]-1)//2
  

for n in range(N):
  if list[n]>0:
  	list2[n]=sum-list[n]*(list[n]-1)//2+(list[n]-1)*(list[n]-2)//2
  
for a in A:
  print(list2[a-1])
  
  


    


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
sum=0
list=[0]*N
list2=[0]*N

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

for n in range(N):
  sum += list[n]*(list[n]-1)//2
  

for n in range(N):
  if list[n]>0:
  	list2[n]=sum-list[n]*(list[n]-1)//2+(list[n]-1)*(list[n]-2)//2
  
for a in A:
  print(list2[a-1])