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

n = int(input())
ar = list(map(int,input().split()))
ans=1
for i in ar:
    ans*=i
if ans>1e18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
else:
    ans=1
    for i in ar:
        ans*=i
        if ans>1e18:
            break
    if ans>1e18:
        print(-1)
    else:
        print(ans)
### BUGGY CODE ###

import numpy as np

N, K = map(int,input().split())
MOD = 10**9+7

# dp[i][j][k]:
# ウサギ1~i, カメ1~i (うちj個は相手が未定)まで見ていて，
# 確定している奇妙さがkであるような場合の数
dp = np.zeros((55,55,55*55), dtype='int64')
dp[0][0][0] = 1

for i in range(N+1):
    for j in range(N+1):
        for k in range(N*N+1):
            if k-2*j < 0 or i-1 < 0: continue

            dp[i][j][k] += (2*j+1) * dp[i-1][j][k-2*j] % MOD
            dp[i][j][k] %= MOD

            dp[i][j][k] += (j+1)*(j+1) * dp[i-1][j+1][k-2*j] % MOD
            dp[i][j][k] %= MOD

            if j > 0:
                dp[i][j][k] += dp[i-1][j-1][k-2*j]
                dp[i][j][k] %= MOD
            
print(dp[N][0][K])

### FIXED CODE ###

N, K = map(int,input().split())
MOD = 10**9+7

# dp[i][j][k]:
# ウサギ1~i, カメ1~i (うちj個は相手が未定)まで見ていて，
# 確定している奇妙さがkであるような場合の数
dp = []
for _ in range(55):
    dp.append([[0] * (55*55) for _ in range(55)])

dp[0][0][0] = 1

for i in range(N+1):
    for j in range(N+1):
        for k in range(N*N+1):
            if k-2*j < 0 or i-1 < 0: continue

            dp[i][j][k] += (2*j+1) * dp[i-1][j][k-2*j] % MOD
            dp[i][j][k] %= MOD

            dp[i][j][k] += (j+1)*(j+1) * dp[i-1][j+1][k-2*j] % MOD
            dp[i][j][k] %= MOD

            if j > 0:
                dp[i][j][k] += dp[i-1][j-1][k-2*j]
                dp[i][j][k] %= MOD
            
print(dp[N][0][K])
### BUGGY CODE ###

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K, *H = map(int, read().split())
H.sort()
ans = 10 ** 9
for i in range(N - K + 1):
    ans = min(max(H[i:i + K]) - min(H[i:i + K]), ans)
print(ans)


### FIXED CODE ###

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K, *H = map(int, read().split())
H.sort()
print(min(H[i+K-1]-H[i] for i in range(N-K+1)))
### BUGGY CODE ###

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


for i in range(1, n+1):
    print(stu.index(i) + 1, end=' ')
print('')

### FIXED CODE ###

import numpy as np

n = int(input())
stu = list(map(int, input().split()))
stu = np.argsort(stu)

[print(i + 1, end=" ") for i in stu]
print()
### BUGGY CODE ###

word = input()
maxLength = len(word)
for i in range(maxLength):
  if (word[i] == '?'):
    if ((word[i-1] == 'P') or (i == len(word)-1)):
    	word = word[:i] + 'D' + word[i+1:]
    elif ((i != len(word) -1) and ((word[i+1] == "D") or word[i+1] == "?")):
    	word = word[:i] + 'P' + word[i + 1:]
    else:
    	word = word[:i] + 'D' + word[i+1:]
print(word)

### FIXED CODE ###

word = input()
start = 0
end = len(word)
while(True):
	i = word.find('?', start, end)
	if (i == -1):
		break
	elif (i == (end-1)):
		word = word.replace('?', "D", 1)   
	elif (word[i-1] == 'P'):
		word = word.replace('?', "D", 1)
	elif ((word[i+1] == "?") or (word[i+1] == "D")):
		word = word.replace('?', "P", 1)
	else:
		word = word.replace('?', "D", 1)
	start = i + 1
print(word)
### BUGGY CODE ###

def f(k):
    def lunlun(n):
        s = [int(i) for i in str(n)]
        for i in range(len(s) - 1):
            if abs(s[i] - s[i + 1]) > 1:
                return False
        return True
    i = 0
    while k > 0:
        i += 1
        if lunlun(i):
            k -= 1
    print(i)

f(int(input()))

### FIXED CODE ###

# ABC161D
def f(k):
    if 1 <= k <= 9:
        print(k)
    else:
        nxt = [[0,1], [0,1,2], [1,2,3], [2,3,4], [3,4,5], [4,5,6], [5,6,7], [6,7,8], [7,8,9], [8,9]]
        cum_npi = [0, 9, 35, 110, 327, 956, 2782, 8089, 23527, 68468, 199368]
        for length, begin in enumerate(cum_npi):
            if k < begin:
                found = cum_npi[length - 1]
                break
        begin = 10 ** (length - 1)
        length, begin, found
        k -= found
        x = [[]] * (length + 1)
        x[1] = list(range(1, 10))
        x

        terminate = False
        i = 1
        while True:
            #print(f"a) i = {i}  x = {x}")
            if len(x[i]): # len(x[i])
                digit = x[i][0]
                if i < length: # i, length
                    i += 1
                    x[i] = nxt[digit].copy()
                    #print(f"x) digit = {digit}  nxt[digit] = {nxt[digit]}  i = {i}  x[i] = {x[i]}")
                    #print(f"b) i = {i}  x = {x}")
                    if i == length: # i, length
                        while len(x[i]): # i, x[i]
                            k -= 1
                            #print(f"c) i = {i}  x = {x}, k = {k}")
                            if k == 0:
                                x.pop(0)
                                #print("answer =", x)
                                ans = "".join([str(j.pop(0)) for j in x])
                                print(ans)
                                terminate = True
                                break
                            else:
                                x[i].pop(0)
                            #print(f"d) i = {i}  x = {x}")
                        else:
                            #print(f"e) i = {i}  x = {x}")
                            while len(x[i]) == 0:
                                i -= 1
                                x[i].pop(0)
                        if terminate:
                            break

f(int(input()))
### BUGGY CODE ###

from itertools import islice

N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]


lst = []
for i in LR:
    lst_ = set(list(range(i[0],i[1]+1)))
    lst.append(lst_)

lst = set.intersection(set(lst[0]), *islice(lst, 1, None))
print(len(lst))


### FIXED CODE ###

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

L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

print(max(min(R) - max(L) + 1, 0))
### BUGGY CODE ###

N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))

def argmax(x):
  return max(enumerate(x), key=lambda x:x[1])[0]

while K > 0:
  now_costs = [a*f for a, f in zip(A, F)]
  if max(now_costs) < 1: break
  A[(argmax(now_costs))] -= 1
  K -= 1
print(max([a*f for a, f in zip(A, F)]))

### FIXED CODE ###

N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng == 1: break
  m = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    now_cost += max(a-(m//f), 0)
  if now_cost <= K:
    ok = m
  else:
    ng = m
    
print(ok)
### BUGGY CODE ###

from sys import stdin

def main():
    n, m, k = [int(x) for x in stdin.readline().rstrip().split()]

    pileda = 0
    a = [0]
    for x in stdin.readline().rstrip().split():
        x = int(x)
        pileda += x
        a.append(pileda)
    
    piledb = 0
    b = [0]
    for x in stdin.readline().rstrip().split():
        x = int(x)
        piledb += x
        b.append(piledb)

    ans = 0
    for ai, time_a in enumerate(a):
        if time_a > k:
            break
        for bi, time_b in enumerate(b):
            if time_a + time_b > k:
                break
            if time_a + time_b <= k and ai + bi > ans:
                ans = ai + bi
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from sys import stdin

def main():
    n, m, k = [int(x) for x in stdin.readline().rstrip().split()]

    pileda = 0
    a = [0]
    for x in stdin.readline().rstrip().split():
        x = int(x)
        pileda += x
        a.append(pileda)
    
    piledb = 0
    b = [0]
    for x in stdin.readline().rstrip().split():
        x = int(x)
        piledb += x
        b.append(piledb)

    ans = 0
    bi = m
    for ai, at in enumerate(a):
        if at > k:
            break

        while at + b[bi] > k:
            bi -= 1
        
        ans = max(ans, ai+bi)
    
    print(ans)
            

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

n=int(input())
s=input()
print(min([list(s[:i]).count("W")+list(s[i+1:]).count("E") for i in range(n)]))

### FIXED CODE ###

n=int(input())
s=input()
ans=[]
alle=list(s).count("E")
allw=n-alle
ecnt=wcnt=0
for i in range(n):
    if s[i] == "W":
        ans.append(wcnt+alle-ecnt)
        wcnt+=1
    else:
        ans.append(wcnt+alle-ecnt-1)
        ecnt+=1
print(min(ans))
### BUGGY CODE ###

import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

sub = -10000000000000
for i in range(len(a)):
    for j in range(len(b)):
        if j >= i:
            if sub <= b[j]-a[i]:
                sub = b[j]-a[i]
print(sub)


### FIXED CODE ###

import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

maxv = -1000000000
minv = a[0]
for i in range(len(a)):
    maxv = max(maxv,b[i]-minv)
    minv = min(minv,b[i])
print(maxv)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7

ans = 0
for i in range(n):
    plus = 0
    for j in range(i, n):
        if i == j:
            continue
        plus += a[j]%MOD
    ans += a[i]*plus 
    ans %= MOD
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
plus = 0
for i in range(n-1):
    plus += a[n-i-1]
    plus %= MOD
    ans += a[n-i-2]*plus
    ans %= MOD
print(ans%MOD)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))


N,Q=two_int()
S=one_str()

for i in range(Q):
    l,r =two_int()
    print(S[l-1:r].count("AC"))

### FIXED CODE ###

def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

length, N=two_int()

S=one_str()

ac_list = [0]

hoge = 0
for i in range(length-1):
    if S[i:i+2]=="AC":
        hoge += 1
    ac_list.append(hoge)

for i in range(N):
    l, r = two_int()
    print(ac_list[r-1] - ac_list[l-1])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = []

for i in range(n):
    temp = [a[i]]
    if i % 2 == 0:
        b.append(a[i])
    else:
        temp.extend(b)
        b = temp

if n % 2 == 1:
    b.reverse()

b = list(map(str,b))
print(" ".join(b))

### FIXED CODE ###

import collections

n = int(input())
a = list(map(int, input().split()))
b = collections.deque()

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if n % 2 == 1:
    b.reverse()

print(*b)
### BUGGY CODE ###

n,m = map(int,input().split())
s=[int(input()) for i in range(m)]
l=[1]
INF=1000000007
if n ==1:
    print(1)
    exit()
if len(s)!=0 and s[0]== 1:l.append(0)
else:l.append(1)

for i in range(2,n+1):
    if i in s:num=0
    else:num = (l[i-2]+l[i-1])%INF
    l.append(num)
print(l[-1])

### FIXED CODE ###

n,m = map(int,input().split())
s=set([int(input()) for i in range(m)])
l=[1]+[0]*n
INF=1000000007
if n ==1:
    print(1)
    exit()
if len(s)!=0 and 1 in s:l[1]=0
else:l[1]=1
for i in range(2,n+1):
    if i in s: l[i]=0
    else:l[i] = (l[i-2]+l[i-1])%INF
print(l[-1])
### BUGGY CODE ###

N = int(input())
ans = 0
for j in range(1, N+1):
  for i in range(1,N+1):
    if(i%j == 0):
      ans += i
print(ans)

### FIXED CODE ###

N = int(input())
ans = 0
for j in range(1, N+1):
  Y = int(N / j)
  ans += (j * Y*(Y+1)/2)
print(int(ans))
### BUGGY CODE ###

NK = input().split();
N,K = int(NK[0]),int(NK[1]);
min = N;

flag = True;
while flag == True:
    N = abs(N - K);
    if(N <= min):
        min = N;
    else:
        flag = False;
    
print(min);

### FIXED CODE ###

import math

NK = input().split();
N,K = int(NK[0]),int(NK[1]);
min = N;

#桁が大きい時の処理
if(K == 1):
    while(int(len(str(N))) > 2):
        N = int(N - K * (N / 2));
else:
    border = math.floor(N / K);
    N = N - K * border;
        
flag = True;
while flag == True:
    N = abs(N - K);
    if(N <= min):
        min = N;
    else:
        flag = False;
    
print(min);
### BUGGY CODE ###

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

k=int(input())
s=input()
lens=len(s)
mod=10**9+7
ans=0

dp=[0 for i in range(1+len(s)+k)]
dp[0]=1




l={i:1 for i in range(lens+10)}
for i in range(lens+1,lens+k+2):
    l[i]=l[i-1]*i//(i-lens)

now=1

for i in range(k+1):
    ans+=pow(25,i,mod)*pow(26,k-i,mod)*cmb(lens+i-1,lens-1,mod)
    ans=ans%mod

print(ans)

### FIXED CODE ###

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 2 * 10 ** 6 + 10 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

k=int(input())
s=input()
lens=len(s)
mod=10**9+7
ans=0

now=1

for i in range(k+1):
    ans+=pow(25,i,mod)*pow(26,k-i,mod)*cmb(lens+i-1,lens-1,mod)
    ans=ans%mod

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

def main():
	import sys
	sys.setrecursionlimit(700000)
	N, Q = map(int, input().split())
	d = [[] for i in range(N)]

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

	ans = [0]*N

	for i in range(Q):
		p, x = map(int, input().split())
		p -= 1
		ans[p] += x

	def dfs(cur, parent):
		for child in d[cur]:
			if child != parent:
				ans[child] += ans[cur]
				dfs(child,cur)
	dfs(0,-1) 
	print(*ans)
    
main()



### FIXED CODE ###

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

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    d[b] = a
ans = [0 for i in range(N)]

for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    ans[p] += x

for i in range(1, N):
    ans[i] += ans[d[i]]

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

def resolve():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    dp = [True for _ in range(max(A)+1)]
    counts = [0 for _ in range(max(A)+1)]
    for a in A:
        counts[a] += 1
        if dp[a] and counts[a] == 1:
            for j in range(a*2, max(A)+1, a):
                dp[j] = False
    cnt = 0
    #print(dp)
    for a in A:
        if dp[a] and counts[a] == 1:
            cnt += 1
    print(cnt)

if '__main__' == __name__:
    resolve()

### FIXED CODE ###

def resolve():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    import collections
    counter = collections.Counter(A)
    maxA = max(A)
    dp = [True for _ in range(max(A)+1)]
    for a in A:
        if counter[a] > 1:
            dp[a] = False
        for j in range(a+a, maxA+1, a):
            dp[j] = False
    #print(dp)
    print(sum(1 for a in A if dp[a]))

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

import sys
from fractions import gcd
import math
import collections
def input():
    return sys.stdin.readline()[:-1]
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass


def main():
    n=int(input())
    a=list(map(int,input().split()))
    mod=10**9+7
    # li=[0]*(max(a)+1)
    dic={}
    for i in range(n):
        tmp=collections.Counter(prime_factor(a[i]))
        # print(tmp)
        for j in list(tmp.keys()):
            if not j in dic:
                dic[j]=tmp[j]
            else:
                dic[j]=max(dic[j],tmp[j])
    ans=1
    # print(dic)
    for i in dic.keys():
        # print(dic[i],i)
        ans*=i**dic[i]
    # print(ans)
    cnt=0
    for i in range(n):
        cnt+=ans//a[i]
        cnt%=mod
    print(cnt)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import deque
import heapq
import math
import bisect
from itertools import permutations
from itertools import accumulate
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

dic={}
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# print(factorization(12))
for i in range(n):
    tmp=factorization(a[i])
    for j in range(len(tmp)):
        if not tmp[j][0] in dic:
            dic[tmp[j][0]]=tmp[j][1]
        else:
            dic[tmp[j][0]]=max(dic[tmp[j][0]],tmp[j][1])
l=1
for i in dic.keys():
    l*=i**dic[i]
    l%=mod
# print(l)
ans=0
for i in range(n):
    ans+=l*pow(a[i],mod-2,mod)
    ans%=mod
print(ans)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
counter = 0
cemetery = []

for i in range(N):
    if not A[i] in cemetery:
        if A.count(A[i]) % 2 == 1:
            counter += 1
        cemetery.append(A[i])

print(counter)


### FIXED CODE ###

N = int(input())
maps = {}

for _ in range(N):
    A = int(input())
    if A in maps:
        maps.pop(A)
    else:
        maps[A] = 1

print(len(maps))
### BUGGY CODE ###

#入力
N,M=map(int,input().split())
H=list(map(int,input().split()))

#展望台リスト初期化
road=[l for l in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    #道行列を入力
    if a-1 in road :
        if (H[b-1]>=H[a-1]):
            road.remove(a-1)
    if b-1 in road:
        if (H[a-1]>=H[b-1]):
            road.remove(b-1)

result=len(road)

print(result)

### FIXED CODE ###

#入力
N,M=map(int,input().split())
H=list(map(int,input().split()))

#隣接展望台の最大標高リスト初期化
road_max=[0 for l in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    if road_max[a-1]<H[b-1]:
        road_max[a-1]=H[b-1]
    if road_max[b-1]<H[a-1]:
        road_max[b-1]=H[a-1]

result=[(road_max[p]<H[p])*1 for p in range(N)]

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

import numpy as np

def solve(N, M, Q, L, R, p, q):
    A = np.zeros((N+2, N+2), dtype=int)
    S = np.zeros((N+2, N+2), dtype=int)
    for i in range(M):
        A[L[i], R[i]] += 1
    S[0,0] = A[0,0]
    for i in range(1, N+1):
        for j in range(1, N+1):
            S[i,:] = S[i-1,:] + A[i,:]
    res = []
    for i in range(Q):
        a = sum(S[p[i]-1,p[i]:q[i]+1])
        b = sum(S[q[i],p[i]:q[i]+1])
        c = b - a
        res.append(c)
    return "\n".join(map(str, res))

N, M, Q = map(int, input().split())
L, R = [0]*M, [0]*M
for i in range(M):
    L[i], R[i] = map(int, input().split())
p, q = [0]*Q, [0]*Q
for i in range(Q):
    p[i], q[i] = map(int, input().split())
print(solve(N, M, Q, L, R, p, q))

### FIXED CODE ###

import numpy as np

def solve(N, M, Q, L, R, p, q):
    A = np.zeros((N+1, N+1), dtype=int)
    for i in range(M):
        A[L[i], R[i]] += 1
    S = np.zeros((N+1, N+1), dtype=int)
    S[0,0] = A[0,0]
    for i in range(1, N+1):
        S[i,:] = S[i-1,:] + A[i,:]
    for j in range(1, N+1):
        S[:,j] += S[:,j-1]
    res = []
    for i in range(Q):
        x1, x2 = p[i]-1, q[i]
        a = S[x2,x2]
        b = S[x1,x2]
        c = S[x2,x1]
        d = S[x1,x1]
        res.append(a - b - c + d)
    return "\n".join(map(str, res))

N, M, Q = map(int, input().split())
L, R = [0]*M, [0]*M
for i in range(M):
    L[i], R[i] = map(int, input().split())
p, q = [0]*Q, [0]*Q
for i in range(Q):
    p[i], q[i] = map(int, input().split())
print(solve(N, M, Q, L, R, p, q))
### BUGGY CODE ###

def main():
    n = int(input())
    a = [input() for _ in range(n)]
    ans = 0
    for j in range(n):
        f = True
        for i in range(n):
            for k in range(n):
                if a[(0+i)%n][(j+k)%n] != a[(0+k)%n][(j+i)%n]:
                    f = False
                    break
            if not f:
                break
        if f:
            ans += n
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n = int(input())
    a = [input() for _ in range(n)]
    ans = 0
    for j in range(n):
        f = True
        for i in range(n-1):
            for k in range(i+1, n):
                if a[(0+i)%n][(j+k)%n] != a[(0+k)%n][(j+i)%n]:
                    f = False
                    break
            if not f:
                break
        if f:
            ans += n
    print(ans)

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

N = int(input())
# サイズが下の方が大きくないとダメtop<mid<bottom
tops = sorted(list(map(int, input().split(" "))))
mids = sorted(list(map(int, input().split(" "))))
bottoms = sorted(list(map(int, input().split(" "))))


def binary_search(check_list, num, left, right):
    if left > right:
        return left
    mid = (left + right) // 2
    if check_list[mid] > num:
        return binary_search(check_list, num, left, mid - 1)
    elif check_list[mid] == num:
        return mid
    else:
        return binary_search(check_list, num, mid + 1, right)


total_count = 0
for bottom in bottoms:
    mid_insert_index = binary_search(mids, bottom, 0, N - 1)

    for mid in mids[0:mid_insert_index]:
        top_insert_index = binary_search(tops, mid, 0, N - 1)
        total_count += top_insert_index
print(total_count)


### FIXED CODE ###

import bisect
N = int(input())
# サイズが下の方が大きくないとダメtop<mid<bottom
tops = sorted(list(map(int, input().split(" "))))
mids = list(map(int, input().split(" ")))
bottoms = sorted(list(map(int, input().split(" "))))
# print(tops)
# print(mids)
# print(bottoms)


# def left_binary_search(check_list, num, left, right):
#     if left > right:
#         return left
#     mid = (left + right) // 2
#     if check_list[mid] >= num:
#         return left_binary_search(check_list, num, left, mid - 1)
#     else:
#         return left_binary_search(check_list, num, mid + 1, right)


# def right_binary_search(check_list, num, left, right):
#     if left > right:
#         return left
#     mid = (left + right) // 2
#     if check_list[mid] > num:
#         return right_binary_search(check_list, num, left, mid - 1)
#     else:
#         return right_binary_search(check_list, num, mid + 1, right)


total_count = 0
for mid in mids:
    # bottom_start_index = right_binary_search(bottoms, mid, 0, N - 1)
    bottom_start_index = bisect.bisect_right(bottoms, mid)
    # top_end_index = left_binary_search(tops, mid, 0, N - 1)
    top_end_index = bisect.bisect_left(tops, mid)
    total_count += ((N - bottom_start_index) * top_end_index)
print(total_count)