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

N=int(input())
S=input()
r=S.count("R")
g=S.count("G")
b=S.count("B")
ans=r*g*b
for i in range(N):
  x=S[i]
  for j in range(i+1,N):
    if(S[j]!=x):
      y=S[j]
      if(2*j-i>=0 and 2*j-i<N):
        if(S[2*j-i]!=x and S[2*j-i]!=y):
          ans-=1
print(ans)

### FIXED CODE ###

N=int(input())
S=input()
r=S.count("R")
g=S.count("G")
b=S.count("B")
ans=r*g*b
for i in range(N):
  x=S[i]
  for j in range(i+1,N):
    if(S[j]!=x):
      y=S[j]
      if(2*j-i>=0 and 2*j-i<N):
        if(S[2*j-i]!=x and S[2*j-i]!=y):
          ans-=1
print(ans)
### BUGGY CODE ###

import math
import bisect
import copy
#int型として読み込む
n = int(input())


#同じくint型でリスト化する
list1 = list(map(int,input().split()))
list1.sort()
cout = 0
m,k = 0,0
while True:
	if m == n-2:
		break
	o = list1.pop(0)
	list1_c = copy.deepcopy(list1) #ここでjのためのdeepcopyを更新
	while True:
		if k == len(list1):
			break
		p = list1_c.pop(0)

		a = abs(o-p) +1
		b = o+p -1 #<= ではなく<条件に揃える

		c = bisect.bisect_left(list1_c,a)
		d = bisect.bisect_right(list1_c,b)

		if c < d:
			cout += d-c
		k+=1

		
		#list1.insert(j,p)
	#list1.insert(i,o)
	k = 0
	m += 1

print(cout)

### FIXED CODE ###

import bisect
import copy

n = int(input())
list1 = list(map(int,input().split()))
list1.sort()

cout = 0
m,k = 0,0

for i in range(n-2):
	o = list1.pop(0)
	for j in range(n-i-1):
		p = list1[j]

		a = abs(o-p) +1
		b = o+p -1 #<= ではなく<条件に揃える

		d = bisect.bisect_right(list1[j+1:],b)
		
		cout += d

print(cout)
### BUGGY CODE ###

import sys
from collections import deque
import copy
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

if __name__ == '__main__':
  n,m,k=map(int,input().strip("\n").split())
  A=deque()
  mapA=map(int,input().strip("\n").split())
  for a in mapA:
    A.append(a)
  B=deque()
  mapB=map(int,input().strip("\n").split())
  for b in mapB:
    B.append(b)
  #A=list(map(int,input().strip("\n").split()))
  #B=list(map(int,input().strip("\n").split()))
#  A.append(10**9+1)
#  B.append(10**9+1)

  #def dfs(a,b,k,s):
  def dfs(A,B,k,s):
    if k<0:
      return s-1
    if k==0:
      return s
    ansA=s
    ansB=s
    if len(A)>0:
      x=copy.deepcopy(A)
      y=copy.deepcopy(B)
      tmp=x.popleft()
      ansA=dfs(x,y,k-tmp,s+1)
    #if a<n:
    #  ansA=dfs(a+1,b,k-A[a],s+1)
    #else:
    #  ansA=s
    if len(B)>0:
      #print(A)
      x=copy.deepcopy(A)
      y=copy.deepcopy(B)
      tmp=y.popleft()
      ansB=dfs(x,y,k-tmp,s+1)
    #if b<m:
    #  ansB=dfs(a,b+1,k-B[b],s+1)
    #else:
    #  ansB=s
    return max(ansA,ansB)

  x=copy.deepcopy(A)
  y=copy.deepcopy(B)
  ans=dfs(x,y,k,0)
  #ans=max(dfs(1,0,k-A[0],1),dfs(0,1,k-B[0],1))
  print(ans)


### FIXED CODE ###

import sys
from collections import deque
import copy
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

if __name__ == '__main__':
  n,m,k=map(int,input().strip("\n").split())
  A=list(map(int,input().strip("\n").split()))
  B=list(map(int,input().strip("\n").split()))
  t=sum(B)
  j=m
  ans=0
  for i in range(n+1):
    while j>0 and t>k:
      j-=1
      t-=B[j]
    if t>k:
      break
    ans=max(ans,i+j)
    if i==n:
      break
    t+=A[i]
  print(ans)
### BUGGY CODE ###

K = int(input())
trip = dict()

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

    while b:
        a %= b
        a, b = b, a

    return a

def gcd3(K):

    res = 0

    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                l = frozenset([i, j, k])
                if l in trip:
                    res += trip[l]
                    continue

                x = gcd(i, gcd(j, k))
                # print("i:%d, j:%d, k:%d, x:%d" % (i, j, k, x))
                res += x
                trip[l] = x

    return res

print(gcd3(K))

### FIXED CODE ###

import math 

K = int(input())

def sol(K):
    res = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            t = math.gcd(i, j)
            for k in range(1, K+1):
                res += math.gcd(k, t)

    return res
  
print(sol(K))
### BUGGY CODE ###

import itertools

K,S = map(int,input().split())
cnt = 0
for i in itertools.product(range(K+1),repeat = 3):
    if i[0] + i[1] + i[2] == S:
        cnt += 1
print(cnt)

### FIXED CODE ###

k,s=map(int,input().split())
cnt=0
for x in range(k+1):
  for y in range(k+1):
    if 0 <= (s-x-y) <= k:
      cnt+=1
print(cnt)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
def calc_results(results, pvalue, i):
  results[i] = pvalue + values[i]
  if childrens[i] is None:
    return
  for j in childrens[i]:
    calc_results(results, results[i], j)
n, q = map(int, input().split())
values = [0] * (n + 1)
results = [0] * (n + 1)
childrens = [None] * (n + 1)
dc = [None for i in range(0, n + 1)]
for i in range(n - 1):
  a, b = map(int, input().split())
  if childrens[a] is None:
    childrens[a] = []
  childrens[a].append(b)
for _ in range(q):
  p, x = map(int, input().split())
  values[p] += x
calc_results(results, 0, 1)
print(*[results[i] for i in range(1, n + 1)])



### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
def main():
  _map = map
  _input = input
  _int = int
  def calc_results(results, pvalue, i):
    results[i] = pvalue + values[i]
    for j in childrens[i]:
      calc_results(results, results[i], j)
  n, q = _map(_int, _input().split())
  values = [0] * (n + 1)
  results = [0] * (n + 1)
  childrens = [[] for _ in range(n + 1)]
  for i in range(n - 1):
    a, b = _map(_int, _input().split())
    childrens[a].append(b)
  for _ in range(q):
    p, x = _map(_int, _input().split())
    values[p] += x
  calc_results(results, 0, 1)
  print(*[results[i] for i in range(1, n + 1)])
main()
### BUGGY CODE ###

n=int(input())
v=input().split()
o=[("0",0)]
e=[("0",0)]
for i in range(n//2):
    I=2*i
    O=len(o)
    E=len(e)
    for j in range(O):
        if v[I]==o[j][0]:
            o[j]=(o[j][0],o[j][1]+1)
            break
        elif j==O-1:
            o.append((v[I],1))
    for k in range(E):
        if v[I+1]==e[k][0]:
            e[k]=(e[k][0],e[k][1]+1)
            break
        elif k==E-1:
            e.append((v[I+1],1))
o.sort(key=lambda x:-x[1])
e.sort(key=lambda x:-x[1])
if o[0][0]==e[0][0]:
    if o[0][1]<e[0][1]:
        m=e[0][1]+o[1][1]
    else:
        m=o[0][1]+e[1][1]
else:
    m=o[0][1]+e[0][1]
print(n-m)

### FIXED CODE ###

N=int(input())
V=list(map(int,input().split()))
o={0:0}
e={0:0}
n=1
for i,v in enumerate(V):
    if n:
        if v in o.keys():
            o[v]+=1
        else:
            o[v]=1
    else:
        if v in e.keys():
            e[v]+=1
        else:
            e[v]=1
    n=1-n
O=sorted(o.items(),key=lambda x:-x[1])
E=sorted(e.items(),key=lambda x:-x[1])
if O[0][0]==E[0][0]:
    m=max(O[0][1]+E[1][1],E[0][1]+O[1][1])
else:
    m=O[0][1]+E[0][1]
print(N-m)
### BUGGY CODE ###

from collections import defaultdict
import itertools
from functools import reduce


def analyze(string):
  s_count = defaultdict(int)
  for s in string:
    s_count[s] += 1
  counts = list(s_count.values())
  return counts

def count(counts, num_set):
    if num_set == 1:
        return sum(counts)
    if num_set == 2:
        num_sum = sum(counts)
        ans = 0
        for i in range(len(counts)):
            num_sum -= counts[i]
            ans += counts[i] * num_sum
        return ans

    ans = 0
    for i in range(len(counts) - 1):
        ans += counts[i] * count(counts[i + 1:], num_set - 1)
    return ans

N = int(input())
string = input()

counts = analyze(string)
ans = 0
for i in range(1, len(counts) + 1):
    ans += count(counts, i)
print(ans % (10**9 + 7))


### FIXED CODE ###

from collections import defaultdict
import itertools
from functools import reduce


def analyze(string):
  s_count = defaultdict(int)
  for s in string:
    s_count[s] += 1
  counts = tuple(s_count.values())
  return counts

N = int(input())
string = input()

def search(N, string):
    memo = {}
    def count(counts, num_set):
        if (counts, num_set) in memo:
            return memo[(counts, num_set)]

        if num_set == 1:
            ans = sum(counts)
        elif num_set == 2:
            num_sum = sum(counts)
            ans = 0
            for i in range(len(counts)):
                num_sum -= counts[i]
                ans += counts[i] * num_sum
        else:
            ans = 0
            for i in range(len(counts) - 1):
                ans += counts[i] * count(counts[i + 1:], num_set - 1)

        memo[(counts, num_set)] = ans
        return ans

    counts = analyze(string)
    ans = 0
    for i in range(1, len(counts) + 1):
        ans += count(counts, i)
    print(ans % (10**9 + 7))

search(N, string)
### BUGGY CODE ###

#a,b=map(int,input().split())
import numpy as np

s=input()
n=len(s)
MOD=1000000007
wayA=np.array([0,0,0,0],dtype=np.int64)
wayB=np.array([0,0,0,0],dtype=np.int64)
wayC=np.array([0,0,0,0],dtype=np.int64)
MOD2=np.array([MOD,MOD,MOD,MOD],dtype=np.int64)
hatena=0
for c in s:
	if c=="A":
		wayA[0]+=1
	if c=="B":
		wayB+=wayA
	if c=='C':
		wayC+=wayB
	if c=='?':
		wayC+=np.roll(wayB,1)
		wayB+=np.roll(wayA,1)
		wayA[1]+=1
		hatena+=1
	wayA%=MOD2
	wayB%=MOD2
	wayC%=MOD2
ans=0
for i in range(0,4):
	ans+=pow(3,hatena-i)*wayC[i]
	ans=ans%MOD
print(int(ans))

### FIXED CODE ###

#a,b=map(int,input().split())
import numpy as np

s=input()
n=len(s)
wayA=np.array([0,0,0,0],dtype=np.int64)
wayB=np.array([0,0,0,0],dtype=np.int64)
wayC=np.array([0,0,0,0],dtype=np.int64)
hatena=0
MOD=1000000007
for c in s:
	if c=="A":
		wayA[0]=wayA[0]+1
	if c=="B":
		wayB+=wayA;
	if c=='C':
		wayC=wayC+wayB
	if c=='?':
		wayC[1]=wayC[1]+wayB[0]
		wayC[2]=wayC[2]+wayB[1]
		wayC[3]=wayC[3]+wayB[2]
		wayB[1]=wayB[1]+wayA[0]
		wayB[2]=wayB[2]+wayA[1]
		wayA[1]=wayA[1]+1
		hatena=hatena+1
	for z in range(0,4):
		wayA[z]=wayA[z]%MOD
		wayB[z]=wayB[z]%MOD
		wayC[z]=wayC[z]%MOD
ans=0
for i in range(0,4):
	p3=1
	if wayC[i]<=0:
		continue
	for k in range(0,hatena-i):
		p3=p3*3
		p3=p3%MOD
	ans=ans+p3*wayC[i]
	ans=ans%MOD
print(int(ans))
### BUGGY CODE ###

N = int(input())
V = [int(v) for v in input().split()]
V_135 = []
V_246 = []
for n in range(N):
  if n % 2 == 0:
    V_135.append(V[n])
  else:
    V_246.append(V[n])

how_many_replace = 0
mx_cnt = 0
for i in range(len(V_135)):
  cnt = V_135.count(V_135[i])
  if cnt > mx_cnt:
    mx_cnt = cnt
    mx_cnt_nm_V_135 = V_135[i]
how_many_replace += (len(V_135)-mx_cnt)

mx_cnt = 0
for i in range(len(V_246)):
  cnt = V_246.count(V_246[i])
  if cnt > mx_cnt:
    if V_246[i] != mx_cnt_nm_V_135:
      mx_cnt = cnt
how_many_replace += (len(V_246)-mx_cnt)

print(how_many_replace)

### FIXED CODE ###

n = int(input())
V = [int(v) for v in input().split()]

V1 = [V[n] for n in range(0, n, 2)] #v1, v3, v5, ...
V2 = [V[n] for n in range(1, n, 2)] #v2, v4, v6, ...

mx_V1 = max(V1)
V1_cnt = [[0, 0]] # V1に一種類しか数字が存在しなかったときのために
for i in range(1, mx_V1+1):
  V1_cnt.append([i, 0])
for v in V1:
  V1_cnt[v][1] += 1  
V1_cnt.sort(key=lambda x: x[1], reverse=True)

mx_V2 = max(V2)
V2_cnt = [[0, 0]] # V2に一種類しか数字が存在しなかったときのために
for j in range(1, mx_V2+1):
  V2_cnt.append([j, 0])
for v in V2:
  V2_cnt[v][1] += 1  
V2_cnt.sort(key=lambda x: x[1], reverse=True)

mxnum_V1_cnt = V1_cnt[0][0] #V1の中で一番出現回数多い数字
mxnum_V2_cnt = V2_cnt[0][0] #V2の中で一番出現回数多い数字
if mxnum_V1_cnt != mxnum_V2_cnt:
  ans = n - (V1_cnt[0][1] + V2_cnt[0][1])
else:
  ans = n - max(V1_cnt[0][1] + V2_cnt[1][1], V1_cnt[1][1] + V2_cnt[0][1])

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

# from math import gcd
from fractions import gcd
from functools import reduce

n = int(input())
a = [int(x) for x in input().split()]

def lcm_list(numbers):
    return reduce(lambda x, y: (x * y) // gcd(x, y), numbers, 1)

lcm = lcm_list(a)
aa = []
for i in range(len(a)):
    aa.append(lcm // a[i])
ans = sum(aa) % 1000000007
print(ans)

### FIXED CODE ###

# from math import gcd
from fractions import gcd
from functools import reduce

def lcm_list(numbers):
    return reduce(lambda x, y: (x * y) // gcd(x, y), numbers, 1)

def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    lcm = lcm_list(a)
    aa = []
    for i in range(len(a)):
        aa.append(lcm // a[i])
    ans = sum(aa) % 1000000007
    print(ans)

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

NN,a,b=map(int,input().split())
mod=(10**9+7)
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under



D=[1,2,4]
d=[0,1,2]
for i in range(3,31):
    d.append(d[-1]*2)
    D.append((D[-1]**2)%mod)
D=D[::-1]
d=d[::-1]
#print(len(D),D)
#print(len(d),d)
Num=NN
ALL=1
for i in range(31):
    if Num>=d[i]:
        Num-=d[i]
        ALL*=D[i]
        ALL%=mod
if Num==1:
    Num-=1
    ALL*=2
    ALL%=mod
#print(ALL,Num)

A=cmb(NN,a)%mod
B=cmb(NN,b)%mod
#print(A,B)

if NN<a or NN<b:
    print(0)
else:
    if ALL-A-B-1<0:
        print((ALL-A-B-1+mod*2)%mod)
    else:
        print(ALL-A-B-1)

### FIXED CODE ###

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

MOD=10**9+7
def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

print((pow(2,N,MOD) - comb(N , A) - comb(N , B) - 1 ) % MOD )
### BUGGY CODE ###

from collections import deque

def bfs(graph, visited, ss, g):
  queue = deque([ss])
  visited[ss] = 0
  while queue:
    s = queue.popleft()
    #　返り値に関する条件
    if visited[g] != -1 :
        return visited
    for new_s in range(n) :
      if graph[new_s][s] == 1 and visited[new_s] == -1:
        #　移動回数の計算
        visited[new_s] = visited[s] + 1
        queue.append(new_s)
  return visited

n,m = map(int,input().split())
graph = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a,b = map(int, input().split())
    graph[a-1][b-1] = 1
    graph[b-1][a-1] = 1
 
d = [0]*n
for g in range(1,n) :
    visited = [-1]*n
    d[g] = bfs(graph, visited, 0, g)[g]

maxd = max(d)
dpt = [[] for i in range(maxd+1)]
for i in range(maxd+1) :
    dpt[i] = [n for n, v in enumerate(d) if v == i]

if -1 in d :
    print('No')
else :
    print('Yes')
    for i in range(1,n) :
        print(dpt[d[i]-1][0]+1)

### FIXED CODE ###

from collections import deque

def bfs(graph, visited, ss):
  queue = deque([ss])
  visited[ss] = 0
  ans = [0]*n
  while queue:
    s = queue.popleft()
    for new_s in graph[s] :
      if visited[new_s] == -1:
        #　移動回数の計算
        visited[new_s] = visited[s] + 1
        queue.append(new_s)
        ans[new_s] = s
  return ans

n,m = map(int,input().split())
graph = [[] for j in range(n)]

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

visited = [-1]*n
ans = bfs(graph, visited, 0)

print('Yes')
for i in range(1,n) :
  print(ans[i]+1)
### BUGGY CODE ###

L = input()
digits = len(L)
MOD = 10**9 + 7
ans = pow(2, L.count('1'), MOD)
for i, d in enumerate(L, 1):
    if d == '1': ans = (ans + (pow(3, digits - i, MOD) * pow(2, L[:i-1].count('1'), MOD)) % MOD) % MOD
print(ans)

### FIXED CODE ###

L = input()
digits = len(L)
MOD = 10**9 + 7
ans = pow(2, L.count('1'), MOD)
counter = 0
for i, d in enumerate(L, 1):
    if d == '1':
        ans = (ans + (pow(3, digits - i, MOD) * pow(2, counter, MOD)) % MOD) % MOD
        counter += 1
print(ans)
### BUGGY CODE ###

n, a, b = map(int, input().split())
mod = 10**9+7
ans = (2**n-1)%mod

nCa = 1
for i in range(a):
  nCa *= n-i
  nCa %= mod
  nCa *= pow(a-i, mod-2, mod)
  nCa %= mod

nCb = 1
for i in range(b):
  nCb *= n-i
  nCb %= mod
  nCb *= pow(b-i, mod-2, mod)
  nCb %= mod  
  
print((ans-nCa-nCb)%mod)

### FIXED CODE ###

n, a, b = map(int, input().split())
mod = 10**9+7
ans = (pow(2,n,mod)-1)%mod

f = 1
for i in range(1, 200001):
  f *= i
  f %= mod

finv = [1]*200001
finv[200000] = pow(f, mod-2, mod)
for i in range(199999, 0, -1):
  finv[i] = finv[i+1]*(i+1)%mod

nCa = 1
for i in range(a):
  nCa *= n-i
  nCa %= mod
nCa *= finv[a]
nCa %= mod
  
nCb = 1
for i in range(b):
  nCb *= n-i
  nCb %= mod
nCb *= finv[b]
nCb %= mod

print((ans-nCa-nCb)%mod)
### BUGGY CODE ###

# ABC-141-D
N, M = map(int, input().split())
A = list(map(int, input().split()))

for _ in range(M):
    A[A.index(max(A))] //= 2
    
print(sum(A))

### FIXED CODE ###

# ABC-141-D
# https://qiita.com/ellio08/items/fe52a9eb9499b7060ed6
import heapq

N, M = map(int, input().split())
A = [i * (-1) for i in list(map(int, input().split()))]
heapq.heapify(A)

for _ in range(M):
    tmp = heapq.heappop(A) * (-1)
    heapq.heappush(A, (tmp//2)*-1)

# これだとTLEになる。
# for _ in range(M):
#     A[A.index(max(A))] //= 2

print(sum(A)*-1)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
N,Q = map(int,input().split())
tree = [[] for _ in range(N)]
cnt = [0]*N
for _ in range(N-1):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
for _ in range(Q):
    p,x = map(int,input().split())
    cnt[p-1] += x
sys.setrecursionlimit(10 ** 6)
def dfs(cur,parent):
    li = tree[cur]
    for chi in li:
        if chi == parent:
            continue
        cnt[chi] += cnt[cur]
        dfs(chi,cur)
dfs(0,-1)
print(*cnt)


### FIXED CODE ###

import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
N,Q = map(int,input().split())
tree = [[] for _ in range(N)]
cnt = [0]*N
for _ in range(N-1):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
for _ in range(Q):
    p,x = map(int,input().split())
    cnt[p-1] += x
sys.setrecursionlimit(10 ** 6)
def dfs(cur,parent):
    li = tree[cur]
    for chi in li:
        if chi == parent:
            continue
        cnt[chi] += cnt[cur]
        dfs(chi,cur)
dfs(0,-1)
print(" ".join(map(str,cnt)))
### BUGGY CODE ###

s = input()
x,y = map(int, input().split())
dp = [[[False]*(len(s)*4+1) for _ in range(2)] for _ in range(2)]
 
dp[0][0][0] = True
dp[0][1][0] = True
#print(dp)
index = 0
while index < len(s) and s[index] == 'F':
  index += 1
x -= index
xy_axis = 1
dp_index = 1
i = index+1
while i < len(s):
  num = 0
  while i < len(s) and s[i] == 'F':
    num += 1
    i += 1
  #print(num)
  for j in range(-len(s), len(s)+1):
    dp[dp_index][xy_axis][j] = dp[(dp_index+1)%2][xy_axis][j-num] or dp[(dp_index+1)%2][xy_axis][j+num]
  xy_axis = (xy_axis+1) % 2
  if xy_axis == 1:
      dp_index = (dp_index+1) % 2
  i += 1
 
#print(dp)
 
if dp[(dp_index + 1) % 2][0][x] and dp[(dp_index + xy_axis) % 2][1][y]:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

import datetime
s = input()
x, y = map(int, input().split())
#print(datetime.datetime.now())
 
num_of_f = 0
for c in s:
    if c == 'F':
        num_of_f += 1
dp = [[[False] * 32001 for _ in range(2)] for _ in range(2)]
 
dp[0][0][0] = True
dp[0][1][0] = True
# print(dp)
index = 0
while index < len(s) and s[index] == 'F':
    index += 1
x -= index
xy_axis = 1
dp_index = 1
i = index + 1
num_of_f = index
while i < len(s):
    num = 0
    while i < len(s) and s[i] == 'F':
        num += 1
        i += 1
    num_of_f += num
    for j in range(-1 * num_of_f, num_of_f + 1):
        dp[dp_index][xy_axis][j] = dp[(dp_index + 1) % 2][xy_axis][j - num] or dp[(dp_index + 1) % 2][xy_axis][j + num]
    xy_axis = (xy_axis + 1) % 2
    if xy_axis == 1:
        dp_index = (dp_index + 1) % 2
    i += 1
 
# print(dp)
 
if dp[(dp_index + 1) % 2][0][x] and dp[(dp_index + xy_axis) % 2][1][y]:
    print('Yes')
else:
    print('No')
#print(datetime.datetime.now())
### BUGGY CODE ###

import copy
import collections
def kaijyou(k):
  N=1
  for i in range(k,0,-1):
    N*=i
  return N

def combinations(n,r):
  return int(kaijyou(n)/(kaijyou(r)*kaijyou(n-r)))

N=int(input())
A=list(map(int,input().split()))
B=sorted(set(A))
dp=[]

for i in B:
  C=copy.copy(A)
  C.remove(i)
  c=collections.Counter(C)
  e=c.values()
  f=0
  for k in e:
    f+=combinations(k,2)
  dp.append(f)
for i in A:
  print(dp[B.index(i)])

### FIXED CODE ###

import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)

#全体の数列について答えを求めるnC2=n(n-1)/2
ALL=0
for i in c.values():
  if i>1:
    ALL += i*(i-1)//2

#各要素が影響する分を求める
for i in A:
  if c[i]>2:
    print(ALL-c[i]+1)
  elif c[i]==2:
    print(ALL-1)
  else:
    print(ALL)
### BUGGY CODE ###

import sys

input = lambda: sys.stdin.readline().rstrip()
INF = 10 ** 9 + 7

H, N = map(int, input().split())
AB = [[] for _ in range(N)]
for i in range(N):
    AB[i] = list(map(int, input().split()))


def solve():

    dp = [INF] * (H + 1)
    dp[H] = 0

    for h in range(H, 0, -1):

        if dp[h] == INF:
            continue
        next_dp = dp

        for i in range(N):
            a, b = AB[i]
            hh = max(0, h - a)
            next_dp[hh] = min(dp[hh], dp[h] + b)

        dp = next_dp

    print(dp[0])


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys

input = lambda: sys.stdin.readline().rstrip()
INF = 10 ** 9 + 7

H, N = map(int, input().split())
AB = [[] for _ in range(N)]
for i in range(N):
    AB[i] = list(map(int, input().split()))


def solve():

    dp = [INF] * (H + 1)
    dp[H] = 0

    for h in range(H, 0, -1):

        if dp[h] == INF:
            continue
        next_dp = dp

        for i in range(N):
            a, b = AB[i]
            hh = max(0, h - a)
            next_dp[hh] = min(dp[hh], dp[h] + b)

        dp = next_dp

    print(dp[0])


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

import copy
import functools
import fractions

n=int(input())
lstA=list(map(int,input().split()))
maximum=max(lstA)
gcdlst=[]

for i in range(n):
    cplstA=copy.copy(lstA)
    del cplstA[i]
    gcdlst.append(functools.reduce(fractions.gcd, cplstA))

print(max(gcdlst))


### FIXED CODE ###

#import sys
#input=sys.stdin.readline

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


def main():
    n = int(input())
    A = list(map(int, input().split()))
    gcdA = [0]*n
    gcdB = [0]*n
    gcdA[0] = A[0]
    gcdB[n-1] = A[n-1]
    for i in range(1, n):
        gcdA[i] = gcd(A[i], gcdA[i-1])
        gcdB[n-i-1] = gcd(A[n-i-1], gcdB[n-i])
    ans = max(gcdA[n-2], gcdB[1])
    for i in range(1, n-1):
        ans = max(ans, gcd(gcdA[i-1], gcdB[i+1]))
    print(ans)


if __name__ == "__main__":
    main()