from random import randint
s=0
n=int(input())
a=[randint(-988,592) for i in range(n)]
print(a)
for i in range (n):
if (a[i]%3!=0) and (a[i]%2!=0):
s+=a[i]
print(s)
from random import randint
s=0
n=int(input())
a=[randint(-988,592) for i in range(n)]
print(a)
for i in range (n):
if (a[i]%3!=0) and (a[i]%2!=0):
s+=a[i]
print(s)