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

n = int(input())
s = str(input())

R, G, B = [], [], []
for i, c in enumerate(s):
  if c == 'R': R.append(i)
  elif c == 'G': G.append(i)
  else: B.append(i)

ans = 0
for r in R:
  for g in G:
    for b in B:
      if abs(r-g) != abs(g-b) and abs(r-b) != abs(g-b) and abs(r-g) != abs(r-b):
        ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
s = str(input())

R, G, B = [], [], []
for i, c in enumerate(s):
  if c == 'R': R.append(i)
  elif c == 'G': G.append(i)
  else: B.append(i)

ans = 0
for r in R:
  for g in G:
    if r < g: x, y = r, g
    else: x, y = g, r

    ans += len(B)
    if x*2 - y >= 0:
      if s[x*2 - y] == 'B': ans -= 1
    if (x + y) % 2 == 0:
      if s[(x+y)//2] == 'B': ans -= 1
    if y*2 - x < len(s):
      if s[y*2 - x] == 'B': ans -= 1

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

mi = lambda: map(int, input().split())
e = enumerate
n,k = mi()
m = (n+k).bit_length()
a = list(mi())
g = [None]*n

d = dict()
for i,x in e(a):
  d[x] = i
for i,x in e(a):
  g[d[x]] = ((i+1)%n,int(d[x]>=i)+int(i+1==n))
  d[x] = i
db = [g]
for _ in range(m):
  old = db[-1]
  new = [None]*n
  for i in range(n):
    p,q = old[i]
    r,s = old[p]
    new[i] = (r,q+s)
  db.append(new)
cur = 0
st = m
cs = 0
while st>=0:
  p,q = db[st][cur]
  if cs+q < k:
    cs += q
    cur = p
  else:
    st -= 1
    
q = list()
while cur < n:
  if g[cur][1] == 0:
    cur = g[cur][0]
  elif g[cur] == (0,1):
    break
  else:
    q.append(a[cur])
    cur += 1
  
print(' '.join(map(str,q)))

### FIXED CODE ###

mi = lambda: map(int, input().split())
e = enumerate
n,k = mi()
m = (n+k).bit_length()
a = list(mi())
g = [None]*n

d = dict()
for i,x in e(a):
  d[x] = i
for i,x in e(a):
  g[d[x]] = ((i+1)%n,int(d[x]>=i)+int(i+1==n))
  d[x] = i
db = [g]
for _ in range(m):
  old = db[-1]
  new = [None]*n
  for i in range(n):
    p,q = old[i]
    r,s = old[p]
    new[i] = (r,q+s)
  db.append(new)
cur = 0
st = m
cs = 0
while st>=0:
  p,q = db[st][cur]
  if cs+q < k:
    cs += q
    cur = p
  else:
    st -= 1
    
q = list()
while cur < n:
  if g[cur][1] == 0:
    cur = g[cur][0]
  elif g[cur] == (0,1):
    break
  else:
    q.append(a[cur])
    cur += 1
  
print(' '.join(map(str,q)))
### BUGGY CODE ###

def main():
    N, K = map(int, raw_input().split())
    Points = []
    for i in range(N):
        x, y = map(int, raw_input().split())
        Points.append([x, y])

    ans = float('inf')
    for u in range(N):
        for d in range(u + 1, N):
            for r in range(N):
                for l in range(r + 1, N):
                    x1, x2 = min(Points[l][0], Points[r][0]), max(Points[l][0], Points[r][0])
                    y1, y2 = min(Points[d][1], Points[u][1]), max(Points[d][1], Points[u][1])
                    tmp = 0
                    for x, y in Points:
                        if (x1 <= x <= x2) and (y1 <= y <= y2):
                            tmp += 1
                    if tmp >= K:
                        ans = min(ans,  (x2 - x1) * (y2 - y1))

    print(ans)


main()


### FIXED CODE ###

N, K = map(int, input().split())
XY = []
YX = []
for i in range(N):
    x, y = map(int, input().split())
    XY.append([x, y, i])
    YX.append([y, x, i])
XY.sort()
YX.sort()

x_order = {}
for xo, p in enumerate(XY):
    x, y, i = p
    x_order[i] = xo

cums = [[0 for j in range(N+1)] for i in range(N+1)]
for i in range(N):
    y, x, pi = YX[i]
    xo = x_order[pi]
    for j in range(N + 1):
        cums[i + 1][j] = cums[i][j] + (1 if j > xo else 0)

ans = float('inf')

for i in range(N-1):
    for j in range(i+1, N):
        for k in range(N-1):
            for l in range(k+1, N):
                if cums[l+1][j+1] - cums[l+1][i] - cums[k][j+1] + cums[k][i] >= K:
                        ans = min(ans, (XY[j][0]-XY[i][0]) * (YX[l][0]-YX[k][0]))

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

N = int(input())
A = list(map(int,input().split()))
B = [A.count(i) for i in range (N + 1)]
C = 0
for i in range(N + 1):
  C += int(B[i] * (B[i] - 1) / 2)
for j in range(N):
  print(0 if B[A[j]] < 2 else C + 1 - B[A[j]])

### FIXED CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)
L = {key:(B[key] * (B[key] - 1) // 2) for key in B}
total = sum(L.values())
#print(f"A = {A}\nB = {B}\nL = {L}\ntotal = {total}")
[print(total if L[i] == 0 else total - L[i] + ((B[i] - 1) * (B[i] - 2) // 2)) for i in A]
### BUGGY CODE ###

import sys
from bisect import bisect, bisect_left
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def get_sieve_of_eratosthenes(n):
	prime = [2]
	limit = int(n**0.5)
	data = [i + 1 for i in range(2, n, 2)]
	append = prime.append
	while True:
		p = data[0]
		if p > limit:
			return prime + data
		append(p)
		data = [e for e in data if e % p != 0]

def main():
	Q = INT()
	A = [[] for _ in range(Q)]
	
	qmax = 0
	for i in range(Q):
		l, r = MAP()
		qmax = max(qmax, r)
		A[i] = [l, r]
	
	primes = get_sieve_of_eratosthenes(qmax)
	primes = [p for p in primes if primes.count((p+1)//2)]
	# print(primes)

	for a in A:
		l, r = a
		print(bisect(primes, r)-bisect_left(primes, l))

if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys
from bisect import bisect, bisect_left

sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def get_sieve_of_eratosthenes(n):
	prime = [2]
	limit = int(n**0.5)
	data = [i + 1 for i in range(2, n, 2)]
	append = prime.append
	while True:
		p = data[0]
		if p > limit:
			return prime + data
		append(p)
		data = [e for e in data if e % p != 0]

def main():
	primes = get_sieve_of_eratosthenes(10**5)

	prime_dict = dict(zip(primes, [1]*len(primes)))
	prime_2017 = []
	append = prime_2017.append
	for k in prime_dict.keys():
		if int((k+1)/2) in prime_dict:
			append(k)
	
	prime_2017.sort()
	# print(prime_2017)

	Q = INT()
	for _ in range(Q):
		l, r = MAP()
		print(bisect(prime_2017, r)-bisect_left(prime_2017, l))

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

import sys
import math

N = int(input())
S = input()
PW = []

for i in range(N-2):
    A = S[i]
    for j in range(i+1, N-1):
        B = S[j]
        for k in range(j+1, N):
            C = S[k]
            T = A + B + C
            if T in PW:
                continue
            else:
                PW.append(T)


ans = len(PW)

print(ans)

### FIXED CODE ###

import sys
import math

N = int(input())
S = input()
ans = 0

for i in range(10):
    a = S.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = S.find(str(j), a+1)
        if b == -1:
            continue
        for k in range(10):
            if S.find(str(k), b+1) != -1:
                ans += 1


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

#problem-D
def discount(array):
    array.sort()
    array[-1] = array[-1]//2
    return array

n,m = map(int, input().split())
price = list(map(int, input().split()))

for i in range(m):
    discount(price)
print(sum(price))

### FIXED CODE ###

#problem-D needs priority queue
import heapq
n,m = map(int, input().split())
price = list(map(int, input().split()))
for i in range(n):
    price[i] = -price[i]
heapq.heapify(price)

for i in range(m):
    x = heapq.heappop(price)
    if x%2 == 0:
        heapq.heappush(price,x//2)
    else:
        heapq.heappush(price,x//2+1)
print(-sum(price))
### BUGGY CODE ###

b = []
def binomial(n):
    global b
    b = [None] * n
    for i in range(n):
        b[i] = [0] * n
        b[i][i] = 1
    for i in range(1, n):
        for j in range(1, i + 1):
            b[i][j] = b[i - 1][j - 1] + b[i - 1][j]
    
cache = {}

def s(x, a, k, i):
    if a < 0: return 0
    if k < 0: return 0
    if k == 0:
        if a == 0: return 1
        else: return 0
    if i > a: return 0
    if i == 51: return 0
    key = (a, k, i)
    if key in cache: return cache[key]
    c = s(x, a, k, i + 1)
    for j in range(1, x[i] + 1):
        c += b[x[i] + 1][j + 1] * s(x, a - i * j, k - j, i + 1)
    cache[key] = c
    return c

n, a = map(int, input().split())
binomial(n + 2)
x = [0] * 51
for k in input().split():
    x[int(k)] += 1

c = 0
for i in range(1, n + 1):
    c += s(x, a * i, i, 0)
print(c)


### FIXED CODE ###

n, a = map(int, input().split())
x = [int(i) for i in input().split()]
cache = {}
def s(v, k, i):
    if i == n: return int(v > 0 and v == k * a)
    if v > a * n: return 0
    key = (v, k, i)
    if key in cache: return cache[key]
    cache[key] = s(v, k, i + 1) + s(v + x[i], k + 1, i + 1)
    return cache[key]

print(s(0, 0, 0))
### BUGGY CODE ###

import itertools
import numpy

n = int(input())

seq = []
for _ in range(n):
  i = list(map(int, input().split(" ")))
  seq.append(i)
  
permutations = list(itertools.permutations(seq))

results = []
for path in itertools.permutations(seq):
  pwd = None
  for p in path:
    if pwd is None:
      pwd = p
    else:
      a = numpy.array(pwd)
      b = numpy.array(p)
      u = b - a
      results.append(numpy.linalg.norm(u))
      pwd = p
print(sum(results) / len(permutations))

### FIXED CODE ###

import itertools
import numpy
import math

n = int(input())

seq = []
for _ in range(n):
  i = list(map(int, input().split(" ")))
  seq.append(i)
  
length = len(list(itertools.permutations(seq)))
results = []
paths = list(itertools.combinations(seq, 2))
factorial = math.factorial(n - 1)
for path in paths:
  a, b = path
  a = numpy.array(a)
  b = numpy.array(b)
  u = b - a
  results.append(numpy.linalg.norm(u) * (factorial * 2))
print(sum(results) / length)
### BUGGY CODE ###

n=int(input())
l=[int(i) for i in input().split()]
l.sort()

ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        k=j+1
        while l[i]+l[j]>l[k]:
            ans+=1
            k+=1
            if k==n:
                break
print(ans)

### FIXED CODE ###

n=int(input())
l=[int(i) for i in input().split()]
l.sort()


def binarysearch(lista,b):
    left=0
    right=len(lista)
    while left<right:
        mid=(left+right)//2
        if lista[mid]>=b:
            right=mid
        else:
            left=mid+1
            mid+=1
    return mid

ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        ans+=(binarysearch(l,l[i]+l[j])-(j+1))
print(ans)
### BUGGY CODE ###

def main():
    import sys
    sys.setrecursionlimit(10**8)
    input=sys.stdin.readline
    n=int(input())
    a=list(map(int,input().split()))
    num1,num2,num3=0,0,0
    for i in range(n):
        if a[i]==1:
            num1+=1
        elif a[i]==2:
            num2+=1
        else:
            num3+=1
    dp=[[[0 for k in range(n+1)] for i in range(n+1)] for j in range(n+1)]
    flag=[[[0 for k in range(n+1)] for i in range(n+1)] for j in range(n+1)]
    def f(n1,n2,n3):
        if flag[n1][n2][n3]:
            return dp[n1][n2][n3]
        if n1==n2==n3==0:
            return 0
        flag[n1][n2][n3]=1
        ret=1/(1-(n-n1-n2-n3)/n)
        if n1>0:
            ret+=f(n1-1,n2,n3)*(n1/n)/(1-(n-n1-n2-n3)/n)
        if n2>0:
            ret+=f(n1+1,n2-1,n3)*(n2/n)/(1-(n-n1-n2-n3)/n)
        if n3>0:
            ret+=f(n1,n2+1,n3-1)*(n3/n)/(1-(n-n1-n2-n3)/n)
        dp[n1][n2][n3]=ret
        return dp[n1][n2][n3]
    print(f(num1,num2,num3))
if __name__=="__main__":
    main()

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
num1,num2,num3=0,0,0
for i in range(n):
    if a[i]==1:
        num1+=1
    elif a[i]==2:
        num2+=1
    else:
        num3+=1
dp=[[[-1.0 for k in range(n+1)] for i in range(n+1)] for j in range(n+1)]
def f(n1,n2,n3):
    if dp[n1][n2][n3]>=0.0:
        return dp[n1][n2][n3]
    if n1==n2==n3==0:
        return 0.0
    ret=n
    if n1>0:
        ret+=f(n1-1,n2,n3)*n1
    if n2>0:
        ret+=f(n1+1,n2-1,n3)*n2
    if n3>0:
        ret+=f(n1,n2+1,n3-1)*n3
    ret*=1.0/(n1+n2+n3)
    dp[n1][n2][n3]=ret
    return dp[n1][n2][n3]
print(f(num1,num2,num3))
### BUGGY CODE ###

h, n = map(int, input().split())

abKeys = set([])
result = [0] * (10 ** 8)
for _ in range(n):
    a, b = map(int, input().split())
    result[b] = a

for i in range(10 ** 8):
    j = 1
    while j <= i // 2:
        result[i] = max(result[i], result[j] + result[i - j])

        j += 1

    #if i % 100 == 0:
        #print(result[i], i, j, i - j)
    if result[i] >= h:
        print(i)
        exit()

#print(max(result))

### FIXED CODE ###

h,n=map(int,input().split())

ab=[]
dp=[10**9]*(10**5)

maxA=0
for _ in range(n):
    a,b=map(int,input().split())
    dp[a]=min(dp[a],b)
    maxA=max(maxA,a)
#print(dp)
#dp[a]は、相手にaダメージを与えるときの、消耗する自分の最小HP
result=10**9
for i in range(1,h+maxA):
    #print(i,"##########")
    for k in range(1,i//2+2):
        dp[i]=min(dp[i],dp[k]+dp[i-k])
    if i>=h:
        result=min(result,dp[i])
    #print(dp)
print(result)
### BUGGY CODE ###

import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces

# 大きい数用


def modPow(a, n, p):
    if n == 0:
        return 1
    if n == 1:
        return a
    if n % 2 == 1:
        return (a * (modPow(a, n // 2, p) ** 2)) % p
    else:
        return (modPow(a, n // 2, p) ** 2) % p


def modInverse(a, p):
    # calculates the modular multiplicative of a mod m.
    # (assuming p is prime).
    return modPow(a, p - 2, p)


def modBinomial(n, k, p):
    # calculates C(n,k) mod p (assuming p is prime).

    numerator = 1  # n * (n-1) * ... * (n-k+1)
    for i in range(k):
        numerator = (numerator * (n - i)) % p

    denominator = 1  # k!
    for i in range(1, k + 1):
        denominator = (denominator * i) % p

    # numerator / denominator mod p.
    return (numerator * modInverse(denominator, p)) % p


K = ni()
S = ns()
s_len = len(S)
mod = 10 ** 9 + 7
ans = 0

total = K + s_len

rui = 1

cmb = 1

for i in range(total, s_len - 1, -1):
    ans = (ans + cmb * rui) % mod
    # print(ans)
    rui = (rui * 25) % mod
    cmb = (cmb * i * modInverse(total - i + 1, mod)) % mod
print(ans)


# a_array = [[0] * 9 for _ in range(9)]
# a_array[0][0] = 1
# for i in range(1,9):
#     for j in range(9):
#         if j == 0:
#             a_array[i][j] = a_array[i-1][j] * 25
#         else:
#             a_array[i][j] = a_array[i-1][j] * 25 + a_array[i-1][j-1]

# print(sum(a_array[-1][3:]) % (10 ** 9 + 7))


### FIXED CODE ###

import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces

# 大きい数用


mod = 10**9 + 7
N = 10 ** 6 + 1  # 出力の制限
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)

K = ni()
S = ns()
s_len = len(S)
mod = 10 ** 9 + 7
ans = 0

total = K + s_len

rui = 1

cmb = 1

for i in range(total, s_len - 1, -1):
    # print(total - i + 1)
    ans = (ans + cmb * rui) % mod
    # print(ans)
    rui = (rui * 25) % mod
    cmb = (cmb * i * inverse[total - i + 1]) % mod
print(ans)
### BUGGY CODE ###

n = int(input())
s = list(map(int,input().split()))
ans = 10**10
for i in range(n):
    ans = min(ans,(abs(sum(s[:i]) - sum(s[i:]))))
print(ans)

### FIXED CODE ###

n = int(input())
s = list(map(int,input().split()))
ans = 2020202020
a = 0
b = sum(s)
for i in range(n):
    a += s[i]
    b -= s[i]
    ans = min(ans,abs(a-b))
print(ans)
### BUGGY CODE ###

N,K=map(int,input().split())
p=list(map(int,input().split()))
array=[]

for n in range(N-(K-1)):
  sum=0
  for k in range(K):
  	sum += p[n+k]
  array.append(sum)

ans=(max(array)+K)/2
print(ans)
  

### FIXED CODE ###

N,K=map(int,input().split())
p=list(map(int,input().split()))
array=[]

a=sum(p[0:K])
array.append(a)

for n in range(N-K):
  a=a-p[n]+p[n+K]
  array.append(a)

ans=(max(array)+K)/2
print(ans)
### BUGGY CODE ###

l, r = map(int, input().split())

from itertools import combinations

ans = 2019

for (x1, x2) in combinations(range(l, r+1), 2):
    a = (x1 * x2) % 2019
    if a < ans:
        ans = a

print(ans)


### FIXED CODE ###

l, r = map(int, input().split())

from itertools import combinations

if r - l > 2019:
    r = l+2019

ans = [(x1*x2)%2019 for (x1, x2) in combinations(range(l, r+1), 2)]

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

import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N, P = map(int, input().split())
    S = list(map(int, input().rstrip("\r\n")[::-1]))
    ans = 0
    if P == 2 or P == 5:
        for i in range(N):
            if int(S[i]) % P == 0:ans += N-i
    else:
        D = [0] * (N+1)
        D[0] = int(S[0]) % P
        tenpow = 1
        for i in range(N):
            S[i] = tenpow * S[i] % P
            tenpow *= 10 % P
        for i in range(N):
            D[i+1] = (S[i] + D[i]) % P
        c = Counter(D)
        for v in c.values():
            ans += v*(v-1)//2
    print(ans)
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N, P = map(int, input().split())
    S = list(map(int, input().rstrip("\r\n")))
    S.reverse()
    ans = 0
    if P == 2 or P == 5:
        for i in range(N):
            if S[i] % P == 0:ans += N-i
    else:
        A = [0] * N
        tenpow = 1
        for i in range(N):
            A[i] = (S[i]*tenpow) % P
            tenpow *= 10
            tenpow %= P
        D = [0] * (N+1)
        for i in range(N):
            D[i+1] = (D[i] + A[i]) % P
        c = Counter(D)
        for v in c.values():
            ans += v*(v-1)//2
    print(ans)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

list1=input().split(' ')
N=int(list1[0])
K=int(list1[1])
Q=int(list1[2])
listQ=[]
for i in range(Q):
    listQ.append(int(input()))
listScores=[K for i in range(N)]
for i in listQ:
    listScores=[x-1 for x in listScores]
    listScores[i-1]=listScores[i-1]+1
for i in listScores:
    if i>0:
        print('Yes')
    elif i<=0:
        print('No')


### FIXED CODE ###

list1=input().split(' ')
N=int(list1[0])
K=int(list1[1])
Q=int(list1[2])
listQ=[]
for i in range(Q):
    listQ.append(int(input()))
listScores=[K for i in range(N)]
sum=0
for i in listQ:
    sum=sum+1
    listScores[i-1]=listScores[i-1]+1
for i in listScores:
    i=i-sum
    if i>0:
        print('Yes')
    elif i<=0:
        print('No')
### BUGGY CODE ###

n, x, y = map(int, input().split())
# n, x, y = 7, 3, 7
edge = [[] for _ in range(n+1)]
dist = [[abs(i-j) for i in range(n+1)] for j in range(n+1)]
counter = [0 for i in range(n)]
for i in range(1, n):
    edge[i].append(i+1)
    edge[i+1].append(i)
edge[x].append(y)
edge[y].append(x)
# print(edge)
for i in range(n):
    for j in range(i+1, n+1):
        new_dist = abs(x-i)+abs(y-j)+1
        if new_dist < dist[i][j]:
            dist[i][j] = new_dist
            dist[j][i] = new_dist

for i in range(1, n+1):
    for num in dist[i][1:]:
        counter[num] += 1
# print(dist)

for num in counter[1:]:
    print(num//2)


### FIXED CODE ###

n, x, y = map(int, input().split())
edge = [[] for _ in range(n+1)]
dist = [[abs(i-j) for i in range(n+1)] for j in range(n+1)]
counter = [0 for i in range(n)]
for i in range(1, n):
    edge[i].append(i+1)
    edge[i+1].append(i)
edge[x].append(y)
edge[y].append(x)
for i in range(y+1):
    for j in range(x, n+1):
        if j > i:
            new_dist = abs(x-i)+abs(y-j)+1
            if new_dist < dist[i][j]:
                dist[i][j] = new_dist

for i in range(1, n+1):
    for num in dist[i][i+1:]:
        counter[num] += 1
# print(dist)

for num in counter[1:]:
    print(num)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**7)
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())

def main():
    n = II()
    a_s = LI()
    kaizyo = [1]
    kaizyo_append = kaizyo.append
    keta = [0 for i in range(60)]
    ans = 0
    for i in range(60):
        kaizyo_append(kaizyo[i] * 2 % MOD)
    for i in a_s:
        for i, v in enumerate(format(i, 'b')[::-1]):
            keta[i] += int(v)
    for i, v in enumerate(keta):
        c = v * (n-v) % MOD
        ans = (ans + c * kaizyo[i]) % MOD

    print(ans)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10**7)
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())

def main():
    n = II()
    a_s = LI()
    kaizyo = [1]
    kaizyo_append = kaizyo.append
    keta = [0 for i in range(60)]
    ans = 0
    for i in range(60):
        kaizyo_append(kaizyo[i] * 2 % MOD)
    for i in a_s:
        for j in range(60):
            v, i = i % 2, i // 2
            keta[j] += v
    for i, v in enumerate(keta):
        c = v * (n-v) % MOD
        ans += c * kaizyo[i] % MOD
        ans = ans % MOD

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

R,G,B,N = map(int,input().split())
cnt = 0

for x in range(N//R+1):
    for y in range(N//G+1):
        z = N - R*x - G*y
        if z >= 0 and z % B == 0:
            cnt += 1
print(cnt)

### FIXED CODE ###

def main():
    R,G,B,N = map(int,input().split())
    cnt = 0

    for x in range(N//R+1):
        for y in range(N//G+1):
            z = N - R*x - G*y
            if z >= 0 and z % B == 0:
                cnt += 1
    print(cnt)

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

n, k = [int(x) for x in input().split()]
ps = [int(x) for x in input().split()]

expected_vals = [sum(range(p+1)) / p for p in ps]

maxval = 0
for i in range(n - k + 1):
  candidate = sum(expected_vals[i:i+k])
  if candidate > maxval:
    maxval = candidate

print(maxval)

### FIXED CODE ###

n, k = [int(x) for x in input().split()]
# ps = [int(x) for x in input().split()]

continuous_sum = (lambda n: (n + 1) * (n // 2) + (0 if n %2 == 0 else n // 2 + 1))
calc_expectedval = (lambda p: continuous_sum(p) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

prevval = sum(expected_vals[0:0+k])
maxval = prevval
for i in range(n - k):
  candidate = prevval - expected_vals[i] + expected_vals[i + k]
  if candidate > maxval:
    maxval = candidate
  prevval = candidate

print(maxval)
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
import functools
import fractions
l1=[]
for i in range(n):
  a=l[0]
  del l[0]
  s = functools.reduce(fractions.gcd, l)
  l1.append(s)
  l.append(a)
print(max(l1))

### FIXED CODE ###

def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
n=int(input())
l=list(map(int,input().split()))
l1=[]
l1.append(l[0])
for i in range(1,n):
  l1.append(gcd(l1[-1],l[i]))
l2=[]
l2.append(l[-1])
for i in range(n-2,-1,-1):
  l2.append(gcd(l2[-1],l[i]))
l3=[]
for i in range(2,n):
  l3.append(gcd(l1[i-2],l2[n-i-1]))
l3.append(l2[n-2])
l3.append(l1[n-2])
print(max(l3))