#!/usr/bin/env python
"""
This file is part of https://github.com/Cheran-Senthil/PyRival.

Copyright 2018 Cheran Senthilkumar all rights reserved,
Cheran Senthilkumar <hello@cheran.io>
Permission to use, modify, and distribute this software is given under the
terms of the MIT License.

"""
from __future__ import division, print_function

import cmath
import itertools
import math
import operator as op
# import random
import sys
from atexit import register
from bisect import bisect_left, bisect_right
# from collections import Counter, MutableSequence, defaultdict, deque
# from copy import deepcopy
# from decimal import Decimal
# from difflib import SequenceMatcher
# from fractions import Fraction
# from heapq import heappop, heappush

if sys.version_info[0] < 3:
    # from cPickle import dumps
    from io import BytesIO as stream
    # from Queue import PriorityQueue, Queue
else:
    # from functools import reduce
    from io import StringIO as stream
    # from pickle import dumps
    # from queue import PriorityQueue, Queue

if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)

        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)

        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.

    Args:
        sync (bool, optional): The new synchronization setting.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def gcd(x, y):
    """greatest common divisor of x and y"""
    while y:
        x, y = y, x % y
    return x

def main():
    input()
    a = map(int, input().split(' '))

    ediff, count = [next(a)] * 2

    for ai in a:
        ediff = (2*ediff + count + ai) % 998244353
        count = (2*count + ai) % 998244353

    print(ediff)

if __name__ == '__main__':
    sync_with_stdio(False)
    main()


from decimal import *
n = int(input())
A = list(map(int, input().split()))

memo = {}

def saratov_dist(m, B):
    if (m, tuple(B)) in memo:
        return memo[(m, tuple(B))]
    if m == 1:
        memo[(m,tuple(B))] = Decimal(B[0])
        return memo[(m, tuple(B))]
    memo[(m,tuple(B))] = Decimal(B[0]) + Decimal(saratov_dist(m-1,B[1:]) + saratov_dist(m-1,A))/2
    return memo[(m, tuple(B))]

print(int(saratov_dist(n, A)*(2**(n-1)))%998244353)


from decimal import *
n = int(input())
A = list(map(int, input().split()))
def saratov_dist(m, B):
    if m == 1:
        return Decimal(B[0])
    return Decimal(B[0]) + Decimal(saratov_dist(m-1,B[1:]) + saratov_dist(m-1,A))/2
print(int(saratov_dist(n, A)*(2**(n-1)))%998244353)


i,m=input,998244353
i()
a=map(int,i().split())
r,c=[next(a)]*2
for j in a:r,c=(2*r+c+j)%m,(2*c+j)%m
print(r)


n = int(input())
a=  list(map(int,input().split()))
sum, cur = a[0] % 998244353, a[0]
for x in a[1:]:
    sum  = sum * 2 + cur + x
    cur = cur * + x
    sum %= 998244353
    cur %= 998244353
print(sum)


n = int(input())
a=  list(map(int,input().split()))
sum, cur = a[0] % 998244353, a[0]

for x in a[1:]:
    sum  = sum * 2 + cur + x
    cur = cur * 2 + x
    sum %= 998244353
    cur %= 998244353
print(sum)


from sys import stdin

n   = int(input())
a   = list(map(int, stdin.readline().split()))
mod = 998244353

def solve(a):
    if len(a) == 1:
        return a[0]

    dp    = [0] * n
    dp[0] = a[0]
    dp[1] = a[0] + a[1]

    for i in range(2, len(a)):
        dp[i] = ( a[i] + a[i-1] + (dp[i-1] - a[i-1]) * 2 ) % mod

    for i in range(1, len(a)):
        dp[i] = ( 2*dp[i-1] + dp[i] ) % mod

    return dp[-1]

print(solve(a))


from sys import stdin

n   = int(input())
a   = list(map(int, stdin.readline().split()))
mod = 998244353

def solve(a):
    dp    = [0] * n
    dp[0] = a[0]
    dp[1] = a[0] + a[1]

    for i in range(2, len(a)):
        dp[i] = ( a[i] + a[i-1] + (dp[i-1] - a[i-1]) * 2 ) % mod

    for i in range(1, len(a)):
        dp[i] = ( 2*dp[i-1] + dp[i] ) % mod

    return dp[-1]

print(solve(a))


MOD = 998244353

def main():
    n = int(input())
    a = [int(x) for x in input().split(' ')]

    p, sp, s, ss = 0, 0, 0, 0
    for x in a:
        ss = (2 * ss + s) % MOD
        s = (s + x) % MOD
        p = (ss + sp + s) % MOD
        sp = (sp + p) % MOD
    print(p)

if __name__ == '__main__':
    main()


mod = 998244353

def calc(nn, costs):
  total = costs[-1]
  mult = 1
  for a in range(nn-1, 0, -1):
    total = (total + ((costs[a - (nn+1)] * mult) % mod) * (nn - a) % mod) % mod
    mult = (mult * 2) % mod
    total = (total + (mult * costs[a - (nn+1)]) % mod) % mod
  return total

# calc(1000000, [1000000 for a in range(1000000)])
print(calc(int(input()), list(map(int, input().split(" ")))))


mod = 998244353

def calc(nn, costs):
  total = costs[-1]
  mult = 1
  for a in range(nn-1, 0, -1):
    total = (total + ((costs[a - (nn+1)] * mult) % mod) * (nn - a + 2) % mod) % mod
    mult = (mult * 2) % mod
  return total

# calc(1000000, [1000000 for a in range(1000000)])
print(calc(int(input()), list(map(int, input().split(" ")))))


#!/usr/bin/python3

MOD = 998244353

def solve(N, A):
    ans = 0

    k = 1
    ans += k * A[-1]
    ans %= MOD

    for i in range(N - 2, -1, -1):
        ans += k * (N + 1 - i) * A[i]
        ans %= MOD
        k *= 2
        k %= MOD

    return ans

def main():
    N = int(input())
    A = [int(e) for e in input().split(' ')]
    assert len(A) == N
    print(solve(N, A))

if __name__ == '__main__':
    main()


def main():
    input()
    s, *aa = map(int, input().split())
    y = s
    for a in aa:
        s = (s * 2 + y + a) % 998244353
        y = (y * 2 + a) % 998244353
    print(s)

if __name__ == '__main__':
    main()


n = int(input())
a = list(map(int, input().split()))
difficulty = a[0]
expectation = a[0]
for i in range(1, n):
    difficulty = difficulty - (a[i - 1] - a[i]) // 2**(i - 1)
    expectation += difficulty * (i + 1)
print(expectation)


n = int(input())
a = list(map(int, input().split()))
difficulty = a[0]
expectation = a[0] % 998244353
for i in range(1, n):
    expectation = expectation * 2 + difficulty + a[i]
    difficulty = difficulty * 2 + a[i]
    expectation %= 998244353
    difficulty %= 998244353
print(expectation)


n = int(input())
a = list(map(int, input().split()))
difficulty = a[0]
expectation = a[0]
for i in range(1, n):
    expectation = expectation * 2 + difficulty + a[i]
    difficulty = difficulty * 2 + a[i]
print(expectation % 998244353)


if __name__ == "__main__":
    MODULO = 998244353 * 4

    n = int(raw_input())
    an = [0] + map(int, raw_input().split(" "))
    result = 0
    for i in range(1, n + 1, 1):
        result += (n - i + 2) * an[i]
        result *= 2
        result %= MODULO

    print result / 4


if __name__ == "__main__":
    MODULO = 998244353
    def pow2(x):
        res = 1
        p = 2
        while x:
            if x & 1:
                res = res * p % MODULO
            p = p * p % MODULO
            x /= 2
        return res

    n = int(raw_input())
    an = [0] + map(int, raw_input().split(" "))
    result = 0
    for i in range(1, n, 1):
        result += (pow2(n - i - 1) * (n - i + 2)) * an[i]
        result %= MODULO
    print (result + an[n]) % MODULO


# coding: utf-8

n = int(raw_input())
i = map(int, raw_input().split())
sum = 0
for j in range(1, len(i)+1):
    a = i[j-1] * (2**(n-j) + (2**(n-j-1))*(n-j))
    print j,a
    sum += a
print sum


# coding: utf-8

n = int(raw_input())
i = map(int, raw_input().split())
sum = 0
for j in range(1, len(i)+1):
    a = i[j-1] * (2**(n-j) + (2**(n-j-1))*(n-j))
    sum += a
print int(sum)


# coding: utf-8

n = int(raw_input())
i = map(int, raw_input().split())
sum = 0
for j in range(1, len(i)+1):
    a = i[j-1] * (2**(n-j) + (2**(n-j-1))*(n-j))
    print j,a
    sum += a
print int(sum)


n=int(raw_input())
a=map(int,raw_input().split())
"""
n=4
a=[1, 3, 3, 7]
"""
M=998244353

S=0
T=0
U=0

for i in range(n):
    S=(T+U)%M
    T=(T+S)%M
    U=(2*U+a[i])%M
    #print S,T,U

print (U+T)%M
exit()


n=int(raw_input())
a=map(int,raw_input().split())

M=998244353

S,T,U=0,0,0

for i in range(n):
    S=(T+U)%M
    T=(T+S)%M
    U=(2*U+a[i])%M

print (U+T)%M
exit()


#include <stdio.h>

#define N	1000000
#define MD	998244353

int main() {
	long long p2[N];
	int n, i, len, sum, ans;

	scanf("%d", &n);
	p2[0] = 1;
	for (i = 1; i < n; i++)
		p2[i] = p2[i - 1] * 2 % MD;
	ans = sum = 0;
	for (len = 1; len <= n; len++) {
		long long cnt;
		int a;

		scanf("%d", &a);
		sum = (sum + a) % MD;
		cnt = p2[n - len];
		if (len + 2 <= n)
			cnt = (cnt + (n - 1 - len) * p2[n - 2 - len]) % MD;
		ans = (ans + sum * cnt) % MD;
	}
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

void run(void){
  const int mod=998244353;
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*(n+1));
  int i;
  for(i=1;i<=n;i++) scanf("%d",a+i);
  for(i=2;i<=n;i++) a[i]=(a[i]+a[i-1])%mod;
  int ans=0;
  int mul;
  for(i=n-2,mul=1;i>=1;i--){
    ans=(ans+(int64)(n-1-i)*mul%mod*a[i])%mod;
    mul=mul*2%mod;
  }
  ans=(ans+a[n])%mod;
  for(i=n-1,mul=2;i>=1;i--){
    ans=(ans+(int64)mul*a[i])%mod;
    mul=2*mul%mod;
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


#include<stdio.h>

using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	long long b[n];
	for(int i =0;i<n;i++)
		scanf("%I64d", b + i);

	const long long mod = 998244353;
	long long ats = 0, daug = 1, dv = 1;
	for(int i = n-1;i>=0;i--){
		ats+=(b[i]*daug)%mod;
		ats%=mod;
		daug = daug * 2 + dv;
		while(daug > mod)
			daug -= mod;
		dv *= 2;
		while(dv > mod)
			dv -= mod;
	}
	printf("%I64d", ats);
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	long long b[n];
	for(int i =0;i<n;i++)
		cin >> b[i];

	const long long mod = 998244353;
	long long ats = 0, daug = 1, dv = 1;
	for(int i = n-1;i>=0;i--){
		ats+=(b[i]*daug)%mod;
		ats%=mod;
		daug = daug * 2 + dv;
		while(daug > mod)
			daug -= mod;
		dv *= 2;
		while(dv > mod)
			dv -= mod;
	}
	cout << ats;
}


#include<stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	long long b[n];
	for(int i =0;i<n;i++)
		scanf("%I64d", b + i);

	const long long mod = 998244353;
	long long ats = 0, daug = 1, dv = 1;
	for(int i = n-1;i>=0;i--){
		ats+=(b[i]*daug)%mod;
		ats%=mod;
		daug = daug * 2 + dv;
		while(daug > mod)
			daug -= mod;
		dv *= 2;
		while(dv > mod)
			dv -= mod;
	}
	printf("%I64d", ats);
}


#include<stdin.h>

using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	long long b[n];
	for(int i =0;i<n;i++)
		scanf("%I64d", b + i);

	const long long mod = 998244353;
	long long ats = 0, daug = 1, dv = 1;
	for(int i = n-1;i>=0;i--){
		ats+=(b[i]*daug)%mod;
		ats%=mod;
		daug = daug * 2 + dv;
		while(daug > mod)
			daug -= mod;
		dv *= 2;
		while(dv > mod)
			dv -= mod;
	}
	printf("%I64d", ats);
}


#include<stdio.h>
#define lint long long

const int m = 998244353;

int main() {
	lint n, a, c=0, ans=0;
	scanf("%lld", &n);
	while( n-- )
	{
		scanf("%lld", &a);
		c = (2*c + a)%m;
		ans = (2*ans + c+a)%m;
	}
	printf("%lld\n", ans>>1);
}


#include<stdio.h>
#define lint long long

const int m = 998244353;

int main() {
	lint n, a, c=0, ans=0;
	scanf("%lld", &n);
	while( n-- )
	{
		scanf("%lld", &a);
		c = (2*c + a)%m;
		ans = (2*ans + c+a)%m;
	}
	printf("%lld\n", (ans*(m+1)/2)%m );
}


using System;
using System.Linq;
using CompLib.Algorithm;
using CompLib.Mathematics;
using CompLib.Util;

public class Program
{
    int N;
    int[] A;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();

        /*
         * 現在地0 ゴールN
         * iから(i+1)の難しさA_iとする
         *
         * 難易度 Aの総和
         *
         * 休憩
         * iをリセット
         *
         * 全パターン
         * 難易度の期待値
         */

        /*
         * A_iについて選ばれる回数総和
         * j-iに休憩 iまで休憩しない
         * のこり自由
         *
         */

        ModInt[] x = new ModInt[N];
        for (int i = 0; i < N; i++)
        {
            x[i] = ModInt.Pow(2, N - i - 2) * (N - i - 1) + ModInt.Pow(2, N - i - 1);
        }

        ModInt sum = 0;
        for (int i = 0; i < N; i++)
        {
            sum += x[i] * A[i];
        }

        Console.WriteLine(sum);

    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Algorithm
{
    using System;
    using System.Numerics;

    public static class FastFourierTransform
    {
        private const int E = 23;
        public static readonly ModInt O = new ModInt(31);

        // private const int E = 20;
        // public static readonly ModInt O = new ModInt(646);
        // public static readonly ModInt InvO = new ModInt(208611436);

        // Z[i] 1の原始2^i乗根
        public static readonly ModInt[] Z;
        public static readonly ModInt[] InvZ;

        static FastFourierTransform()
        {
            Z = new ModInt[E + 1];
            InvZ = new ModInt[E + 1];
            Z[E] = O;
            InvZ[E] = ModInt.Inverse(O);
            for (int i = E - 1; i >= 0; i--)
            {
                Z[i] = Z[i + 1] * Z[i + 1];
                InvZ[i] = InvZ[i + 1] * InvZ[i + 1];
            }
        }

        /// <summary>
        /// a,bからc[k]=Σ(a[i]*b[k-i])を求め、aに代入
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static void Convolution(ref ModInt[] a, ModInt[] b)
        {
            int sz = a.Length + b.Length - 1;
            int len = 1;
            int lg = 0;
            while (len < sz)
            {
                lg++;
                len *= 2;
            }

            Array.Resize(ref a, len);
            Transform(a, lg, len, false);
            Array.Resize(ref b, len);
            Transform(b, lg, len, false);
            for (int i = 0; i < len; i++)
            {
                a[i] *= b[i];
            }

            Transform(a, lg, len, true);
            var invLen = ModInt.Inverse(len);
            for (int i = 0; i < sz; i++)
            {
                a[i] *= invLen;
            }

            Array.Resize(ref a, sz);
        }

        private static void Transform(ModInt[] a, int lg, int len, bool inverse)
        {
            for (int i = 0; i < len; i++)
            {
                int rev = BitsReverse(i, lg);
                if (i < rev)
                {
                    var tmp = a[i];
                    a[i] = a[rev];
                    a[rev] = tmp;
                }
            }

            for (int i = 1; i <= lg; i++)
            {
                int b = 1 << (i - 1);
                ModInt z = 1;
                for (int j = 0; j < b; j++)
                {
                    for (int k = j; k < len; k += (b << 1))
                    {
                        ModInt t = z * a[k + b];
                        ModInt u = a[k];
                        a[k] = u + t;
                        a[k + b] = u - t;
                    }

                    z *= inverse ? InvZ[i] : Z[i];
                }
            }
        }

        /// <summary>
        /// lg桁のbit列vのbitを逆順にする
        /// </summary>
        /// <param name="v"></param>
        /// <param name="lg"></param>
        /// <returns></returns>
        public static int BitsReverse(int v, int lg)
        {
            int result = 0;
            for (int i = 0; i < lg; i++)
            {
                if (((1 << i) & v) > 0)
                {
                    result |= (1 << (lg - 1 - i));
                }
            }

            return result;
        }
    }
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    #region ModInt
    /// <summary>
    /// [0,<see cref="Mod"/>) までの値を取るような数
    /// </summary>
    public struct ModInt
    {
        /// <summary>
        /// 剰余を取る値．
        /// </summary>
        // public const long Mod = (int)1e9 + 7;
        public const long Mod = 998244353;

        /// <summary>
        /// 実際の数値．
        /// </summary>
        public long num;
        /// <summary>
        /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
        /// </summary>
        /// <param name="n">インスタンスが持つ値</param>
        /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
        public ModInt(long n) { num = n; }
        /// <summary>
        /// このインスタンスの数値を文字列に変換します．
        /// </summary>
        /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
        public override string ToString() { return num.ToString(); }
        public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
        public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
        public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
        public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(long v, long k)
        {
            long ret = 1;
            for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
                if ((k & 1) == 1) ret = ret * v % Mod;
            return new ModInt(ret);
        }
        /// <summary>
        /// 与えられた数の逆元を計算します．
        /// </summary>
        /// <param name="v">逆元を取る対象となる数</param>
        /// <returns>逆元となるような値</returns>
        /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
        public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
    }
    #endregion
    #region Binomial Coefficient
    public class BinomialCoefficient
    {
        public ModInt[] fact, ifact;
        public BinomialCoefficient(int n)
        {
            fact = new ModInt[n + 1];
            ifact = new ModInt[n + 1];
            fact[0] = 1;
            for (int i = 1; i <= n; i++)
                fact[i] = fact[i - 1] * i;
            ifact[n] = ModInt.Inverse(fact[n]);
            for (int i = n - 1; i >= 0; i--)
                ifact[i] = ifact[i + 1] * (i + 1);
            ifact[0] = ifact[1];
        }
        public ModInt this[int n, int r]
        {
            get
            {
                if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
                return fact[n] * ifact[n - r] * ifact[r];
            }
        }
        public ModInt RepeatedCombination(int n, int k)
        {
            if (k == 0) return 1;
            return this[n + k - 1, k];
        }
    }
    #endregion
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace codeforces
{

    public class Program
    {
        private const int MOD = 998244353;

        private static int Mult(int a, int b)
        {
            return (int)(1L * a * b % MOD);
        }

        private static int Add(int a, int b)
        {
            a += b;
            if (a >= MOD)
            {
                a -= MOD;
            }
            return a;
        }

        private static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            var values = Console.ReadLine().Split(' ');
            var a = new int[n];
            var pt = new int[n + 1];

            for (int i = 0; i < n; ++i)
            {
                a[i] = Convert.ToInt32(values[i]);
            }

            pt[0] = 1;
            for (int i = 1; i <= n; ++i)
            {
                pt[i] = Mult(pt[i - 1], 2);
            }
            int result = 0;
            for (int i = 0; i < n; ++i)
            {
                int value = i < n - 1 ? Mult(n - i - 1, pt[n - i - 2]) : 0;
                result = Add(result, Mult(a[i], Add(value, pt[n - i - 1])));
            }
            Console.WriteLine(result);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;

class Solver
{
    public Scanner sc;
    public void Solve()
    {
        var N = sc.Int;
        var A = sc.ArrInt;
        ModInt res = 0;
        for (int i = 0; i < N; i++)
        {
            res+=A[i]* ModInt.Pow(2, N - 1 - i);
            if(i!=N-1)
                res += (N-i-1)*A[i] * ModInt.Pow(2, N - 2 - i);
        }
        Console.WriteLine(res);
    }
}

public struct ModInt
{
    //public const long MOD = (int)1e9 + 7;
    public const long MOD = 998244353;
    public long Value { get; set; }
    public ModInt(long n = 0) { Value = n; }
    private static ModInt[] fac, inv, facinv;
    public override string ToString() => Value.ToString();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Value += r.Value;
        if (l.Value >= MOD) l.Value -= MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Value -= r.Value;
        if (l.Value < 0) l.Value += MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt l) => l.Value;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long n)
    {
        n %= MOD; if (n < 0) n += MOD;
        return new ModInt(n);
    }

    public static ModInt Pow(ModInt m, long n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(m * m, n >> 1);
        else return Pow(m * m, n >> 1) * m;
    }

    public static void Build(int n)
    {
        fac = new ModInt[n + 1];
        facinv = new ModInt[n + 1];
        inv = new ModInt[n + 1];
        inv[1] = fac[0] = fac[1] = facinv[0] = facinv[1] = 1;
        for (var i = 2; i <= n; i++)
        {
            fac[i] = fac[i - 1] * i;
            inv[i] = MOD - inv[MOD % i] * (MOD / i);
            facinv[i] = facinv[i - 1] * inv[i];
        }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Fac(int n) => fac[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Inv(int n) => inv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt FacInv(int n) => facinv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Comb(int n, int r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        return fac[n] * facinv[r] * facinv[n - r];
    }
    public static ModInt Perm(int n, int r)
    {
        if (n < r) return 0;
        return fac[n] * facinv[n - r];
    }

}
#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var sol = new Solver() { sc = new Scanner() };
        //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
        sol.Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static string Concat<T>(this IEnumerable<T> A, string sp) => string.Join(sp, A);
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int ArgMax<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next<T7>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }

    public static implicit operator Pair<T1, T2>((T1 f, T2 s) p) => new Pair<T1, T2>(p.f, p.s);
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }

    public static implicit operator Pair<T1, T2, T3>((T1 f, T2 s, T3 t) p) => new Pair<T1, T2, T3>(p.f, p.s, p.t);
}
#endregion


// "static void main" must be defined in a public class.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[][] a = new int[n][3];int c=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<3;j++){
                a[i][j] = sc.nextInt();
                c=c+a[i][j];
            }
        }    if(c==0){
    System.out.println("YES");}
    else{System.out.println("NO");

    }}
}


// "static void main" must be defined in a public class.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();int x=0,y=0,z=0;
        for(int i=0;i<n;i++){
            x=x+sc.nextInt();
            y=y+sc.nextInt();
            z=z+sc.nextInt();
        }

        if(x+y+z==0){
    System.out.println("YES");}
    else{System.out.println("NO");

    }}
}


// "static void main" must be defined in a public class.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[][] a = new int[n][n];int c=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<3;j++){
                a[i][j] = sc.nextInt();
                c=c+a[i][j];
            }
        }    if(c==0){
    System.out.println("YES");}
    else{System.out.println("NO");

    }}
}


// "static void main" must be defined in a public class.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[][] a = new int[n][3];int c=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<3;j++){
                a[i][j] = sc.nextInt();
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<3;j++){
                c=c+a[j][i];
            }
        }

        if(c==0){
    System.out.println("YES");}
    else{System.out.println("NO");

    }}
}


// "static void main" must be defined in a public class.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] a = new int[n][n];int c=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                a[i][j] = sc.nextInt();
                c=c+a[i][j];
            }
        }    if(c==0){
    System.out.println("YES");}
    else{System.out.println("NO");

    }}
}


import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();int x=0,y=0,z=0;
        for(int i=0;i<n;i++){
            x=x+sc.nextInt();
            y=y+sc.nextInt();
            z=z+sc.nextInt();
        }

        if(x==0 && y==0 &&z==0){
    System.out.println("YES");}
    else{System.out.println("NO");

    }}
}


import java.util.Arrays;
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count =0;
		int sum[] = new int[3];
		int a[][] = new int[n][3];
		for(int i=0; i<n; i++)
		{
			for(int j=0; j<3; j++)
			{
				a[i][j] = sc.nextInt();
			}
		}

		for(int i=0; i<3; i++)
		{
			for(int j=0; j<n; j++)
			{
				sum[i] += a[j][i];
				System.out.println(sum[i]);
			}
		}
		if(sum[2] == 0 && sum[1] ==0 && sum[0] == 0)
		{
			System.out.println("YES");
		}
		else System.out.println("NO");
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count =0;
		int sum[] = new int[n];
		int a[][] = new int[n][3];
		for(int i=0; i<n; i++)
		{
			for(int j=0; j<3; j++)
			{
				a[i][j] = sc.nextInt();
			}
		}

		for(int i=0; i<3; i++)
		{
			for(int j=0; j<n; j++)
			{
				sum[i] += a[j][i];
			}
		}
		if(sum[2] == 0)
		{
			System.out.println("YES");
		}
		else System.out.println("NO");
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count =0;
		int sum[] = new int[3];
		int a[][] = new int[n][3];
		for(int i=0; i<n; i++)
		{
			for(int j=0; j<3; j++)
			{
				a[i][j] = sc.nextInt();
			}
		}

		for(int i=0; i<3; i++)
		{
			for(int j=0; j<n; j++)
			{
				sum[i] += a[j][i];
			}
		}
		if(sum[2] == 0 && sum[1] ==0 && sum[0] == 0)
		{
			System.out.println("YES");
		}
		else System.out.println("NO");
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count =0;
		int sum[] = new int[3];
		int a[][] = new int[n][3];
		for(int i=0; i<n; i++)
		{
			for(int j=0; j<3; j++)
			{
				a[i][j] = sc.nextInt();
			}
		}

		for(int i=0; i<3; i++)
		{
			for(int j=0; j<n; j++)
			{
				sum[i] += a[j][i];
			}
		}
		if(sum[2] == 0)
		{
			System.out.println("YES");
		}
		else System.out.println("NO");
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
//		int count =0;
		int sum[] = new int[n];
		int a[][] = new int[n][3];
		for(int i=0; i<n; i++)
		{
			for(int j=0; j<3; j++)
			{
				a[i][j] = sc.nextInt();
			}
		}

		for(int i=0; i<3; i++)
		{
			for(int j=0; j<n; j++)
			{
				sum[i] += a[j][i];
			}
		}
		if(sum[n-1] == 0)
		{
			System.out.println("YES");
		}
		else System.out.println("NO");
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
//		int count =0;
		int sum[] = new int[n];
		int a[][] = new int[n][n];
		for(int i=0; i<n; i++)
		{
			for(int j=0; j<n; j++)
			{
				a[i][j] = sc.nextInt();
			}
		}

		for(int i=0; i<n; i++)
		{
			for(int j=0; j<n; j++)
			{
				sum[i] += a[j][i];
			}
			System.out.println(sum[i]);
		}
		if(sum[n-1] == 0)
		{
			System.out.println("YES");
		}
		else System.out.println("NO");
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
//		int count =0;
		int sum[] = new int[n];
		int a[][] = new int[n][n];
		for(int i=0; i<n; i++)
		{
			for(int j=0; j<n; j++)
			{
				a[i][j] = sc.nextInt();
			}
		}

		for(int i=0; i<n; i++)
		{
			for(int j=0; j<n; j++)
			{
				sum[i] += a[j][i];
			}
		}
		if(sum[n-1] == 0)
		{
			System.out.println("YES");
		}
		else System.out.println("NO");
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count =0;
		int sum[] = new int[n];
		int a[][] = new int[n][3];
		for(int i=0; i<n; i++)
		{
			for(int j=0; j<3; j++)
			{
				a[i][j] = sc.nextInt();
			}
		}

		for(int i=0; i<3; i++)
		{
			for(int j=0; j<n; j++)
			{
				sum[i] += a[j][i];
				System.out.println(sum[i]);
				count += 1;
			}
		}
		System.out.println(count);
		if(sum[2] == 0)
		{
			System.out.println("YES");
		}
		else System.out.println("NO");
	}
}


import java.util.Scanner;

public class youngPhysics {
	public static String sq() {
		Scanner sc =new Scanner (System.in);
		int n =sc.nextInt();
		int x =0;
		int y=0;
		int z=0;
		for(int i=0;i<n;i++) {
			 x =x+sc.nextInt();
			 y =y+sc.nextInt();
			 z =z+sc.nextInt();
		}
		if(x !=0 && y!=0 && z!=0) {
			return"NO";
		}
		else {
			return"YES";
		}

	}
	public static void main (String [] args) {
		System.out.print(sq());
	}

}


import java.util.Scanner;

public class youngPhysics {
	public static String sq() {

		Scanner sc =new Scanner (System.in);
		int n =sc.nextInt();
		int xs =0;
		int ys=0;
		int zs=0;

		for(int i=0;i<n;i++) {
			int  x =sc.nextInt();
			int y=sc.nextInt();
			int z =sc.nextInt();
			 xs =xs + x;

			 ys =ys +y;

			 zs =zs + z;

		}
		if(xs !=0 && ys!=0 && zs!=0) {
			return"NO";
		}
		else {
			return"YES";
		}

	}
	public static void main (String [] args) {
		System.out.print(sq());
	}

}


import java.util.Scanner;

public class youngPhysics {
	public static String sq() {

		Scanner sc =new Scanner (System.in);
		int n =sc.nextInt();
		int xs =0;
		int ys=0;
		int zs=0;

		for(int i=0;i<n;i++) {
			int  x =sc.nextInt();
			int y=sc.nextInt();
			int z =sc.nextInt();
			 xs =xs + x;

			 ys =ys +y;

			 zs =zs + z;

		}
		if(xs ==0 && ys==0 && zs==0) {
			return"YES";
		}
		else {
			return"NO";
		}

	}
	public static void main (String [] args) {
		System.out.print(sq());
	}

}


import java.util.Scanner;

public class youngPhysics {
	public static String sq() {
		Scanner sc =new Scanner (System.in);
		int n =sc.nextInt();
		int x =0;
		int y=0;
		int z=0;
		for(int i=0;i<n;i++) {
			 x =x + sc.nextInt();
			 y =y + sc.nextInt();
			 z =z + sc.nextInt();
		}
		if(x !=0 && y!=0 && z!=0) {
			return"NO";
		}
		else {
			return"YES";
		}

	}
	public static void main (String [] args) {
		System.out.print(sq());
	}

}


import java.util.Scanner;

public class youngPhysics {
	public static String sq() {
		Scanner sc =new Scanner (System.in);
		int n =sc.nextInt();
		int x =0;
		int y=0;
		int z=0;
		for(int i=0;i<=n;i=i+1) {
			 x =x + sc.nextInt();
			 y =y + sc.nextInt();
			 z =z + sc.nextInt();
		}
		if(x !=0 && y!=0 && z!=0) {
			return"NO";
		}
		else {
			return"YES";
		}

	}
	public static void main (String [] args) {
		System.out.print(sq());
	}

}


import java.util.Scanner;

public class youngPhysics {
	public static String sq() {

		Scanner sc =new Scanner (System.in);
		int n =sc.nextInt();
		int xs =0;
		int ys=0;
		int zs=0;
		int i= 0;
		while(i<n) {
			int  x =sc.nextInt();
			int y=sc.nextInt();
			int z =sc.nextInt();
			 xs =xs + x;

			 ys =ys +y;

			 zs =zs + z;

			 i++;
		}
		if(xs !=0 && ys!=0 && zs!=0) {
			return"NO";
		}
		else {
			return"YES";
		}

	}
	public static void main (String [] args) {
		System.out.print(sq());
	}

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication2;

import java.util.Scanner;

/**
 *
 * @author mmmm
 */
public class JavaApplication2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

       int y,x,z, n;
       int a=0,b=0,c=0 ;

        n = input.nextInt();

             while (n>=1) {
              x=input.nextInt();
              a+=x;
               z=input.nextInt();
              b+=z;
               y=input.nextInt();
              c+=y;
              n--;
            }

            if(a==0 && b==0 && c==0)
                       System.out.println("yes");
	               else
                            System.out.println("no");

    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication2;

import java.util.Scanner;

/**
 *
 * @author mmmm
 */
public class JavaApplication2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

       int y,x,z, n;
       int a=0,b=0,c=0 ;

        n = input.nextInt();
       for(int i=0;i<n;i++)
       {
          x=input.nextInt();
              a+=x;
               z=input.nextInt();
              b+=z;
               y=input.nextInt();
              c+=y;
       }

              if(a==0 && b==0 && c==0) {
                System.out.println("yes");
              }else{
                      System.out.println("no");
              }

        }

    }


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication2;

import java.util.Scanner;

/**
 *
 * @author mmmm
 */
public class JavaApplication2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

       int y=0 ;
       int x=0 ;
       int z=0 ;
       int n;
       int a=0,b=0,c=0 ;

        n = input.nextInt();
        if ( n>=1&&n<=100 )
        {

             while (n>=1) {
              x=input.nextInt();
              a+=x;
               z=input.nextInt();
              b+=z;
               y=input.nextInt();
              c+=y;
              n--;
            }

                   if(a==0 && b==0 && c==0)
                       System.out.println("yes");
	               else
                            System.out.println("no");

        }

    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication2;

import java.util.Scanner;

/**
 *
 * @author mmmm
 */
public class JavaApplication2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

       int y ,x,z,n=0;
       int a=0,b=0,c=0 ;

n = input.nextInt();
        if ( n>=1&&n<=100 )
        {
             while (n>=1) {
              x=input.nextInt();
              a+=x;
               z=input.nextInt();
              b+=z;
               y=input.nextInt();
              c+=y;
              n--;
            }

                   if(a==0 && b==0 && c==0)
                       System.out.println("yes");
	               else
                            System.out.println("no");

        }

    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication2;

import java.util.Scanner;

/**
 *
 * @author mmmm
 */
public class JavaApplication2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

       int y,x,z,    n=0;
       int a=0,b=0,c=0 ;

        n = input.nextInt();
        if ( n>=1&&n<=100 )
        {

             while (n>=1) {
              x=input.nextInt();
              a+=x;
               z=input.nextInt();
              b+=z;
               y=input.nextInt();
              c+=y;
              n--;
            }

                   if(a==0 && b==0 && c==0)
                       System.out.println("yes");
	               else
                            System.out.println("no");

        }

    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication3;

import java.util.Scanner;

/**
 *
 * @author mmmm
 */
public class JavaApplication3 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
         Scanner input = new Scanner(System.in);

       int y,x,z, n;
       int a=0,b=0,c=0 ;

        n = input.nextInt();
       for(int i=0;i<n;i++)
       {
               x=input.nextInt();
               z=input.nextInt();
               y=input.nextInt();

                a+=x;
                b+=z;
                c+=y;
       }

              if(a==0 && b==0 && c==0)
                System.out.println("yes");
	           else
                      System.out.println("no");

        }

    }


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication2;

import java.util.Scanner;

/**
 *
 * @author mmmm
 */
public class JavaApplication2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

       int y,x,z ;
       int n;
       long a=0,b=0,c=0 ;

        n = input.nextInt();
        if ( n>=1&&n<=100 )
        {

             while (n>=1) {
              x=input.nextInt();
              a+=x;
               z=input.nextInt();
              b+=z;
               y=input.nextInt();
              c+=y;
              n--;
            }

                   if(a==0 && b==0 && c==0)
                       System.out.println("yes");
	               else
                            System.out.println("no");

        }

    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication2;

import java.util.Scanner;

/**
 *
 * @author mmmm
 */
public class JavaApplication2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

       int y,x,z,    n;
       int a=0,b=0,c=0 ;

        n = input.nextInt();
        if ( n>=1&&n<=100 )
        {

             while (n>=1) {
              x=input.nextInt();
              a+=x;
               z=input.nextInt();
              b+=z;
               y=input.nextInt();
              c+=y;
              n--;
            }

                   if(a==0 && b==0 && c==0)
                       System.out.println("yes");
	               else
                            System.out.println("no");

        }

    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package gava;

import java.util.Scanner;

/**
 *
 * @author mmmm
 */
public class gava{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

       int y,x,z, n;
       int a=0,b=0,c=0 ;

        n = input.nextInt();
       for(int i=0;i<n;i++)
       {
          x=input.nextInt();
              a+=x;
               z=input.nextInt();
              b+=z;
               y=input.nextInt();
              c+=y;
       }

              if(a==0 && b==0 && c==0) {
                System.out.println("yes");
              }else{
                      System.out.println("no");
              }

        }

    }


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		int[][] mat = new int[t][3];
		int[] sums = new int[3];
		for (int i = 0; i < t; i++) {
			for (int j = 0; j < 3; j++) {
				mat[i][j] = in.nextInt();
				sums[j] += mat[i][j];
			}
		}
		if (sums[0] == 0 && sums[1] == 0 && sums[2] == 0)
			System.out.println("YES");
		else
			System.out.println("NO");
		in.close();
	}
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication2;

import java.util.Scanner;

/**
 *
 * @author mmmm
 */
public class JavaApplication2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

       int y,x,z, n;
       int a=0,b=0,c=0 ;

        n = input.nextInt();
       for(int i=0;i<n;i++)
       {
          x=input.nextInt();
              a+=x;
               z=input.nextInt();
              b+=z;
               y=input.nextInt();
              c+=y;
       }

              if(a==0 && b==0 && c==0)
                System.out.println("yes");
	           else
                      System.out.println("no");

        }

    }


import java.io.*;
public class Solution
 {

    public static void main(String[] args)
     {
        int i;
        int n = scan.nextInt();
        int[] a = {0,0,0};
        Scanner scan = new Scanner(System.in);
        for(i=0;i<n;i++)
        {
           a[i]+=scan.nextInt();
        }
        if(a[0]==0&&a[1]==0&&a[2]==0)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
     }
 }


import java.io.*;
public class Young Physicist{

    public static void main(String[] args) {
        int i;
        int n = scan.nextInt();
        int[] a = {0,0,0};
        Scanner scan = new Scanner(System.in);
        for(i=0;i<n;i++)
        {
           a[0]+=scan.nextInt();
           a[1]+=scan.nextInt();
           a[2]+=scan.nextInt();
        }
        if(a[0]==0&&a[1]==0&&a[2]==0)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
     }
 }


import java.io.*;
public class Young Physicist
 {

    public static void main(String[] args)
     {
        int i;
        int n = scan.nextInt();
        int[] a = {0,0,0};
        Scanner scan = new Scanner(System.in);
        for(i=0;i<n;i++)
        {
           a[0]+=scan.nextInt();
           a[1]+=scan.nextInt();
           a[2]+=scan.nextInt();
        }
        if(a[0]==0&&a[1]==0&&a[2]==0)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
     }
 }


import java.io.*;
public class Solution
 {

    public static void main(String[] args)
     {
        int i;
        int n = scan.nextInt();
        int[] a = {0,0,0};
        Scanner scan = new Scanner(System.in);
        for(i=0;i<n;i++)
        {
           a[0]+=scan.nextInt();
           a[1]+=scan.nextInt();
           a[2]+=scan.nextInt();
        }
        if(a[0]==0&&a[1]==0&&a[2]==0)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
     }
 }


import java.io.*
public class Solution
 {

    public static void main(String[] args)
     {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int a[] = new int[3];
        a[3] = {0,0,0};
        for(int i=0;i<n;i++)
        {
           a[i]+=scan.nextInt();
        }
        if(a[0]==0&&a[1]==0&&a[2]==0)
        {
            System.out.println("YES");
        }
     }
 }


import java.io.*;
public class 69A
 {

    public static void main(String[] args)
     {
        int i;
        int n = scan.nextInt();
        int[] a = {0,0,0};
        Scanner scan = new Scanner(System.in);
        for(i=0;i<n;i++)
        {
           a[0]+=scan.nextInt();
           a[1]+=scan.nextInt();
           a[2]+=scan.nextInt();
        }
        if(a[0]==0&&a[1]==0&&a[2]==0)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
     }
 }


import java.io.*;
import java.util.*;
public class Solution
 {

    public static void main(String[] args)
     {
        int i;
        int n = scan.nextInt();
        int[] a = {0,0,0};
        Scanner scan = new Scanner(System.in);
        for(i=0;i<n;i++)
        {
           a[0]+=scan.nextInt();
           a[1]+=scan.nextInt();
           a[2]+=scan.nextInt();
        }
        if(a[0]==0&&a[1]==0&&a[2]==0)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
     }
 }


import java.io.*;
public class Young Physicist
 {

    public static void main(String[] args)
     {
        int i;
        int n = scan.nextInt();
        int[] a = {0,0,0};
        Scanner scan = new Scanner(System.in);
        for(i=0;i<n;i++)
        {
           a[i]+=scan.nextInt();
        }
        if(a[0]==0&&a[1]==0&&a[2]==0)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
     }
 }


import java.io.*;
public class Young_Physicist
 {

    public static void main(String[] args)
     {
        int i;
        int n = scan.nextInt();
        int[] a = {0,0,0};
        Scanner scan = new Scanner(System.in);
        for(i=0;i<n;i++)
        {
           a[i]+=scan.nextInt();
        }
        if(a[0]==0&&a[1]==0&&a[2]==0)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
     }
 }


import java.io.*;
import java.util.*;
public class Solution
 {

    public static void main(String[] args)
     {
        int i;
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = {0,0,0};

        for(i=0;i<n;i++)
        {
           a[0]+=scan.nextInt();
           a[1]+=scan.nextInt();
           a[2]+=scan.nextInt();
        }
        if(a[0]==0&&a[1]==0&&a[2]==0)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
     }
 }


import java.io.*;
public class Young{

    public static void main(String[] args)
     {
        int i;
        int n = scan.nextInt();
        int[] a = {0,0,0};
        Scanner scan = new Scanner(System.in);
        for(i=0;i<n;i++)
        {
           a[0]+=scan.nextInt();
           a[1]+=scan.nextInt();
           a[2]+=scan.nextInt();
        }
        if(a[0]==0&&a[1]==0&&a[2]==0)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
     }
 }


import java.util.Scanner;
public class Code {
	static Scanner sr = new Scanner(System.in);
	public static void main(String[] args) {
		int[] summ= new int[3];
		int n = sr.nextInt();
		int [][] matrix = new int[3][n];

		for(int i = 0 ;i < n;i++) {
			matrix[0][i] = sr.nextInt();
			matrix[1][i] = sr.nextInt();
			matrix[2][i] = sr.nextInt();
			}
		for(int j = 0;j<3;j++) {
			for(int i = 0;i< n;i++) {
				summ[j]+=matrix[j][i];
			}
		}
	if((summ[0] == 0)&&(summ[1]==0)&&(summ[2]==0)) System.out.println("YES");
	else System.out.println("NO");

	}
}


import java.util.Scanner;
public class Code {
	static Scanner sr = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sr.nextInt();
		int [][] matrix = new int[3][n];
		int  summ = 0;
		for(int i = 0;i < 3;i++) {
			for(int j = 0;j < n;j++) {
				matrix[i][j] = sr.nextInt();
				summ += matrix[i][j];

			}
		}

		if(summ > 0) System.out.println("NO");
		else System.out.println("YES");
	}

}


import java.util.Scanner;
public class Code {
	static Scanner sr = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sr.nextInt();
		int [][] matrix = new int[3][n];
		int  summ = 0;
		for(int i = 0;i < n;i++) {
			for(int j = 0;j < n;j++) {
				matrix[i][j] = sr.nextInt();
				summ += matrix[i][j];

			}
		}

		if(summ > 0) System.out.println("NO");
		else System.out.println("YES");
	}

}


import java.util.Scanner;
public class Code {
	static Scanner sr = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sr.nextInt();
		int [][] matrix = new int[3][n];
		int  summ = 0;
		for(int i = 0;i < 3;i++) {
			for(int j = 0;j < n;j++) {
				matrix[i][j] = sr.nextInt();
				summ += matrix[i][j];

			}
		}

		if(summ == 0) System.out.println("YES");
		else System.out.println("NO");
	}

}


import java.util.Scanner;
public class Code {
	static Scanner sr = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sr.nextInt();
		int [][] matrix = new int[3][n];
		int  summ = 0;
		boolean full = false;
		for(int i = 0;i < n;i++) {
			for(int j = 0;j < n;j++) {
				matrix[i][j] = sr.nextInt();
				summ += matrix[i][j];

			}
		}
		System.out.println(summ);
		if(summ > 0) System.out.println("NO");
		else System.out.println("YES");
	}

}


import java.util.Scanner;
public class Code {
	static Scanner sr = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sr.nextInt();
		int [][] matrix = new int[3][n];
		int  summ = 0;
		for(int i = 0;i < 3;i++) {
			for(int j = 0;j < n;j++) {
				matrix[i][j] = sr.nextInt();
				summ += matrix[i][j];

			}
		}

		if(summ > 0 || summ < 0) System.out.println("NO");
		else System.out.println("YES");
	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int c[] = new int[n*3];
		for(int i = 0;i<n*3;i++) {
			c[i] = in.nextInt();
		}
		int sum = 0;
		int cnt = 0;
		for(int i = 0;i<n;i++) {
			for(int j = i;j<n*3;j+=3) {
				sum+=c[j];
			}
			if(sum==0)
				cnt++;
			sum=0;
		}
		if(cnt==n)
			System.out.println("YES");
		else
			System.out.println("NO");

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int c[][] = new int[n][3];
		for(int i = 0;i<n;i++) {
			for(int j = 0;j<3;j++) {
				c[i][j] = in.nextInt();
			}
		}
		int sum = 0;
		int cnt = 0;
		for(int i = 0;i<3;i++) {
			for(int j = 0;j<n;j++) {
				sum+=c[j][i];
			}
			if(sum==0)
				cnt++;
			sum=0;
		}
		if(cnt==n)
			System.out.println("YES");
		else
			System.out.println("NO");

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int c[][] = new int[n][3];
		for(int i = 0;i<n;i++) {
			for(int j = 0;j<3;j++) {
				c[i][j] = in.nextInt();
			}
		}
		int sum = 0;
		int cnt = 0;
		for(int i = 0;i<3;i++) {
			for(int j = 0;j<n;j++) {
				sum+=c[j][i];
			}
			if(sum==0)
				cnt++;
			sum=0;
		}
		if(cnt==n)
			System.out.println("YES");
		else
			System.out.println("NO");

	}
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int c[] = new int[n*3];
		for(int i = 0;i<n*3;i++) {
			c[i] = in.nextInt();
		}
		int sum = 0;
		int cnt = 0;
		for(int i = 0;i<n;i++) {
			for(int j = i;j<n*3;j+=3) {
				sum+=c[j];
				System.out.print(sum + "*");
			}
			System.out.println();
			if(sum==0)
				cnt++;
			sum=0;
		}
		if(cnt==n)
			System.out.println("YES");
		else
			System.out.println("NO");

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int c[] = new int[n*3];
		for(int i = 0;i<n*3;i++) {
			c[i] = in.nextInt();
		}
		int sum = 0;
		int cnt = 0;
		for(int i = 0;i<3;i++) {
			for(int j = i;j<n*3;j+=3) {
				sum+=c[j];
			}
			if(sum==0)
				cnt++;
			sum=0;
		}
		if(cnt==3)
			System.out.println("YES");
		else
			System.out.println("NO");

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int c[][] = new int[n][3];
		for(int i = 0;i<n;i++) {
			for(int j = 0;j<3;j++) {
				c[j][i] = in.nextInt();
			}
		}
		int sum = 0;
		int cnt = 0;
		for(int i = 0;i<n;i++) {
			for(int j = 0;j<3;j++) {
				sum+=c[i][j];
			}
			if(sum==0)
				cnt++;
			sum=0;
		}
		if(cnt==n)
			System.out.println("YES");
		else
			System.out.println("NO");

	}

}


import java.util.Scanner;

public class example{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(), x = 0, y = 0, z = 0;
    while(n -- > 0)
    {
    	x += sc.nextInt();y += sc.nextInt(); z += sc.nextInt();
    }
    System.out.print( (x == 0 && y == 0 && z == 0) ? "YES": "NO");

   }
}


import java.util.Scanner;

public class example{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n], y = new int[n], z = new int[n];
    boolean flag = true;
    for(int i = 0; i < n; i++)
    	x[i] = sc.nextInt();
    for(int i = 0; i < n; i++)
    	y[i] = sc.nextInt();
    for(int i = 0; i < n; i++)
    	z[i] = sc.nextInt();
    for(int i = 0; i < n; i++)
    {
    	if(x[i] + y[i] + z[i] == 0)
    		flag = true;
    	else
    	{
    		flag = false;
    		break;
    	}

    }
    if(flag == false)
    	System.out.print("N0");
    else
    	System.out.print("YES");
   }
}


import java.util.Scanner;

public class example{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int sum1 = 0, sum2 = 0, sum3 = 0;
    for(int i = 0; i < n; i++)
     sum1 += sc.nextInt();
    for(int i = 0; i < n; i++)
    	sum2+= sc.nextInt();
    for(int i = 0; i < n; i++)
    	sum3 += sc.nextInt();
    if((sum1 + sum2 + sum3 )== 0)
    	System.out.print("YES");
    else
    	System.out.print("NO");
   }
}


import java.util.Scanner;
public class O{

public static void main (String [] tt){
  Scanner sc = new Scanner(System.in);
 int x=0,y=0,z=0;
  int n=sc.nextInt();
  while(n-->0){x+=sc.nextInt();y+=sc.nextInt();z+=sc.nextInt();}
  System.out.print(x==0&&y==0&&z==0?"YES":"NO");


import java.util.Scanner;

public class example{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n], y = new int[n], z = new int[n];
    boolean flag = true;
    for(int i = 0; i < n; i++)
    	x[i] = sc.nextInt();
    for(int i = 0; i < n; i++)
    	y[i] = sc.nextInt();
    for(int i = 0; i < n; i++)
    	z[i] = sc.nextInt();
    for(int i = 0; i < n; i++)
    {
    	if(x[i] + y[i] + z[i] == 0)
    		flag = true;
    	else
    	{
    		flag = false;
    		break;
    	}

    }
    if(flag == false)
    	System.out.print("NO");
    else
    	System.out.print("YES");
   }
}


import java.util.Scanner;

public class Cf_112_A {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int x=0, y=0,z=0, sum = 0;
    for(int i=0;i<n;i++){
    	x +=sc.nextInt();y+=sc.nextInt();z+=sc.nextInt();
    }

    System.out.print(x == 0 && y== 0 && z==0? "YES":"NO");
	}
	}


import java.util.Scanner;
public class Sol
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int x=0,y=0,z=0;
        int sum=0;
        for(int i=0;i<n;i++)
        {
            int x=x+s.nextInt();
            int y=y+s.nextInt();
            int z=z+s.nextInt();

        }
        if(x==0&&y==0&&z==0)
        System.out.println("YES");
        else
        System.out.println("NO");
    }
}


import java.util.Scanner;
public class Sol
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int x=0,y=0,z=0;
        int sum=0;
        for(int i=0;i<n;i++)
        {
            int x+=s.nextInt();
            int y+=s.nextInt();
            int z+=s.nextInt();

        }
        if(x==0&&y==0&&z==0)
        System.out.println("YES");
        else
        System.out.println("NO");
    }
}


import java.util.Scanner;
public class Sol
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int sum=0;
        int x=0,y=0,z=0;
        for(int i=0;i<n;i++)
        {
             x=s.nextInt();
             y=s.nextInt();
             z=s.nextInt();
            sum=sum+x+y+z;
        }
        if(sum==0)
        System.out.println("YES");
        else
        System.out.println("NO");
    }
}


import java.util.Scanner;
public class Sol
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int sum=0;
        for(int i=0;i<n;i++)
        {
            int x=s.nextInt();
            int y=s.nextInt();
            int z=s.nextInt();
            sum=sum+x+y+z;
        }
        if(sum==0)
        System.out.println("YES");
        else
        System.out.println("NO");
    }
}


import java.util.Scanner;
public class Sol
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        for(int i=0;i<n;i++)
        {
            int x=s.nextInt();
            int y=s.nextInt();
            int z=s.nextInt();
            sum=sum+x+y+z;
        }
        if(sum==0)
        System.out.println("YES");
        else
        System.out.println("NO");
    }
}


import java.util.Scanner;
public class Sol
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int x=0,y=0,z=0;
        int sum=0;
        for(int i=0;i<n;i++)
        {
             x=x+s.nextInt();
             y=y+s.nextInt();
             z=z+s.nextInt();

        }
        if(x==0&&y==0&&z==0)
        System.out.println("YES");
        else
        System.out.println("NO");
    }
}


package hello;

import java.util.Scanner;

public class carsimulator {

	public static void main(String[] args) {

		Scanner	input = new Scanner(System.in);

int m = input.nextInt();
	 int sum1=0;
if(m>=1&&m<=100) {

	for(int i=1; i<=m ; i++) {

		int x = input.nextInt();
		int y = input.nextInt();
		int z= input.nextInt();
sum1=sum1 +(x+y+z);

	}
		 if(sum1==0) {System.out.println("YES");
		 }else {
		System.out.println("NO");
		 }
	}

	}
}


import java.util.Scanner;

public class carsimulator {

	public static void main(String[] args) {
		/* TODO Auto-generated method stub

		Scanner	input = new Scanner(System.in);

System.out.println("enter force numbers");

int m = input.nextInt();
	 int sum1=0;
if(m>=1&&m<=100) {

	for(int i=1; i<=m ; i++) {

		int x = input.nextInt();
		int y = input.nextInt();
		int z= input.nextInt();
sum1=sum1 +(x+y+z);

	}
		 if(sum1==0) {System.out.println("YES");
		 }else {
    		System.out.println("NO");
		 }
	}

	}
}


package hello;

import java.util.Scanner;

public class carsimulator {

	public static void main(String[] args) {

		Scanner	input = new Scanner(System.in);

int m = input.nextInt();
	 int sum1=0;

	for(int i=1; i<=m ; i++) {

		int x = input.nextInt();
		int y = input.nextInt();
		int z= input.nextInt();
sum1=sum1 +(x+y+z);

	}
		 if(sum1==0) {System.out.println("YES");
		 }else {
		System.out.println("NO");
		 }

	}
}


import java.util.Scanner;

public class carsimulator {

	public static void main(String[] args) {
		/* TODO Auto-generated method stub
 car bojati = new car();
 bojati.color="red";
 bojati.is_running=true;

 // this is an object

 car bjati3 =new car();
 bjati3.color="black";
 bjati3.is_running=false;
 System.out.print(bjati3.is_running);
 */
		Scanner	input = new Scanner(System.in);

int m = input.nextInt();
	 int sum1=0;
if(m>=1&&m<=100) {

	for(int i=1; i<=m ; i++) {

		int x = input.nextInt();
		int y = input.nextInt();
		int z= input.nextInt();
sum1=sum1 +(x+y+z);

	}
		 if(sum1==0) {System.out.println("yes");
		 }else {
		System.out.println("no");
		 }
	}

	}
}


import java.util.Scanner;

public class carsimulator {

	public static void main(String[] args) {
		/* TODO Auto-generated method stub
 car bojati = new car();
 bojati.color="red";
 bojati.is_running=true;

 // this is an object

 car bjati3 =new car();
 bjati3.color="black";
 bjati3.is_running=false;
 System.out.print(bjati3.is_running);
 */
		Scanner	input = new Scanner(System.in);

System.out.println("enter force numbers");

int m = input.nextInt();
	 int sum1=0;
if(m>=1&&m<=100) {

	for(int i=1; i<=m ; i++) {

		int x = input.nextInt();
		int y = input.nextInt();
		int z= input.nextInt();
sum1=sum1 +(x+y+z);

	}
		 if(sum1==0) {System.out.println("yes");
		 }else {
		System.out.println("no");
		 }
	}

	}
}


import java.util.Scanner;

public class carsimulator {

	public static void main(String[] args) {
		/* TODO Auto-generated method stub
 car bojati = new car();
 bojati.color="red";
 bojati.is_running=true;

 // this is an object

;
 bjati3.color="black";
 bjati3.is_running=false;
 System.out.print(bjati3.is_running);
 */
		Scanner	input = new Scanner(System.in);

int m = input.nextInt();
	 int sum1=0;
if(m>=1&&m<=100) {

	for(int i=1; i<=m ; i++) {

		int x = input.nextInt();
		int y = input.nextInt();
		int z= input.nextInt();
sum1=sum1 +(x+y+z);

	}
		 if(sum1==0) {System.out.println("YES");
		 }else {
		System.out.println("NO");
		 }
	}

	}
}


import java.util.Scanner;

public class wqw {

		// TODO Auto-generated method stub

			public static void main(String[] args) {

					{

						Scanner	input = new Scanner(System.in);

				int m = input.nextInt();
					 int sumx=0;
					 int sumy=0;
					 int sumz=0;
				if(m>=1&&m<=100) {

					for(int i=1; i<=m ; i++) {

						int x = input.nextInt();
						int y = input.nextInt();
						int z= input.nextInt();
						sumx=sumx +x;
						sumz=sumz +z;
						sumy=sumz +y;

					}
						 if(sumx==0 &&sumy==0 &&sumz==0) {System.out.println("YES");
						 }else {
						System.out.println("NO");
						 }
					}

					}
				}

		}


import java.util.Scanner;

public class wqw {

		// TODO Auto-generated method stub

			public static void main(String[] args) {

					{

						Scanner	input = new Scanner(System.in);

				int m = input.nextInt();
					 int sumx=0;
					 int sumy=0;
					 int sumz=0;
				if(m>=1&&m<=100) {

					for(int i=1; i<=m ; i++) {

						int x = input.nextInt();
						int y = input.nextInt();
						int z= input.nextInt();
						sumx=sumx +x;
						sumz=sumz +z;
						sumy=sumy +y;

					}
						 if(sumx==0 &&sumy==0 &&sumz==0) {System.out.println("YES");
						 }else {
						System.out.println("NO");
						 }
					}

					}
				}

		}


import java.util.Scanner;

public class carsimulator {

	public static void main(String[] args) {
		/* TODO Auto-generated method stub
 car bojati = new car();
 bojati.color="red";
 bojati.is_running=true;

 // this is an object

 car bjati3 =new car();
 bjati3.color="black";
 bjati3.is_running=false;
 System.out.print(bjati3.is_running);
 */
		Scanner	input = new Scanner(System.in);

int m = input.nextInt();
	 int sum1=0;
if(m>=1&&m<=100) {

	for(int i=1; i<=m ; i++) {

		int x = input.nextInt();
		int y = input.nextInt();
		int z= input.nextInt();
sum1=sum1 +(x+y+z);

	}
		 if(sum1==0) {System.out.println("Yes");
		 }else {
		System.out.println("No");
		 }
	}

	}
}


package hello;

import java.util.Scanner;

public class carsimulator {

	public static void main(String[] args) {
		/* TODO Auto-generated method stub
 car bojati = new car();
 bojati.color="red";
 bojati.is_running=true;

 // this is an object

 car bjati3 =new car();
 bjati3.color="black";
 bjati3.is_running=false;
 System.out.print(bjati3.is_running);
 */
		Scanner	input = new Scanner(System.in);

int m = input.nextInt();
	 int sum1=0;
if(m>=1&&m<=100) {

	for(int i=1; i<=m ; i++) {

		int x = input.nextInt();
		int y = input.nextInt();
		int z= input.nextInt();
sum1=sum1 +(x+y+z);

	}
		 if(sum1==0) {System.out.println("YES");
		 }else {
		System.out.println("NO");
		 }
	}

	}
}


import java.util.Scanner;

public class carsimulator {

	public static void main(String[] args) {
		/* TODO Auto-generated method stub
 car bojati = new car();
 bojati.color="red";
 bojati.is_running=true;

 // this is an object

 car bjati3 =new car();
 bjati3.color="black";
 bjati3.is_running=false;
 System.out.print(bjati3.is_running);
 */
		Scanner	input = new Scanner(System.in);

int m = input.nextInt();
	 int sum1=0;
if(m>=1&&m<=100) {

	for(int i=1; i<=m ; i++) {

		int x = input.nextInt();
		int y = input.nextInt();
		int z= input.nextInt();
sum1=sum1 +(x+y+z);

	}
		 if(sum1==0) {System.out.println("YES");
		 }else {
		System.out.println("NO");
		 }
	}

	}
}


import java.util.Scanner;

public class carsimulator {

	public static void main(String[] args) {

		Scanner	input = new Scanner(System.in);

int m = input.nextInt();

	for(int i=1; i<=m ; i++) {

		int x = input.nextInt();
		int y = input.nextInt();
		int z= input.nextInt();
sum1=sum1 +(x+y+z);

	}
		 if(sum1==0) {System.out.println("YES");
		 }else {
		System.out.println("NO");

	}

	}
}


	import java.util.Scanner;

public class wqw {

		// TODO Auto-generated method stub

			public static void main(String[] args) {

					{

						Scanner	input = new Scanner(System.in);

				int m = input.nextInt();
					 int sumx=0;
					 int sumy=0;
					 int sumz=0;
				if(m>=1&&m<=100) {

					for(int i=1; i<=m ; i++) {

						int x = input.nextInt();
						int y = input.nextInt();
						int z= input.nextInt();
						sumx=sumx +x;
						sumz=sumx +z;
						sumy=sumx +y;

					}
						 if(sumx==0 &&sumy==0 &&sumz==0) {System.out.println("YES");
						 }else {
						System.out.println("NO");
						 }
					}

					}
				}

		}


import java.util.Scanner;

public class carsimulator {

	public static void main(String[] args) {
		/* TODO Auto-generated method stub
 car bojati = new car();rint(bjati3.is_running);
 */
		Scanner	input = new Scanner(System.in);

int m = input.nextInt();
	 int sum1=0;
if(m>=1&&m<=100) {

	for(int i=1; i<=m ; i++) {

		int x = input.nextInt();
		int y = input.nextInt();
		int z= input.nextInt();
sum1=sum1 +(x+y+z);

	}
		 if(sum1==0) {System.out.println("YES");
		 }else {
		System.out.println("NO");
		 }
	}

	}
}


import java.util.Scanner;

public class erf {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner	input = new Scanner(System.in);

		int m = input.nextInt();
		 int sum1=0;

		for(int i=1; i<=m ; i++) {

			int x = input.nextInt();
			int y = input.nextInt();
			int z= input.nextInt();
	sum1=sum1 +(x+y+z);

		}
			 if(sum1==0) {System.out.println("YES");
			 }else {
			System.out.println("NO");
			 }

		}

	}

}


import java.util.Scanner;

public class carsimulator {

	public static void main(String[] args) {
		/* TODO Auto-generated method stub
 car bojati = new car();
 bojati.color="red";
 bojati.is_running=true;

 // this is an object

 car bjati3 =new car();
 bjati3.color="black";
 bjati3.is_running=false;
 System.out.print(bjati3.is_running);
 */
		Scanner	input = new Scanner(System.in);

System.out.println("enter force numbers");

int m = input.nextInt();
	 int sum1=0;
if(m>=1&&m<=100) {

	for(int i=1; i<=m ; i++) {

		int x = input.nextInt();
		int y = input.nextInt();
		int z= input.nextInt();
sum1=sum1 +(x+y+z);

	}
		 if(sum1==0) {System.out.println("Yes");
		 }else {
		System.out.println("No");
		 }
	}

	}
}


import java.util.Scanner;
public class ahmed
{
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int x[n] = new int[n];
    int y[n] = new int[n];
    int z[n] = new int[n];
    int s1 = 0;
    int s2 = 0;
    int s3 = 0;
    for(int i = 0;i < n; ++i)
    {
        x[i] = s.nextInt();
        y[i] = s.nextInt();
        z[i] = s.nextInt();
        s1 += x[i];
        s2 += y[i];
        s3 += z[i];
    }
    if(s1 == 0 && y == 0 && z == 0)
    {
        System.out.println("YES");
    }
    else
    {
        System.out.println("NO");
    }
}


import java.util.Scanner;
public class ahmed
{
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int x[] = new int[n];
    int y[] = new int[n];
    int z[] = new int[n];
    int s1 = 0, s2 = 0, s3 = 0;
    for(int i = 0;i < n; ++i)
    {
        x[i] = s.nextInt();
        y[i] = s.nextInt();
        z[i] = s.nextInt();
        s1 += x[i];
        s2 += y[i];
        s3 += z[i];
    }
    if(s1 == 0 && y == 0 && z == 0)
    {
        System.out.println("YES");
    }
    else
    {
        System.out.println("NO");
    }
}


import java.util.Scanner;
public class ahmed
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int x[] = new int[n];
        int y[] = new int[n];
        int z[] = new int[n];
        int s1 = 0, s2 = 0, s3 = 0;
        for(int i = 0;i < n; ++i)
        {
            x[i] = s.nextInt();
            y[i] = s.nextInt();
            z[i] = s.nextInt();
            s1 += x[i];
            s2 += y[i];
            s3 += z[i];
        }
        if(s1 == 0 && y == 0 && z == 0)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
    }
}


import java.util.Scanner;
public class ahmed
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int x[] = new int[n];
        int y[] = new int[n];
        int z[] = new int[n];
        int s1 = 0, s2 = 0, s3 = 0;
        for(int i = 0;i < n; ++i)
        {
            x[i] = s.nextInt();
            y[i] = s.nextInt();
            z[i] = s.nextInt();
            s1 += x[i];
            s2 += y[i];
            s3 += z[i];
        }
        if(s1 == 0 && s2 == 0 && s3 == 0)
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
    }
}


import java.util.Scanner;
public class ahmed
{
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int x[] = new int[n];
    int y[] = new int[n];
    int z[] = new int[n];
    int s1 = 0, s2 = 0, s3 = 0;
    for(int i = 0;i < n; ++i)
    {
        x[i] = s.nextInt();
        y[i] = s.nextInt();
        z[i] = s.nextInt();
        s1 += x[i];
        s2 += y[i];
        s3 += z[i];
    }
    if(s1 == 0 && s2 == 0 && s3 == 0)
    {
        System.out.println("YES");
    }
    else
    {
        System.out.println("NO");
    }
}


import java.util.Scanner;
public class ahmed
{
    public static void main(String args[])
    {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int x[] = new int[n];
    int y[] = new int[n];
    int z[] = new int[n];
    int s1 = 0, s2 = 0, s3 = 0;
    for(int i = 0;i < n; ++i)
    {
        x[i] = s.nextInt();
        y[i] = s.nextInt();
        z[i] = s.nextInt();
        s1 += x[i];
        s2 += y[i];
        s3 += z[i];
    }
    if(s1 == 0 && y == 0 && z == 0)
    {
        System.out.println("YES");
    }
    else
    {
        System.out.println("NO");
    }
    }
}


package sdfgh;

import java.util.Scanner;

public class dfghj {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		int arr[];
		 int sum=0;
		 int size;
		 size=cin.nextInt();
		arr=new int[size];

		for(int i=0;i<size;i++)
		{
			for(int y=0;y<size;y++)
			{
			  arr[y]=cin.nextInt();
			  sum+=arr[y];

			}

		}

		if(sum==0)
		{
			System.out.println("YES");
		}

		else
		{
			System.out.println("NO");
		}

	}

}


package sdfgh;

import java.util.Scanner;

public class tryhjk {

	public static void main(String[] args)
	{
		int x=0,y=0,z=0;
		int xsum=0,ysum=0,zsum=0;
		Scanner cin=new Scanner(System.in);
		int n=cin.nextInt();
		for(int i=1;i<=n;i++)
		{

			x=cin.nextInt();
			xsum+=x;

			y=cin.nextInt();
			ysum+=y;

			z=cin.nextInt();
			zsum+=z;

		}
		 if(xsum==0&&ysum==0&&zsum==0)
		 {
			 System.out.println("YES");
		 }

		 else
		 {
			 System.out.println("NO");
		 }

	}

}


package sdfgh;

import java.util.Scanner;

public class tryhjk {

	public static void main(String[] args)
	{
		Scanner cin=new Scanner(System.in);
		int x=0,y=0,z=0;

		int n=cin.nextInt();
		for(int i=1;i<=n;i++)
		{

			x+=cin.nextInt();

			y+=cin.nextInt();

			z+=cin.nextInt();

		}
		 if(x==0&&y==0&&z==0)
		 {
			 System.out.println("YES");
		 }

		 else
		 {
			 System.out.println("NO");
		 }

	}

}


package sdfgh;

import java.util.Scanner;

public class dfghj {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		int arr[];
		 int sum=0;
		 int size;
		 size=cin.nextInt();
		arr=new int[size];

		for(int i=0;i<size;i++)
		{
			for(int y=0;y<3;y++)
			{
			  arr[y]=cin.nextInt();
			  sum+=arr[y];

			}

		}

		if(sum==0)
		{
			System.out.println("YES");
		}

		else
		{
			System.out.println("NO");
		}

	}

}


import java.util.Scanner;

public class tryhjk {

	public static void main(String[] args)
	{
		Scanner cin=new Scanner(System.in);
		int x=0,y=0,z=0;

		int n=cin.nextInt();
		for(int i=1;i<=n;i++)
		{

			x+=cin.nextInt();

			y+=cin.nextInt();

			z+=cin.nextInt();

		}
		 if(x==0&&y==0&&z==0)
		 {
			 System.out.println("YES");
		 }

		 else
		 {
			 System.out.println("NO");
		 }

	}

}


import java.util.Scanner;

public class mvbn {

	public static void main(String[] args)
	{
		Scanner cin=new Scanner(System.in);
		int arr[];
		 int sum=0;
		 int size;
		 size=cin.nextInt();
		arr=new int[size];

		for(int i=0;i<size;i++)
		{
			for(int y=0;y<size;y++)
			{
			  arr[y]=cin.nextInt();
			  sum+=arr[y];

			}

		}

		if(sum==0)
		{
			System.out.println("yes");
		}

		else
		{
			System.out.println("no");
		}

	}

}


import java.util.Scanner;

public class YoungPhysicist {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] array = new int[3*n];

		for (int i = 0; i < 3*n; i++) {
			array[i] = scan.nextInt();
		}
		int xsum = 0, ysum = 0, zsum = 0;
		for (int i = 0; i < array.length - 3; i = i + 3) {
			xsum += array[i];
			ysum += array[i + 1];
			zsum += array[i + 2];
		}

		if (xsum == ysum && ysum == zsum && xsum == 0) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		scan.close();
	}

}


import java.util.Scanner;

public class YoungPhysicist {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] array = new int[3*n];

		for (int i = 0; i < array.length; i++) {
			array[i] = scan.nextInt();
		}
		long xsum = 0, ysum = 0, zsum = 0;
		for (int i = 0; i <= array.length - 3; i = i + 3) {
			xsum += array[i];
			ysum += array[i + 1];
			zsum += array[i + 2];
		}
		// System.out.println(xsum + " " + ysum  + " " + zsum);
		if (xsum != 0) {
			System.out.println("NO");
		}
		else {
			if (ysum == zsum && ysum == 0) {
			System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
			}
		scan.close();
	}

}


import java.util.Scanner;

public class YoungPhysicist {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] array = new int[101];

		for (int i = 0; i < 3*n; i++) {
			array[i] = scan.nextInt();
		}
		int xsum = 0, ysum = 0, zsum = 0;
		for (int i = 0; i < array.length - 3; i = i + 3) {
			xsum += array[i];
			ysum += array[i + 1];
			zsum += array[i + 2];
		}

		if (xsum == ysum && ysum == zsum && xsum == 0) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		scan.close();
	}

}


import java.util.Scanner;

public class YoungPhysicist {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] array = new int[99];

		for (int i = 0; i < 3*n; i++) {
			array[i] = scan.nextInt();
		}
		int xsum = 0, ysum = 0, zsum = 0;
		for (int i = 0; i <= array.length - 3; i = i + 3) {
			xsum += array[i];
			ysum += array[i + 1];
			zsum += array[i + 2];
		}

		if (xsum == ysum && ysum == zsum && xsum == 0) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		scan.close();
	}

}


import java.util.Scanner;

public class YoungPhysicist {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] array = new int[99];

		for (int i = 0; i < 3*n; i++) {
			array[i] = scan.nextInt();
		}
		int xsum = 0, ysum = 0, zsum = 0;
		for (int i = 0; i < array.length - 3; i = i + 3) {
			xsum += array[i];
			ysum += array[i + 1];
			zsum += array[i + 2];
		}

		if (xsum == ysum && ysum == zsum && xsum == 0) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		scan.close();
	}

}


import java.util.Scanner;

public class YoungPhysicist {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] array = new int[101];

		for (int i = 0; i < 3*n; i++) {
			array[i] = scan.nextInt();
		}
		int xsum = 0, ysum = 0, zsum = 0;
		for (int i = 0; i < array.length - 3; i = i + 3) {
			xsum += array[i];
			ysum += array[i + 1];
			zsum += array[i + 2];
		}

		//System.out.println(xsum + " " + ysum + " " + zsum);

		if (xsum == ysum && ysum == zsum && xsum == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		scan.close();
	}

}


def findsolution(number):
    sonuc=number
    if number%2==0:
        sonuc=2
    elif number%3==0:
        sonuc=3
    elif number%5==0:
        sonuc=5
    else:
        numb=number//2
        for i in range(7,numb,2):
            if number%i==0:
                sonuc=i
                break
    return sonuc+number
for i in range(0,int(input())):
    x=input().split()
    n=int(x[0])
    k=int(x[1])
    for i in range(0,k):
        n=findsolution(n)
    print(n)


import math

def findlist(yy):
    number = yy

    ilk = []
    for q in range(2,number+1):
        ilk.append(q)

    q = 2
    while(q <= int(math.sqrt(number))):
        if q in ilk:
            for r in range(q*2, number+1, q):
                if r in ilk:
                    ilk.remove(r)
        q = q+1

    return ilk

def findsolution(number):
    sonuc=number
    if number%2==0:
        sonuc=2
    elif number%3==0:
        sonuc=3
    elif number%5==0:
        sonuc=5
    elif number%7==0:
        sonuc=7
    elif number%11==0:
        sonuc=11
    elif number%13==0:
        sonuc=13
    elif number%17==0:
        sonuc=17
    elif number%19==0:
        sonuc=19
    elif number%23==0:
        sonuc=23
    else:
        numb=int(math.sqrt(number))
        listx=findlist(numb)
        listx=listx[8:]
        for i in listx:
            #print(i)
            i=int(i)
            if number%i==0:
                sonuc=i
                break
    return sonuc+number
for i in range(0,int(input())):
    x=input().split()
    n=int(x[0])
    k=int(x[1])
    for i in range(0,k):
        n=findsolution(n)
    print(n)


import math

def findlist(yy):
    number = yy

    ilk = []
    for q in range(2,number+1):
        ilk.append(q)

    q = 2
    while(q <= int(math.sqrt(number))):
        if q in ilk:
            for r in range(q*2, number+1, q):
                if r in ilk:
                    ilk.remove(r)
        q = q+1

    return ilk

def findsolution(number):
    sonuc=number
    if number%2==0:
        sonuc=2
    elif number%3==0:
        sonuc=3
    elif number%5==0:
        sonuc=5
    elif number%7==0:
        sonuc=7
    elif number%11==0:
        sonuc=11
    elif number%13==0:
        sonuc=13
    elif number%17==0:
        sonuc=17
    elif number%19==0:
        sonuc=19
    elif number%23==0:
        sonuc=23
    else:
        numb=int(math.sqrt(number))
        listx=findlist(numb)
        for i in listx:
            i=int(i)
            if number%i==0:
                sonuc=i
                break
    return sonuc+number
for i in range(0,int(input())):
    x=input().split()
    n=int(x[0])
    k=int(x[1])
    for i in range(0,k):
        n=findsolution(n)
    print(n)


def findsolution(number):
    sonuc=number
    for i in range(2,number):
        if number%i==0:
            sonuc=i
            break
    return sonuc+number
for i in range(0,int(input())):
    x=input().split()
    n=int(x[0])
    k=int(x[1])
    for i in range(0,k):
        n=findsolution(n)
    print(n)


def func(n) :
    if (n <= 1) :
        return 1
    if (n <= 3) :
        return 3

    if (n % 2 == 0):
        return 2
    if (n % 3 == 0):
        return 3

    i = 5
    while(i * i <= n) :
        if (n % i == 0 ):
            return i
        if(n % (i + 2) == 0):
            return i+2
        i = i + 6

    return n
for _ in range(int(input())):
    n,k = map(int,input().split(' '))

    ld = func(n)

    print(n + ld +2*(k-1))


#code
def func(n) :
    if (n <= 1) :
        return 1
    if (n <= 3) :
        return 3

    if (n % 2 == 0):
        return 2
    if (n % 3 == 0):
        return 3

    i = 5
    while(i * i <= n) :
        if (n % i == 0 ):
            return i
        if(n % (i + 2) == 0):
            return i+2
        i = i + 6

    return n
for _ in range(int(input())):
    n,k = map(int,input().split(' '))

    for _ in range(k):
        n = func(n) + n

    print(n)


def func(n) :
    if (n <= 1) :
        return 1
    if (n <= 3) :
        return 3

    if (n % 2 == 0):
        return 2
    if (n % 3 == 0):
        return 3

    i = 5
    while(i * i <= n) :
        if (n % i == 0 ):
            return i
        if(n % (i + 2) == 0):
            return i+2
        i = i + 6

    return n
for _ in range(int(input())):
    n,k = map(int,input().split(' '))

    n = func(n) + n

    print(n + (k-1) * 2)


def func(n) :
    if (n <= 1) :
        return 1
    if (n <= 3) :
        return 3

    if (n % 2 == 0):
        return 2
    if (n % 3 == 0):
        return 3

    i = 5
    while(i * i <= n) :
        if (n % i == 0 ):
            return i
        if(n % (i + 2) == 0):
            return i+2
        i = i + 6

    return n
for _ in range(int(input())):
    n,k = map(int,input().split(' '))

    ld = func(n)

    print(n + ld + (k-1) * 2)


def func(n) :
    if (n % 2 == 0):
        return 2
    if (n % 3 == 0):
        return 3

    i = 5
    while(i * i <= n) :
        if (n % i == 0 ):
            return i
        if(n % (i + 2) == 0):
            return i+2
        i = i + 6

    return n
for _ in range(int(input())):
    n,k = map(int,input().split(' '))

    ld = func(n)

    print(n + ld + (k-1) * 2)


import math
for _ in range(int(input())):
    n,k=list(map(int,input().split()))
    prev=n
    if(n%2==0):
        prev=n
        n=n+2*k
        k=0
    else:
         while(k!=0):
            x=0
            for i in range(2,int(math.sqrt(n))+1):
                if(n%2==0):
                    n=n+2*k
                    k=0
                    x=1
                    break
                elif(n%i==0):
                    prev=n
                    n=n+i
                    k=k-1
            if(x==1):
                break
            if(n==prev):
                prev=n
                n=2*n
                k=k-1

    print(n)


import math
for _ in range(int(input())):
    n,k=list(map(int,input().split()))
    prev=n
    while(k!=0):
        for i in range(2,int(math.sqrt(n))+1):
            if(n%i==0):
                prev=n
                n=n+i
                k=k-1
                break
        if(n==prev):
            n=2*n
            k=k-1
    print(n)


import math
for _ in range(int(input())):
    n,k=list(map(int,input().split()))
    prev=n
    while(k!=0):
        if(n%2==0):
            prev=n
            n=n+2
            k=k-1
        else:
            for i in range(3,int(math.sqrt(n))+1):
                if(n%i==0):
                    prev=n
                    n=n+i
                    k=k-1
                    break
            if(n==prev):
                prev=n
                n=2*n
                k=k-1
    print(n)


import math
for _ in range(int(input())):
    n,k=list(map(int,input().split()))
    prev=n
    while(k!=0):
        for i in range(2,int(math.sqrt(n))+1):
            if(n%i==0):
                prev=n
                n=n+i
                k=k-1
                break
        if(n==prev):
            prev=n
            n=2*n
            k=k-1
    print(n)


import math
for _ in range(int(input())):
    n,k=list(map(int,input().split()))
    prev=n
    if(n%2==0):
        prev=n
        n=n+2*k
        k=0
    else:
         while(k!=0):
            for i in range(3,int(math.sqrt(n))+1):
                if(n%i==0):
                    prev=n
                    n=n+i
                    k=k-1
                    break
            if(n==prev):
                prev=n
                n=2*n
                k=k-1
    print(n)


# def OracAndfactors(n,k): # O(NrootN)

# 	i = 0
# 	flag = True
# 	while i<k:
# 		j = 1
# 		while j<= n**0.5:
# 			if n%j == 0:
# 				if j!=1:
# 					n+=j
# 					flag = False
# 					break
# 				j+=1
# 			else:
# 				flag = True
# 				j+=1

# 		if flag:
# 			n+=n

# 		i+=1

# 	return n

def OracAndfactors(n,k): # O(N)
	i =2
	while n%i!=0:
		i+=1
	return n+i+(k-1)*2

for i in range(int(input())):
	n,k = list(map(int,input().split()))
	print(OracAndfactors(n,k))


def oracAndfactors(n,k):
	for i in range(k):
		j = 2
		while j<n**0.5:
			if n%j == 0:
				flag = True
				break
			else:
				flag = False
			j+=1
		if flag:
			n+=j
		else:
			n+=n
	return n

for i in range(int(input())):
	n,k = list(map(int,input().split()))
	print(oracAndfactors(n,k))


def oracAndfactors(n,k):
	flag = False
	for i in range(k):
		j = 2
		while j<n**0.5:
			if n%j == 0:
				flag = True
				break
			else:
				flag = False
			j+=1
		if flag:
			n+=j
		else:
			n+=n
	return n

for i in range(int(input())):
	n,k = list(map(int,input().split()))
	print(oracAndfactors(n,k))


# def OracAndfactors(n,k): # O(NrootN)

# 	i = 0
# 	flag = True
# 	while i<k:
# 		j = 1
# 		while j<= n**0.5:
# 			if n%j == 0:
# 				if j!=1:
# 					n+=j
# 					flag = False
# 					break
# 				j+=1
# 			else:
# 				flag = True
# 				j+=1

# 		if flag:
# 			n+=n

# 		i+=1

# 	return n

def OracAndfactors(n,k): # O(N)
	i =2
	while n%i!=0:
		i+=1
	return n+i+(k-1)*2

n,k = list(map(int,input().split()))
print(OracAndfactors(n,k))


def OracAndfactors(n,k): # O(NrootN)

	i = 0
	flag = True
	while i<k:
		j = 1
		while j<= n**0.5:
			if n%j == 0:
				if j!=1:
					n+=j
					flag = False
					break
				j+=1
			else:
				flag = True
				j+=1

		if flag:
			n+=n

		i+=1

	return n

def OracAndfactors(n,k): # O(N)
	i =2
	while n%i!=0:
		i+=1
	return n+i+(k-1)*2

n,k = list(map(int,input().split()))
print(OracAndfactors(n,k))


t=int(input())
while t!=0:
    n,k=map(int,input().split())
    if n%2==0:
        n+=2*(k)
    else:
        for i in range(n,1,-1):
            if n%i==0:
                d=i
        print(i)
        n+=d+2*(k-1)
    print(n)


t=int(input())
while t!=0:
    n,k=map(int,input().split())
    arr=[2,3,5,7]
    5,2
    while k!=0:
        for ele in arr:
            if n%ele==0:
                n=n+ele
                break
        k=k-1
    print(n)
    t=t-1


t=int(input())
while t!=0:
    n,k=map(int,input().split())
    if n%2==0:
        n+=2*(k)
    else:
        for i in range(n,1,-1):
            if n%i==0:
                d=i
        n+=d+2*(k-1)
    print(n)
    t=t-1


tests = int(input())
lines = [list(map(int, input().split())) for i in range (tests)]

def smallestDivisor(n):
    for i in range (2, n+1):
        if n%i == 0:
            return i

for line in lines:
    n = line[0]
    for i in range (line[1]):
        n += smallestDivisor(n)
    print(n)