---
{"category_name":"easy","problem_code":"POSSPEW","problem_name":"Positive Spewing","problemComponents":{"constraints":"- $1 \\leq T \\leq 10^4$\n- $3 \\leq N \\leq 10^5$\n- $0 \\leq A_i \\leq 10^6$\n- $0 \\leq K \\leq 10^9$\n- Sum of $N$ over all test cases does not exceed $10^6$.\n\n\n","constraintsState":true,"subtasks":"","subtasksState":false,"inputFormat":"- The first line will contain $T$, number of testcases. Then $T$ testcases follow.\n- The first line of each testcase contains 2 space separated integers $N$ and $K$.\n- The second line of each testcase line contains $N$ integers $A_1, A_2, \\dots, A_N$. \n","inputFormatState":true,"outputFormat":"For each testcase, output in a single line containing the sum of the all the elements present in the array $A$ after $K$ seconds.\n","outputFormatState":true,"sampleTestCases":{"0":{"id":1,"input":"4\n6 1\n0 1 0 1 0 0\n3 0\n0 1 2\n8 2\n0 0 0 2 0 0 0 5\n3 10\n1 2 3","output":"6\n3\n23\n66","explanation":"**Test Case 1**: After one second, the array will become $A = [1, 1, 2, 1, 1, 0]$. So the sum of elements present in the array is = $1 + 1 + 2 + 1 + 1 + 0 = 6$.\n\n**Test Case 2**: No change will be executed in the array as $K = 0$. So the required sum will be equal to 3.\n\n","isDeleted":false}}},"video_editorial_url":"","languages_supported":{"0":"CPP14","1":"C","2":"JAVA","3":"PYTH 3.6","4":"CPP17","5":"PYTH","6":"PYP3","7":"CS2","8":"ADA","9":"PYPY","10":"TEXT","11":"PAS fpc","12":"NODEJS","13":"RUBY","14":"PHP","15":"GO","16":"HASK","17":"TCL","18":"PERL","19":"SCALA","20":"LUA","21":"kotlin","22":"BASH","23":"JS","24":"LISP sbcl","25":"rust","26":"PAS gpc","27":"BF","28":"CLOJ","29":"R","30":"D","31":"CAML","32":"FORT","33":"ASM","34":"swift","35":"FS","36":"WSPC","37":"LISP clisp","38":"SQL","39":"SCM guile","40":"PERL6","41":"ERL","42":"CLPS","43":"ICK","44":"NICE","45":"PRLG","46":"ICON","47":"COB","48":"SCM chicken","49":"PIKE","50":"SCM qobi","51":"ST","52":"SQLQ","53":"NEM"},"max_timelimit":1,"source_sizelimit":50000,"problem_author":"soumyadeep_21","problem_tester":"","date_added":"28-07-2021","tags":{"0":"easy","1":"soumyadeep_21","2":"start11"},"problem_difficulty_level":"Unavailable","best_tag":"","editorial_url":"https://discuss.codechef.com/problems/POSSPEW","time":{"view_start_date":1631727002,"submit_start_date":1631727002,"visible_start_date":1631727002,"end_date":1735669800},"is_direct_submittable":false,"problemDiscussURL":"https://discuss.codechef.com/search?q=POSSPEW","is_proctored":false,"visitedContests":{},"layout":"problem"}
---
A **circular array** of length $N$ is defined as follows: $N$ integers $A_1,A_2,…,A_N$ are placed in a circle in such a way that for each $1 \leq i \lt N$, $A_i$ and $A_{i+1}$ are adjacent, and $A_1$ and $A_N$ are also adjacent.
You are given a circular array $A$ of length $N$. At the end of each second, the following changes are executed in the array: If $A_i \gt 0$ then the elements which are adjacent to $A_i$, will get incremented by $1$, for all $1 \leq i \leq N$.
For example, consider the array $A = [0, 0, 0, 2, 0, 0, 0, 5]$.
- Initially $A_4$ and $A_8$ are greater than zero. So after one second, $A_3$, $A_5$, $A_1$ and $A_7$ will get incremented by $1$. Hence the array will become $A = [1, 0, 1, 2, 1, 0, 1, 5]$.
- After two seconds, the array becomes $A = [2, 2, 2, 4, 2, 2, 2, 7]$. Note that the value of $A_4$ has become $4$, because both, $A_3$ and $A_5$ were greater than zero after one second.
What will be the sum of elements present in the array $A$ after $K$ seconds?
<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.</div></aside>