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

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

t = 1

for i in range(n):
    t = t*a[i]

if t > 10**18 :
    print(-1)
else:
    print(t)

### FIXED CODE ###

import numpy as np

n = int(input())
a = list(map(int, input().split()))
t = 1

if any([i == 0 for i in a]):
    print('0')
else:
    for i in range(n):
        x = a[i]
        t = t * x
        if x == 0:
            break
        if t > 10**18:
            break

    if t > 10**18:
        print('-1')
    else:
        print(t)
### BUGGY CODE ###

N=int(input())
A=[int(x) for x in input().split()]
S=[0]*60

for a in A:
  c=0
  while a>0:
    if a&1!=0:
      S[c]+=1
    a>>=1
    c+=1

s,c=0,0
while c<60:
  s+=S[c]*(N-S[c])*((2**c)%(10**9+7))
  c+=1

print(s%(10**9+7))


### FIXED CODE ###

N=int(input())
A=[int(x) for x in input().split()]

s=0
for c in range(60):
  m=1<<c
  bc=len([1 for x in A if x&m])
  s+=bc*(N-bc)*m
  s%=10**9+7
  
print(s)
### BUGGY CODE ###

S = input()
Q = int(input())
for _ in range(Q):
    Query = [i for i in input().split()]
    if Query[0] == '1':
        S = S[::-1]
    else:
        if Query[1] == '1':
            S = Query[2]+S
        else:
            S = S+Query[2]
print(S)


### FIXED CODE ###

S = input()
Q = int(input())
R = 1  # 1:False, -1:True
P = []
B = []
for _ in range(Q):
    Query = [i for i in input().split()]
    if Query[0] == '1':
        R *= -1
    else:
        if R == 1:
            if Query[1] == '1':
                P.append(Query[2])
            else:
                B.append(Query[2])
        else:
            if Query[1] == '1':
                B.append(Query[2][::-1])
            else:
                P.append(Query[2][::-1])

ans = ''.join(P[::-1])+S+''.join(B)
if R == -1:
    ans = ans[::-1]

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

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

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

### FIXED CODE ###

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

ans = [0] * n
for i in range(1, n+1):
    ans[a[i] - 1] = i

print(" ".join(map(str,ans)))
### BUGGY CODE ###

n = int(input())
boss = list(map(str, input().split()))

for i in range(1, n + 1):
    count = 0
    for b in boss:
        if b == str(i):
            count += 1
    print(count)

### FIXED CODE ###

n = int(input())
boss = list(map(str, input().split()))
ans = [0] * n
for b in boss:
    ans[int(b) - 1] += 1
for a in ans:
    print(a)
### BUGGY CODE ###

from collections import defaultdict


def main():
    S = {i:s for i, s in enumerate(input()[::-1])}
    MOD = 10**9 + 7

    DP_table = defaultdict(int)
    
    digit = S[0]
    if digit == '?':
        for i in range(10):
            DP_table[(1, i)] = 1
    else:
        DP_table[(1, int(digit))] = 1
    
    power_ten = 1
    for i in range(1, len(S)):
        digit = S[i]
        power_ten *= 10
        if digit == '?':
            for j in range(10):
                devided = j * power_ten
                for k in range(13):
                    surplus = (devided + k) % 13
                    DP_table[(i + 1, surplus)] += DP_table[(i, k)] % MOD
                    DP_table[(i + 1, surplus)] %= MOD
        else:
            for k in range(13):
                surplus = (int(digit) * power_ten + k) % 13
                DP_table[(i + 1, surplus)] += DP_table[(i, k)] % MOD
                DP_table[(i + 1, surplus)] %= MOD
                
    print(DP_table[(len(S), 5)])

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    S = {i:s for i, s in enumerate(input()[::-1])}
    MOD = 10**9 + 7

    DP_table = [[0 for i in range(13)] for j in range(len(S))]
    
    digit = S[0]
    if digit == '?':
        for i in range(10):
            DP_table[0][i] = 1
    else:
        DP_table[0][int(digit)] = 1
    
    multiplier = 1
    for i in range(1, len(S)):
        digit = S[i]
        multiplier = multiplier * 10 % 13
        if digit == '?':
            for j in range(10):
                for k in range(13):
                    DP_table[i][(j * multiplier + k) % 13] += DP_table[i-1][k]
        else:
            digit = int(digit)
            for k in range(13):
                DP_table[i][(digit * multiplier + k) % 13] += DP_table[i-1][k]
        
        for j in range(13):
            DP_table[i][j] %= MOD

    print(DP_table[len(S)-1][5])

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

import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    h, w = list(map(int, input().rstrip('\n').split()))
    a = [list(str(input().rstrip('\n'))) for _ in range(h)]
    ql = []
    ql = collections.deque(ql)
    fq = collections.defaultdict(list)
    for i in range(h):
        for j in range(w):
            if a[i][j] == "#":
                ql.append([0, i, j])
                fq[i, j]
    m_cost = 0
    while True:
        if len(ql) != 0:
            cost, x, y = ql.popleft()
            m_cost = max(m_cost, cost)
            for x, y in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]:
                if 0 <= x < h and 0 <= y < w:
                    if (x, y) not in fq and a[x][y] == ".":
                        ql.append([cost+1, x, y])
                        fq[x, y]
        else:
            break
    print(m_cost)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    h, w = list(map(int, readline().split()))
    a = [[True] * w for _ in range(h)]
    ql = collections.deque()
    for i in range(h):
        s = list(str(readline().rstrip().decode('utf-8')))
        for j in range(w):
            if s[j] == "#":
                ql.append([0, i, j])
                a[i][j] = False
    while ql:
        cost, x, y = ql.popleft()
        for xv, yv in ((x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)):
            if 0 <= xv < h and 0 <= yv < w:
                if a[xv][yv]:
                    ql.append([cost + 1, xv, yv])
                    a[xv][yv] = False
    print(cost)


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

n,m = map(int,input().split())
h = list(map(int,input().split()))
route = [[False for x in range(n+1)] for x in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    route[a][b] = True
    route[b][a] = True
ans = 0
for i in range(1,n+1):
    if(route[i] == [False for x in range(n+1)]):
        ans+=1
        continue
    for j in range(1,n+1):
        if(route[i][j]):
            if(h[i-1] <= h[j-1]):
                break
    else:
        ans+=1
print(ans)


### FIXED CODE ###

n,m = map(int,input().split())
h = list(map(int,input().split()))
h.insert(0,0)
ans = [True for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    if(h[a] > h[b]):
        ans[b] = False
    elif(h[a] < h[b]):
        ans[a] = False
    else:
        ans[a] = ans[b] = False
print(ans.count(True)-1)
### BUGGY CODE ###

# coding: utf-8

from itertools import accumulate as accum
import sys
input = sys.stdin.readline

def f(N, s):
    MOD = int(1e9 + 7)
    dp = [[0] * N for _ in range(N)]
    for j in range(N):
        dp[0][j] = 1
    for i in range(1, N):
        dpi = dp[i]
        csum = list(accum(dp[i - 1], lambda x, y: (x + y) % MOD))
        csum_ = csum[N - i]
        for j in range(N - i):  # N-(i+1)+1 = N-i
            if s[i - 1] == "<":
                dpi[j] = csum_ - csum[j]
            else: #s[i-1] == ">"
                dpi[j] = csum[j]
    return(dp[-1][0])

N = int(input()) # 2 <= N <= 30000
s = input().rstrip() # len(s) = N - 1
print(f(N, s))


### FIXED CODE ###

# coding: utf-8

import sys
input = sys.stdin.readline

def f2(N, s):
    MOD = int(1e9 + 7)
    dp = [1] * N
    for i in range(1, N):
        csum = list(dp)
        for j in range(1, N - i + 1):
            csum[j] += csum[j - 1]
        csum_ = csum[N - i]
        i_ = i - 1
        for j in range(N - i):  # N-(i+1)+1 = N-i
            dp[j] = csum[j] if s[i_] == ">" else (csum_ - csum[j] + MOD) % MOD
    return(dp[0])

N = int(input()) # 2 <= N <= 30000
s = input().rstrip() # len(s) = N - 1
print(f2(N, s))
### BUGGY CODE ###

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

delete = 0
b = list(set(a))

for i in b:
  if a.count(i) < i:
    delete += a.count(i)
  elif a.count(i) > i:
    delete += a.count(i) - i
    
print(delete)

### FIXED CODE ###

import collections

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

b = collections.Counter(a)
delete = 0

for i,j in b.items():
  i = int(i)
  if i > j:
    delete += j
  elif i < j:
    delete += j - i
    
print(delete)
### BUGGY CODE ###

N = int(input())
n = N
sum = 0
for i in range(N):
    sum = sum + ((i)%(i+1))

print(sum)

### FIXED CODE ###

N = int(input())
print((N*(N-1))//2)
### BUGGY CODE ###

x, k, d = map(int, input().split())
i = 1
x = abs(x)

if k*d <= x:
    print(x-k*d)
else:
    while(d*i < x):
        i += 1
    #print(i)
    if (k-i)%2 == 0:
        print(abs(x-d*i))
    else:
        print(x-d*i + d)


### FIXED CODE ###

x, k, d = map(int, input().split())
i = 1
x = abs(x)

if k*d <= x:
    print(x-k*d)
else:
    i = x//d + 1
    #print(i)
    if (k-i)%2 == 0:
        print(abs(x-d*i))
    else:
        print(x-d*i + d)
### BUGGY CODE ###

N = int(raw_input())
A = map(int, raw_input().split())
S = [sum(A[:i+1]) for i in range(N)]

ans = 0
d = {0:1}

for s in S:
    if s in d:
        ans += d[s]
        d[s] += 1
    else:
        d[s] = 1

print ans


### FIXED CODE ###

N = int(raw_input())
A = map(int, raw_input().split())

ans, s = 0, 0
d = {0:1}

for i in A:
    s += i
    if s in d:
        ans += d[s]
        d[s] += 1
    else:
        d[s] = 1

print ans
### BUGGY CODE ###

while True:
    d= float(input())
    if d< 0: break
    a, b= bin(int(d))[2:].zfill(8)+".", d-int(d)
    while 1:
        b*= 2
        a= a+'1' if int(b)>= 1 else a+'0'
        if str(b).split(".")==['1','0']: break
        b-=int(b)
    a= a.ljust(13, '0')
    print("NA" if len(a)> 13 else a)

### FIXED CODE ###

while True:
    d= float(input())
    if d< 0: break
    a= bin(int(d))[2:]
    if len(a)> 8:
        print("NA")
    else:
        a= a.zfill(8)+"."
        b= d-int(d)
        for _ in range(4):
            b*= 2
            if int(b)>= 1:
                a= a+'1'
                b-= 1
            else:
                a= a+'0'
        a= a.ljust(13, '0')
        print("NA" if 1e-10 < b or len(a)> 13 else a)
### BUGGY CODE ###

#!/usr/bin/env python3
N, M = map(int, input().split())
A = [0] * M
B = [0] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())

friend = [[0]]
for i in range(M):
    for f in friend:
        if A[i] not in f and B[i] not in f:
            friend.append([A[i], B[i]])
        elif A[i] in f and B[i] not in f:
            f.append(B[i])
        elif A[i] not in f and B[i] in f:
            f.append(A[i])
        else:
            pass

ans = 0
for f in friend:
    ans = max(ans, len(f))
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

# uf = UnionFind(要素数)   で使用
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n     # 各要素の親要素の番号を格納するリスト 要素が根の場合は-(グループの要素数)を格納
    def find(self, x):              # 要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):          # 要素xが属するグループと、要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):              # 要素xが属するグループのサイズ(要素数)を返す
        return -self.parents[self.find(x)]
    def same(self, x, y):           # 要素xと要素yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)
    def members(self, x):           # 要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):                # すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):          # グループの数を返す
        return len(self.roots())
    def all_group_members(self):    # {ルート要素: [そのグループに含まれる要素のリスト], ...} の辞書を返す
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N, M = map(int, input().split())
    A = [0] * M
    B = [0] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())

    uf = UnionFind(N + 1)
    for i in range(M):
        uf.union(A[i], B[i])

    ans = 0
    for i in range(1, N + 1):
        ans = max(ans, uf.size(i))
    print(ans)

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

import sys
sys.setrecursionlimit(10**9)

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

ele_id = 1
# dp[v][i] = (頂点vから出るi番目の有向辺に関する部分木のDPの値)
# dp[v][i] = (c, m)
# c = 頂点vから出るi番目の有向辺に関する部分木の塗り方の数
# m = 頂点vから出るi番目の有向辺に関する部分木の頂点数
dp = [[ele_id] * len(graph[i]) for i in range(n)]
ans = [ele_id] * n

add_func = lambda x: x + 1
merge_func = lambda a, b: a * b % mod


def dfs1(v, v_p):
    dp_cum = ele_id
    for i, v_next in enumerate(graph[v]):
        if v_next == v_p:
            continue
        dp[v][i] = dfs1(v_next, v)
        dp_cum = merge_func(dp_cum, dp[v][i])
    return add_func(dp_cum)


def dfs2(v, v_p, dp_vp):
    for i, v_next in enumerate(graph[v]):
        if v_next == v_p:
            dp[v][i] = dp_vp

    dp_l = [ele_id] * (len(graph[v]) + 1)
    dp_r = [ele_id] * (len(graph[v]) + 1)
    for i in range(len(graph[v])):
        dp_l[i + 1] = merge_func(dp_l[i], dp[v][i])
    for i in reversed(range(len(graph[v]))):
        dp_r[i] = merge_func(dp_r[i + 1], dp[v][i])

    ans[v] = add_func(dp_l[-1])

    for i, v_next in enumerate(graph[v]):
        if v_next == v_p:
            continue
        dfs2(v_next, v, add_func(merge_func(dp_l[i], dp_r[i + 1])))


dfs1(0, -1)
# print(*dp, sep='\n')
dfs2(0, -1, ele_id)
for ans_i in ans:
    print(ans_i - 1)


### FIXED CODE ###

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

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

ele_id = 1
# dp[v][i] = (頂点vから出るi番目の有向辺に関する部分木のDPの値)
# dp[v][i] = (c, m)
# c = 頂点vから出るi番目の有向辺に関する部分木の塗り方の数
# m = 頂点vから出るi番目の有向辺に関する部分木の頂点数
dp = [[ele_id] * len(graph[i]) for i in range(n)]
ans = [ele_id] * n

add_func = lambda x: x + 1
merge_func = lambda a, b: a * b % mod


def dfs1(v, v_p):
    dp_cum = ele_id
    for i, v_next in enumerate(graph[v]):
        if v_next == v_p:
            continue
        dp[v][i] = dfs1(v_next, v)
        dp_cum = merge_func(dp_cum, dp[v][i])
    return add_func(dp_cum)


def dfs2(v, v_p, dp_vp):
    for i, v_next in enumerate(graph[v]):
        if v_next == v_p:
            dp[v][i] = dp_vp

    dp_l = [ele_id] * (len(graph[v]) + 1)
    dp_r = [ele_id] * (len(graph[v]) + 1)
    for i in range(len(graph[v])):
        dp_l[i + 1] = merge_func(dp_l[i], dp[v][i])
    for i in reversed(range(len(graph[v]))):
        dp_r[i] = merge_func(dp_r[i + 1], dp[v][i])

    ans[v] = add_func(dp_l[-1])

    for i, v_next in enumerate(graph[v]):
        if v_next == v_p:
            continue
        dfs2(v_next, v, add_func(merge_func(dp_l[i], dp_r[i + 1])))


dfs1(0, -1)
# print(*dp, sep='\n')
dfs2(0, -1, ele_id)
for ans_i in ans:
    print(ans_i - 1)
### BUGGY CODE ###

import itertools

N, Y = (int(x) for x in input().split())
for x, y, z in itertools.product(range(N+1), range(N+1), range(N+1)):
    if x + y + z == N and 10000*x + 5000*y + 1000*z == Y:
        print('{} {} {}'.format(x, y, z))
        break
if not(x + y + z == N and 10000*x + 5000*y + 1000*z == Y):      
  print('-1 -1 -1')

### FIXED CODE ###

import itertools

N, Y = (int(x) for x in input().split())
for x, y in itertools.product(range(N+1), range(N+1)):
  z = N - x - y
  if 0 <= z and 10000*x + 5000*y + 1000*z == Y:
    print('{} {} {}'.format(x, y, z))
    break
if not(x + y + z == N and 10000*x + 5000*y + 1000*z == Y):      
  print('-1 -1 -1')
### BUGGY CODE ###

N = int(input())
A = sorted(list(map(int,input().split())))
def gcd(L):
    
    
    minb = L[0]
    while True:
        NL = []
        #print(L)
        rs = 0
        minb = min(L)
        for l in L:
            r = l % minb
            if r != 0:
                NL.append(r)
                rs += r
        NL.append(minb)
        L = NL
        
        if rs == 0:
            return minb

max = 0
for i in range(1,len(A)+1):
    g = gcd(A[0:i-1]+A[i:])
    #print(i,g,(A[0:i-1]+A[i:]))
    if max < g:
        max = g
print(max)


### FIXED CODE ###

N = int(input())
A = sorted(list(map(int,input().split())))
def gcdaaaaaaaaa(L):
    nextminb = L[0]
    nextn = len(L)
    while True:
        n = nextn
        minb = nextminb
        for l in L[:n]:
            nextn = 0
            r= l % minb
            
            if r != 0:
                L[nextn] = r
                nextn += 1
                if r < nextminb :
                    nextminb = r
        if minb == nextminb:
            return minb
        
def gcd(a,b):
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b,r)
def gcdL(L):
    g = L[0]
    for l in L:
        g = gcd(g,l)
    return g



lgcd = [0] * N
rgcd = [0] * N

lg = A[0]
rg = A[-1]
for i in range(N):
    
    lg = gcd(lg,A[i])
    lgcd[i] = lg
    rg = gcd(rg,A[N-i-1])
    rgcd[N-i-1] = rg
    
maxg = max(lgcd[N-2],rgcd[1])
for i in range(1,N-1):
    g = gcd(lgcd[i-1],rgcd[i+1])
    if maxg < g:
        maxg = g

print(maxg)
### BUGGY CODE ###

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

ans=1

for i in range(N):
    ans*=A[i]

if ans > 10**18:
    print(-1)
    exit()

print(ans)

### FIXED CODE ###

import numpy as np

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

if 0 in P:
    print(0)
    exit()

ans=1
P.sort(reverse=True)

for i in range(N):
    ans*=P[i]
    if ans>10**18:
        print(-1)
        exit()

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

# D
import numpy as np
N = int(input())
X = []
Y = []

for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

# edges
X_s = np.argsort(np.array(X))
Y_s = np.argsort(np.array(Y))

edge_list = []
edge_weight = []
for i in range(N-1):
    edge_list.append([X_s[i], X_s[i+1]])
    edge_weight.append(min(abs(X[X_s[i+1]] - X[X_s[i]]), abs(Y[X_s[i+1]] - Y[X_s[i]])))
    edge_list.append([Y_s[i], Y_s[i+1]])
    edge_weight.append(min(abs(X[Y_s[i+1]] - X[Y_s[i]]), abs(Y[Y_s[i+1]] - Y[Y_s[i]])))
    
# sort edges
sel = np.argsort(np.array(edge_weight))

# union find tree
uf = np.arange(N)


res = 0
flg = np.zeros(N)

for s in sel:
    m, n = edge_list[s]
    # find union
    gr_m = m
    gr_m_list = []
    gr_n = n
    gr_n_list = []
    while gr_m != uf[gr_m]:
        gr_m_list.append(gr_m)
        gr_m = uf[gr_m]
    for m_ in gr_m_list:
        uf[m_] = gr_m
        
    while gr_n != uf[gr_n]:
        gr_n_list.append(gr_n)
        gr_n = uf[gr_n]
    for n_ in gr_n_list:
        uf[n_] = gr_n
        
    if gr_m == gr_n:
        pass
    else:
        res += edge_weight[s]
        uf[gr_n] = gr_m
print(res)

### FIXED CODE ###

# D
import numpy as np
N = int(input())
X = []
Y = []

for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

# edges
X_s = np.argsort(np.array(X))
Y_s = np.argsort(np.array(Y))

edge_list = []
edge_weight = []
for i in range(N-1):
    edge_list.append([X_s[i], X_s[i+1]])
    edge_weight.append(X[X_s[i+1]] - X[X_s[i]])
    edge_list.append([Y_s[i], Y_s[i+1]])
    edge_weight.append(Y[Y_s[i+1]] - Y[Y_s[i]])
    
# sort edges
sel = np.argsort(np.array(edge_weight))

# union find tree
uf = np.arange(N)


res = 0
flg = np.zeros(N)

for s in sel:
    m, n = edge_list[s]
    # find union
    gr_m = m
    gr_m_list = []
    gr_n = n
    gr_n_list = []
    while gr_m != uf[gr_m]:
        gr_m_list.append(gr_m)
        gr_m = uf[gr_m]
    for m_ in gr_m_list:
        uf[m_] = gr_m
        
    while gr_n != uf[gr_n]:
        gr_n_list.append(gr_n)
        gr_n = uf[gr_n]
    for n_ in gr_n_list:
        uf[n_] = gr_n
        
    if gr_m == gr_n:
        pass
    else:
        res += edge_weight[s]
        uf[gr_n] = gr_m
print(res)
### BUGGY CODE ###

_ = input()
nums = [int(x) for x in input().split(" ")]
res = 0
for i, ni in enumerate(nums):
    for nj in nums[i+1:]:
        res += ni*nj
        res %= 10**9 + 7
print(res)


### FIXED CODE ###

_ = input()
nums = [int(x) for x in input().split(" ")]
res = 0
sums = []
for n in nums[1:][::-1]:
    if sums:
        sums.append(sums[-1]+n)
    else:
        sums.append(n)
sums.reverse()
#print(sums)
for i, ni in enumerate(nums[:-1]):
    res += ni*sums[i]
    res %= 10**9 + 7
print(res)
### BUGGY CODE ###

import string

ALPHABETS = string.ascii_lowercase


def is_avairable(a):
    return bin(a).count('1') <= 1


s = input()
N = len(s)
a = [0] * (N + 1)
for i, c in enumerate(s):
    idx = ALPHABETS.index(c)
    a[i+1] = a[i] ^ (2 ** idx)

opt = [0] * (N + 1)
for i in range(1, N + 1):
    min = -1
    for j in range(i):
        if is_avairable(a[j] ^ a[i]):
            if opt[j] < min or min < 0:
                min = opt[j]
    opt[i] = min + 1
print(opt[N])


### FIXED CODE ###

s = input()
N = len(s)
a = 0
dp = {}
dp[0] = 0
bits = [2 ** i for i in range(26)]

for c in s:
    a = a ^ bits[ord(c)-ord('a')]
    dp[a] = min(dp.get(a, N), min([dp.get(a ^ bit, N) for bit in bits]) + 1)

print(dp[a] if dp[a] != 0 else 1)