[Question]
  [
I've been posting relatively hard challenges recently, so here goes an easy one.
## Task
Given an array \$A\$ and a number \$n\$, calculate the sum of all numbers of \$A\$ multiplied by \$n\$, except the last one. All numbers (the elements of \$A\$ and the value of \$n\$) are positive integers, and \$A\$ is non-empty. Shortest code in bytes wins.
I have a 3-byte J solution. Can you find it (or beat it in a different language)?
## Test cases
```
A           N   Ans   Explanation
3 1 4 1 5   10  95    (3+1+4+1)*10+5
3 1 4 1 5   1   14    (3+1+4+1)*1+5
1           999 1     1
```
  
[Answer]
# [J](http://jsoftware.com/), 3 bytes
That was fun to find.
```
&+/
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/1bT1/2v@VzA0UEhTMFYwVDABYlMuBSCJzLe0tATyDQE "J ‚Äì Try It Online")
### How it works
`10 (&+/) 3 1 4 1 5` will bind `10` as an argument of `+` as `10&+`, one verb that gets inserted between the elements of the list by `/`. So we have: `3 (10&+) 1 (10&+) 4 (10&+) 1 (10&+) 5`. Now `x n&v y` means that `y` gets applied to `n&v` for `x` times. With J's right to left evaluation we get: to 5 add 1 times 10, add 4 times 10, add 1 times 10, add 3 times 10. A challenge made for J's stranger parts. :-) And because `+` is commutative, `+&/` would also be a valid solution.
[Answer]
# JavaScript (ES6), ~~¬†28¬†~~ 23 bytes
*Saved 3 bytes thanks to @Mukundan314*
Expects `(A)(n)`.
```
A=>n=>eval(A.join`*n+`)
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@9/R1i7P1i61LDFHw1EvKz8zL0ErTztB839yfl5xfk6qXk5@ukaaRrSxjqGOCRCbxmpqGBpoanLhk8eUNgQKW1paamr@BwA "JavaScript (Node.js) ‚Äì Try It Online")
### How?
We simply join the input array with `"*n+"`, so that `[1,2,3]` is turned into `"1*n+2*n+3"` and evaluate the resulting string.
[Answer]
# [Haskell](https://www.haskell.org/), 17 bytes
```
foldr1.((+).).(*)
```
[Try it online!](https://tio.run/##y0gszk7NyfmfZhvzPy0/J6XIUE9DQ1tTT1NPQ0vzv4aqpm1aTmaBQhpXbmJmnoKtQkFRZl6JgopCdLSxjoKhjoIJmDSNVVBVMDTQUcAiChQ0BDEsLS1j//9LTstJTC/@r5tcUAAA "Haskell ‚Äì Try It Online")
It turns out this this was close to a port of the [intended J solution](https://codegolf.stackexchange.com/a/206979/20260). The pointfree function `((+).).(*)` takes the argument `n` to the map `\a b->a*n+b`, that is, to add `n` times the left value to the right value. This creates the same "verb" as J used, and the `foldr1` does the same a J's automatic right to left evaluation. It starts with the rightmost value in the list, which never gets multiplied by `n`, and applies it right-to-left, effectively increasing the sum so far with `n` times to the new element.
[Answer]
# [Python 3](https://docs.python.org/3/), 27 bytes
```
lambda a,n:a.pop()+sum(a)*n
```
Port of my Japt solution to python
[Try it online!](https://tio.run/##TY2xDoMwDET3fIW3xm2EGgFDkPiStoMrimoJTETSga9Pk8JQSx7u7vnst/hepE4j9HBPE83PgYCMdFT5xWu8hM@sCc@SePbLGiFsQalxWWFieQFLMaoQB5ZOQR4yIAZIQi4sSBX8xFGj2tPs3liiJkYoLcSlgw7qZE74@IGSwcLJcejXokZd6hH6PcxfEFNtrGnytmCv4Fr1p8E2yoJzDuwX "Python 3 ‚Äì Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 19 bytes
```
#2Tr@Most@#+Last@#&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n277X9kopMjBN7@4xEFZ2ycRRKn9DyjKzCtRcEiPrjbWMdQxAWLTWh1Dg1gu7BLI4oa1OpaWlrH//wMA "Wolfram Language (Mathematica) ‚Äì Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 27 bytes
```
lambda a,n:a.pop()+sum(a)*n
```
[Try it online!](https://tio.run/##dY5NDoIwEIX3PcXs2tFqrEBMSfAiwKIqRBIpTVsWhnD2WurClbOYv@/l5Zm3f046C33VhJcabw8FiutSHc1kGO7dPDKFOx1857yDChiBWIzVGQfBIU@9aOM4IQdZIP8riFzkPy7iT0qJiRAkdnOfaTOfL/mdcviuIqNI@smC5x0MGlKOMnlscXq285guYwftWU8Xv8LhCotbYbF11FTQtSvF8AE "Python 3 ‚Äì Try It Online")
[Answer]
## [Clojure](https://clojuredocs.org/) 41 bytes
`#(+(last %1)(* %2(apply +(butlast %1))))`
Unfortunately, `+` does have to be `apply`ed.
[Try It Online](https://tio.run/##S87JzyotSv2vkZKappD2X1lDWyMnsbhEQdVQU0NLQdVII7GgIKdSQVsjqbQEJgEE/zW5uDQKijLzSnLyFDTSFKKNFQwVTIDYNFbB0EBTE7ckupxhrIKlpSXQRAA)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 5 bytes
-2 bytes thanks to @KevinCruijssen.
```
*`¬≤√∑O
```
[Try it online!](https://tio.run/##yy9OTMpM/f9fK@HQpsPb/f//jzbWMdQxAWLTWC5DAwA "05AB1E ‚Äì Try It Online")
## Explanation
```
*     Multiply list by second operand
 `    Dump
   √∑  Divide the last item by
  ¬≤   the second operand
    O Sum the stack
```
# [05AB1E](https://github.com/Adriandmen/05AB1E), 7 bytes
```
‚Äû¬≤*√Ω.VO
```
[Try it online!](https://tio.run/##yy9OTMpM/f//UcO8Q5u0Du/VC/P//z/aWMdQxwSITWO5DA0A "05AB1E ‚Äì Try It Online")
## Explanation
```
‚Äû       2-char string
 ¬≤*     (Which does when evaluated) Multiply by the second input
   √Ω    Join the input list by this
    .V  Evaluate
      O Sum the resulting stack
```
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 9 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?") ([SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set"))
Anonymous tacit infix function. Takes \$A\$ as left argument and \$n\$ as right argument.
```
‚ä¢/+.√ó+√ó‚àò~
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn//1HXIn1tvcPTtQ9Pf9Qxo@5/2qO2CY96@x51NT/qXfOod8uh9caP2iY@6psaHOQMJEM8PIP/GysYKpgAsalCmoKhARcKl8sQSFpaWgIA "APL (Dyalog Extended) ‚Äì Try It Online")
`√ó‚àò~`‚ÄÉ\$A√ó(1-n)\$
`+.√ó+`‚ÄÉ\$\big(\sum\_{i=1}^N A\_i√ón\big)+\$
`‚ä¢/`‚ÄÉrightmost element (lit. right-argument reduction)
So this effectively implements: $$
\Bigg(\bigg(\sum\_{i=1}^N A\_i√ón\bigg)+A√ó(1-n)\Bigg)\_N\\
\bigg(\sum\_{i=1}^N A\_i√ón\bigg)+A\_N√ó(1-n)\\
\bigg(\sum\_{i=1}^N A\_i√ón\bigg)+A\_N-n√óA\_N\\
\bigg(\sum\_{i=1}^{N-1} A\_i√ón\bigg)+A\_N
$$
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 5 [bytes](https://github.com/abrudz/SBCS)
```
+‚ç£‚éï/‚éï
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKM97b/2o97Fj/qm6gMxSOA/ZxqXsYKhggkQm3IZGnCh8kFcQy5LS0sA "APL (Dyalog Unicode) ‚Äì Try It Online")
A full program, which pretty much works like the [3-byte J solution](https://codegolf.stackexchange.com/a/206979/78410). Takes two lines of input, \$A\$ first and \$n\$ second.
### How it works
```
+‚ç£‚éï/‚éï
    ‚éï  ‚çù Take the input A
   /   ‚çù Reduce by...
+      ‚çù   Add the left argument
 ‚ç£‚éï    ‚çù   n times
For n=10 and A = 3 1 4 1 5, this becomes:
+‚ç£10/3 1 4 1 5
3 (+‚ç£10) 1 (+‚ç£10) 4 (+‚ç£10) 1 (+‚ç£10) 5
3 added 10 times to
         1 added 10 times to
                  4 added 10 times to
                           1 added 10 times to
                                    5
```
---
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 8 bytes
```
1¬®‚çõ,‚ä•0,‚ä£
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/3/DQike9s3UedS01ABKL/6c9apvwqLfvUVfzo941j3q3HFpv/Kht4qO@qcFBzkAyxMMz@L@xgqGCCRCbKqQpGBpwoXC5DIGkpaUlAA "APL (Dyalog Extended) ‚Äì Try It Online")
A longer but more interesting one. A tacit dyadic function that takes \$A\$ on its left and \$n\$ on the right.
Uses mixed base conversion `‚ä•`, which does the following:
```
Base:        1  1  1  ... 1    n
Digit value: n  n  n  ... n    1
Array value: 0  a1 a2 ... ax-1 ax
Total: a1n + a2n + ... + ax-1n + ax
```
### How the code works
```
1¬®‚çõ,‚ä•0,‚ä£  ‚çù Input: left=A, right=n
1¬®        ‚çù An array of ones as long as A
  ‚çõ,      ‚çù Append n, which becomes the base
     0,‚ä£  ‚çù A prepended with single zero, which becomes the values
    ‚ä•     ‚çù Mixed base conversion as described above
```
[Answer]
# [R](https://www.r-project.org/), ~~37~~ ~~36~~ 35 bytes
-2 bytes with help from Giuseppe
```
function(l,n)rev(l)%*%n^(seq(!l)>1)
```
[Try it online!](https://tio.run/##K/qfpmCjq/A/rTQvuSQzP08jRydPsyi1TCNHU1VLNS9Oozi1UEMxR9POUPN/mkayhrGOoY4JEJtq6igYGmhyYYiBhAx1FCwtLUEsIzjLAML6DwA "R ‚Äì Try It Online")
Reverse the vector, and perform dot product with the vector \$(n^0, n^1, n^1, \ldots,n^1) = (1, n, n,\ldots, n)\$.
I just discovered this behaviour of `seq`, which gains 1 byte on item 4 of [this tip](https://codegolf.stackexchange.com/a/138046/86301): `seq(!l)` is equivalent to `seq(along.with = l)` (giving the vector `1 2 3 ... length(l)`) in all situations, even if `l` is of length 1. That is because `!l` is a logical, not an integer, and so we avoid the call to `seq.int` when `l` is a (length 1) integer.
[Answer]
# [Pyramid Scheme](https://github.com/ConorOBrien-Foxx/Pyramid-Scheme), 407 bytes
```
     ^      ^
    /l\    /+\
   /oop\  ^---^
  ^-----^ -  /x\
 / \   / \   ---
/arg\ /set\
-----^-----^
    /2\   /+\
    ---  ^---^
        ^-  /1\
       ^-   ---
      ^-
     /]\
    ^---^
   / \ /2\
  /set\---
 ^-----^
/x\   ^- 
---  /]\
    ^---^ 
   ^-  /#\
  / \  ---^
 /set\   / \
^-----^ /arg\
-    /+\-----^
    ^---^   /2\
   /*\  -   ---
  ^---^
 ^-  /#\
/x\ ^---
---/ \
  /arg\
 ^-----
/1\
---
```
[Try it online!](https://tio.run/##VZDLDoJADEX3/Yom7jSTER9/M5IQJWoigYAL/fra284AktAHbU9vGb5j0z1vYbo@2q4VYTw1uyPY@Ermdglp7PtB8zqEgDK8Rhy08tGGyGh2qwWKzXhPHKf2nchb3Tr5kBYw2hduFgBslWiVGrWkHsSLd8yzWK9sDW2xTZS9qtJJZPv@ZpnKzo0N4wpnGsfJVE620yjkf7M6y1mcJXDcAjMrzyrLGujBJ8gBnTM3Cyacr15Eqr0cpZKTvucf "Pyramid Scheme ‚Äì Try It Online")
Takes input through command arguments, with `n` as the first argument. This basically implements the algorithm:
```
i = 2
x = 0
o = 0
while args[i]:
  o += x*args[1]
  x = args[i]
  i += 1
print(o + x)
```
But with more nesting and some shortcuts, like using the variable `2`.
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), ~~14~~ 13 bytes
**Solution:**
```
{*|x+/y*-1_x}
```
[Try it online!](https://tio.run/##y9bNz/6fZlWtVVOhrV@ppWsYX1H7P01PXUPDWMFQwQSITa0NDTStkblAno6htaWlpabm//8A "K (oK) ‚Äì Try It Online")
**Explanation:**
Couldn't figure out a smart way of solving this.
```
{*|x+/y*-1_x} / the solution
{           } / lambda taking implicity x, y
        -1_x  / drop (_) 1 element from end of x
      y*      / multiply by y
   x+/        / sum up with x as accumulator
 *|           / take last (reverse, first)
```
**Notes:**
* **-1 byte** thanks to coltim - thanks!
[Answer]
# [Perl 5](https://www.perl.org/) + `-pa -MList::Util+sum`, 19 bytes
```
$_=pop(@F)+<>*sum@F
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3rYgv0DDwU1T28ZOq7g018Ht/39jBUMFEyA25TI04ELiAKGlpeW//IKSzPy84v@6BYk5/3V9fTKLS6ysQksyc7SB@gE "Perl 5 ‚Äì Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 7 bytes
```
o +V*Ux
```
[Try it online!](https://tio.run/##y0osKPn/P19BO0wrtOL//2hjHQVDHQUTMGkay2VoAAA "Japt ‚Äì Try It Online")
## Explanation
```
o +V*Ux
o         // Pop and return last element of first input
  +       // plus
   V*     // second input times
     Ux   // Sum of first input
```
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 31 bytes
```
\d+
$*
1(?=.*,1*;(1*)|1*$)
$1
1
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wPyZFm0tFi8tQw95WT0vHUMtaw1BLs8ZQS0WTS8WQy/D/f2MdQx0TIDa1NjTgQuJwGVpbWloCAA "Retina 0.8.2 ‚Äì Try It Online") Link includes test cases. Explanation:
```
\d+
$*
```
Convert to unary.
```
1(?=.*,1*;(1*)|1*$)
$1
```
Multiply all but the last element of `A` by `n` and delete `A`.
```
1
```
Take the sum and convert to decimal.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 7 bytes
```
+*sPQEe
```
[Try it online!](https://tio.run/##K6gsyfj/X1urOCDQNfX//2hjHQVDHQUTMGkay2Vo8C@/oCQzP6/4v24KAA "Pyth ‚Äì Try It Online")
## Explanation
```
+*sPQEe
    Q    # First input
   P     # Remove the last element
  s      # Sum elements
 *   E   # Multiply by the second input
+     e  # Add the last element of the first input
```
[Answer]
# x86-16 machine code, 18 bytes
```
33 DB       XOR  BX, BX         ; clear running sum
49          DEC  CX             ; decrement array length
74 09       JZ   ADD_LAST       ; handle array length of 1 case
        LOOP_SUM:
AD          LODSW               ; load next value into AX
03 D8       ADD  BX, AX         ; BX = BX + AX
E2 FB       LOOP LOOP_SUM       ; keep looping
93          XCHG AX, BX         ; move sum into AX
F7 E2       MUL  DX             ; DX:AX = AX * DX
93          XCHG AX, BX         ; move result back to BX
        ADD_LAST:
AD          LODSW               ; load last value into AX
03 C3       ADD  AX, BX         ; AX = AX + BX
C3          RET                 ; return to caller
```
As a callable function: `[SI]` to input array, `CX` array length, `DX` = `N`. Output to `AX`.
Rather than make an elaborate test program, here's it being run using DOS DEBUG, entering the input array into memory and setting registers as they would be called:
[![enter image description here](https://i.stack.imgur.com/JP7iR.png)](https://i.stack.imgur.com/JP7iR.png)
Explanation of above:
Enter input array into memory address `DS:200` as 16-bit, little-endian words:
```
-e 200 3 0 1 0 4 0 1 0 5 0
```
Point `SI` to this input array:
```
-r SI
:200
```
Set `CX` to array's length:
```
-r CX
:5
```
Set `N` to `10` (`0xA` in hex):
```
-r DX
:A
```
Execute and stop before last instruction (`RET` will "return to DOS" and clobber registers):
```
-g 111
```
Result is `AX=005F` or `95` in decimal.
[Answer]
# [Golfscript](http://www.golfscript.com/), 13 bytes
```
~:i;-1%{i*+}*
```
[Try it online!](https://tio.run/##S8/PSStOLsosKPn/v84q01rXULU6U0u7Vuv//2hjBUMFEyA2jVUwNAAA "GolfScript ‚Äì Try It Online")
**Explanation:**
`~` to convert string input to array and integer on stack. `:i;` assigns \$n\$ to `i` and pops value. `-1%` reverses the array and `{i*+}*` folds the array with `(a, b) -> a*n + b`
[Answer]
# [Emacs Lisp](https://www.gnu.org/software/emacs/manual/eintr.html) with [dash](https://github.com/magnars/dash.el/tree/732d92eac56023a4fb4a5dc3d9d4e274ebf44bf9#-sum-list) library: ~~38~~ 51 bytes
```
(lambda(n A)(+(car(last A))(* n(-sum(butlast A)))))
```
(38 bytes was the function body' size only.)
[Answer]
# [Pyramid Scheme](https://github.com/ConorOBrien-Foxx/Pyramid-Scheme), ~~7747~~ ~~3668~~ ~~1985~~ ~~1732~~ 1619 bytes
## Edits
* -4079 bytes by giving the variables shorter names... üòÖ
* -1638 bytes by doing some more manual optimisation
* -253 bytes by using more 0-height trees
* -113 bytes because out can output the final result directly
```
    ^  ^        ^       ^        ^  ^        ^        ^        ^
   / \ -^      / \     / \      / \ -^      / \      / \      / \
  /set\ -^    / do\   /set\    /   \ -^    /set\    /   \    /out\
 ^-----^ -^  ^-----^ ^-----^  / set \ -^  ^-----^  /     \   -----^
/l\   / \ -^/c\   ^-/n\   ^- ^-------^ -^/i\   ^- / loop  \      /+\
---  /arg\^----  ^- ---  ^- /N\     /#\^----  ^- ^---------^    ^---^
    ^------^    / \     /-\ ---    ^----^    ^- / \       / \  /s\ /#\
   / \    ^-   ^---^   ^---^      / \  ^-   ^- /<=>\     ^---^ --- ---^
  /99 \  ^-   / \ / \ /n\ /1\    /arg\^-   ^- ^-----^   / \ / \      / \
  ----- ^-   ^---/   \--- ---   ^------^  ^- /i\   /0\ ^---/set\    /arg\
       ^-   / \  -----^        /n\    ^- /-\ ---   ---/ \ ^-----^   -----^
      ^-   ^---      / \       ---   ^- ^---^        ^---/s\   / \      /-\
     ^-   / \       /set\           ^- /n\ /1\      / \  ---  / + \    ^---^
    ^-   /set\     ^-----^         / \ --- ---     ^---      ^-----^  /n\ /1\
   ^-   ^-----^   /c\   /!\       /set\           / \       /s\   /*\ --- ---
   -^  /n\   /+\  ---  ^---      ^-----^         /set\      ---  ^---^
   / \ ---  ^---^     /=\       /s\   /0\       ^-----^         /#\ /N\
  /set\    /n\ /1\   ^---^      ---   ---      /i\   /-\       ^--- ---
 ^-----^   --- ---  / \ /l\                    ---  ^---^     / \
/n\   /0\          /arg\---                        /i\ /1\   /arg\
---   ---         ^-----                           --- ---  ^-----
                 /n\                                       /i\
                 ---                                       ---
```
[Try it online!](https://tio.run/##jVTbagIxEH3PV6T4Vgmz0vahUPsJ/YIQEJVW8IZrH/r1aTK3zO4qGGozzJycOXPR899lddhtQr/@2R62OftyEv7RSaP7ZtAYrvwDH31gV7XtfTM4MAoD9NuroMBvTjVIPnR4pRg5q3H6vRaKFOpJCBNb7gIuz5jDOD1zkMfBPqpcWFc7BTjSzc8oA@zYCX5/Op291jKPrkCKsbp8R3yBMLnhi1szM0EhDlRgQiliiVebGiKxcZiftHaSBX2sSVx7mYJwm1vCHPTwsfwkHkLUTCwH3t8VWd/gp/QGFjQEKti2KhmkmTTGmhwcI@cZ1FzlYJuhi4TUyddcTtZPBPnWLAQdpezWMkwXjTyeu2FK3FyzoKrMto3F93GwyoFlNVF@sLNNs2ldk1@tuYyrbcGAIQ3LpG3V9tkC2p5TLmdr5PHgksPTPaG2BEQ@a7LKJuS4@F62fJJ/Sq7I9uOhHsIuR4m76O@wzmL9Wjn7y6C9NQPTDeBntFrB0lJZg@2QqRTCvW2MnrHusuLckc7gcWM19/RUNaSYdnskVsv294@KJaSb5jhG/9gpatztQh86BZlzfsmL/Fo@b3nR/QM "Pyramid Scheme ‚Äì Try It Online")
## Explanation
```
(set nil (arg 99)) // Make nil
// Count the number of input arguments - n
(set nargin 0)
(do
    cond
    (
        (set nargin (+ nargin 1))
        (set cond (! (= (arg nargin) nil)))
    )
)
(set nargin (- nargin 1))
(set N (# (arg nargin))) // N - the number all but last of the array elements is getting multiplied by
// Add all but last elements of A
(set sum 0)
(set i (- nargin 1))
(loop
    (<=> i 0)
    (
        (set i (- i 1))
        (set sum (+ sum (* (# (arg i)) N))) // A[i] multiplied by N
    )
)
(set sum (+ sum (# (arg (- nargin 1))))) // Add the last element of A
(out sum) // Print
```
[Answer]
# [Ruby](https://www.ruby-lang.org/en/), 46 19 bytes
```
->a,n{eval a*"*n+"}
```
Courtesy of [petStorm](https://codegolf.stackexchange.com/users/96495/petstorm).
**Old answer:**
```
n,*A,l=gets.split(' ').map(&:to_i)
p A.sum*n+l
```
[Answer]
## [MAWP](https://esolangs.org/wiki/MAWP), 26 bytes
```
%@_2A<\:.>2M3A[1A~M~]%\WM:
```
Now it works properly on the testcases. Works on MAWP 1.1's integer input.
[Try it!](https://8dion8.github.io/MAWP/v1.1?code=%25%40_2A%3C%5C%3A.%3E2M3A%5B1A%7EM%7E%5D%25%5CWM%3A&input=1%202%203%204)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes
```
·π™·π≠√óS
```
[Try it online!](https://tio.run/##y0rNyan8///hzlUPd649PD34/@Hl@o@a1kT@/x8dbaxjqGMCxKaxOoYGsTqoAiA@kLC0tIwFAA "Jelly ‚Äì Try It Online")
```
·π™       Pop the last element of the left argument,
 ·π≠      append it to
  √ó     the right argument times what's left of the left argument,
   S    and sum.
```
A more fun solution, which borrows Jonathan Allan's base conversion trick:
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
S,¬•/·∏Ö
```
[Try it online!](https://tio.run/##y0rNyan8/z9Y59BS/Yc7Wv8fXq7/qGlN5P//0dHGOoY6JkBsGqtjaBCrgyoA4gMJS0vLWAA "Jelly ‚Äì Try It Online")
```
   /     Reduce the left argument by
 ,       pair right with
S ¬•      the sum of left,
    ·∏Ö    and convert from base right.
```
Bonus: `√Ñ-.·ªã·∏Ö‚Äô}` is a whole 7 bytes, and doesn't even work if the left argument only has one element, but it's just kind of funny.
[Answer]
# [PHP](https://php.net/), 41 bytes
```
fn($a,$n)=>array_pop($a)+array_sum($a)*$n
```
[Try it online!](https://tio.run/##bYw/C8IwEMX3@xRvuKHRUCzqUGJ1EhwEu5dSQmnI0jY0dRDxs8f4Z3CQ4x3v9457zrqwOzjriNgUwQwJa8mDKPZ6mvStcaOLiVh@yF/7Fy14CIp47vzsUaAioIqzlpncRG1riWyFuP8dfvK3z/McNYhqKCIzTp1uLRJ827WPDgL3@NK1dgSbJE1TnoVEeSqb4@Ws6IHwBA "PHP ‚Äì Try It Online")
Just trying to use all the built-ins!
[Answer]
# [Raku](https://github.com/nxadm/rakudo-pkg), 20 bytes
```
{@^a.pop+$^b*@a.sum}
```
By using twigils, `@^a` matches the first arg (the array), and `$^b` the second (the multiplier).
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvwv9ohLlGvIL9AWyUuScshUa@4NLf2vzUXF1CBgyNQgWNRUWKlXl5quYaxjqGOCRCbauoQFDXUtAab4AQ0wdBAR8FQR8HSEmhqcWKlQppGjUq8pkJafhHIhiigIuv/AA "Perl 6 ‚Äì Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
·π™·π≠S∆ä·∏Ö
```
A dyadic Link accepting a list of numbers on the left and a number on the right which yields a number.
**[Try it online!](https://tio.run/##y0rNyan8///hzlUPd64NPtb1cEfr////o411FAx1FEzApGnsf0MDAA "Jelly ‚Äì Try It Online")**
```
·π™·π≠S∆ä·∏Ö - Link: list of numbers, A; number n
   ∆ä  - last three links as a monad - f(A):
·π™     -   remove the tail (of A) and yield its value
  S   -   sum (the remaining elements in A)
 ·π≠    -   tack -> [sum_of_remaining, tail]
    ·∏Ö  - convert from base (n) -> n√ósum_of_remaining+1√ótail
```
[Answer]
# [Q'Nial](https://github.com/danlm/QNial7), 33 bytes (20 bytes without operator definition)
```
s is op n a{+link[n*front,last]a}   %full operator definition
+link[n*front,last]a                %simple function
```
Explanation:
```
+                                   sum, reduce by +
 link                               list of the items of the argument
     [                              atlas (argument of link operation), point-free notation
      n*                            n *
        front                       all elements but the last of the argument
             ,
              last                  last element of the argument
                  ]                 end atlas
                   a                array a (argument of atlas)
```
Intermediate results, for `n=10` and `a=3 1 4 1 5`
```
         10 s 3 1 4 1 5
or
         s 10 (3 1 4 1 5)
or
         +link[10*front,last]3 1 4 1 5
         [n*front,last] a
+-------------+-+
|+--+--+--+--+|5|
||30|10|40|10|| |
|+--+--+--+--+| |
+-------------+-+
         link[n*front,last] a
+--+--+--+--+-+
|30|10|40|10|5|
+--+--+--+--+-+
         +link[n*front,last]a
95
```
[Answer]
# [Befunge-98 (PyFunge)](https://pythonhosted.org/PyFunge/), ~~29~~ 27 bytes
```
j&10p#v&\10g*\4
_\.@  >+\:#
```
[Try it online!](https://tio.run/##S0pNK81LT9W1tNAtqAQz///PUjM0KFAuU4sxNEjXijHhio/Rc1BQsNOOsVL@/9/QQMFYwVDBBIhNFQA "Befunge-98 (PyFunge) ‚Äì Try It Online") Input is first `N`, then `A`. Note that there has to be a trailing space.
Animation of the code:
[![enter image description here](https://i.stack.imgur.com/nAF2G.gif)](https://i.stack.imgur.com/nAF2G.gif)
The pilcrow (¬∂) represents a newline (value 10) in the grid.
[Answer]
# [Julia 1.0](http://julialang.org/), ~~21~~ 19 bytes
```
A$n=pop!(A)+sum(A)n
```
[Try it online!](https://tio.run/##dY5BCsIwEEX3OcW3dJFgFgbroosKPUctIm0KKTUNbQr1HuLK03mRGlMLIvphZmB48@fXQ6NOYpymNNSJac2KpmzdD2c39GRlb3skyAicaLblEByR77vcjQ1Dske8438ACA@IaAEEPpTzOI5ngOSEVG0HSlOuGa8ZlIZ/7w@ro3IxitZcXK5Q@52q5nWCmiyOplPaNpoGj/sVAYd3ez1wJPOUbHr5C7994xzBwVI5GllYWSKsWfB20CVxNT0B "Julia 1.0 ‚Äì Try It Online")
]