[Question]
  [
I have just tried a game called [Couch 2048](https://js13kgames.com/games/couch-2048/index.html).  
(Note: You should have a look to better understand this question.)  
Since it wasn't very exciting for me, I've been asking myself *'How much more till 2048!?'*  
That inspired me to post a challenge, because calculating this in not as easy as I thought.
**Your goal:**  
Given a list of balls on the sofa, you have to output how many balls with a value of 2 have to fall from the sky so that one can win the game (by reaching the 2048 ball).
* Assume the input is valid.
* Assume the player won't drop any balls.
* Assume the balls which fall from the sky always have a value of 2, as I've said.
* Valid output examples: 3, "4", [5], ["6"]
**Edit:**  
I should clarify something:  
 - You have to print the *smallest* amount of 2s needed.
**Test cases:**  
`[2048] -> 0` You've already won  
`[1024,1024] -> 0` You don't need any more balls to win  
`[1024,512,256,128,64,32,16,8,4,2] -> 1` One ball required to *'activate the chain'*  
`[512] -> 768`  
`[512,2] -> 767`  
`[4,16,64] -> 982` 
**Notes**:  
I'm not a native speaker - Tell me if you spotted a typo or some non-grammatical text.  
If something's unclear, ask in comments.
  
[Answer]
# Java 8, 17 bytes
```
s->1024-s.sum()/2
```
Port of [*@LuisFelipeDeJesusMunoz*' JavaScript answer](https://codegolf.stackexchange.com/a/175769/52210).
[Try it online.](https://tio.run/##fZDBTsMwDIbvewofE8k1a8iqShO778AuOyIOoctQSptOizsJoT17SUKFgElcrNj@8v@2W3MxRXt4m5rOhACPxvmPBYDzbM9H01jYpRRyBRrRRpxGdh0FPlvT09bzPr/AyXUkr4sYAht2DezAw8MUik25VLoIFMZeyDs1rRNzGl@6yMzoZXAH6KO5iGrOvz49g5FfzmwDC7XUddaf86SIKdwUV6VCtaqwVDVWGu8VlhXWqFH9RCP1J/3d1@lXpW9WynNmIt6DiL6n3L8Htj0NI9MpLsCdF57@uxcNR2GknB2u0yc)
**Explanation:**
```
s->           // Method with IntStream parameter and int return-type
  1024-       //  Return 1024, minus:
   s.sum()    //   The sum of the input-IntStream
          /2  //   Divided by 2
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 72 bytes
```
({{}})({<({}[()()])>()}{})([{}]((((((((()()()()){}){}){}){}){}){}){}){})
```
[Try it online!](https://tio.run/##SypKzMzTTctJzP7/X6O6urZWU6PaRqO6NlpDU0MzVtNOQ7O2GigWXV0bqwEDmhCoCZTAiv7/N1EwNFMwMwEA "Brain-Flak ‚Äì Try It Online")
```
({{}})                     # Sum entire stack
      (                  ) # Push:
       {<          >()}{}  #   The number of times you can...
         ({}[()()])        #   Subtract 2 before reaching 0
([{}]                                        ) # Subtract that from...
     ((((((((()()()()){}){}){}){}){}){}){}){}  # 1024
```
[Answer]
# [Python 2](https://docs.python.org/2/), 22 bytes
```
lambda x:4**5-sum(x)/2
```
Y'know, I *just* realized that `4**5` is the same length as `1024`.
[Try it online!](https://tio.run/##K6gsycjPM/qfaBvzPycxNyklUaHCykRLy1S3uDRXo0JT3@h/QVFmXolGoka0oYGRiY6poZGOkamZjqGRhY6ZiY6xkY6hmY6FjomOUaymJhdcrQlI2MwEKPYfAA)
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/create_explanation.py), ~~6~~ 5 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
Œ£c/‚óò+
```
First MathGolf answer. :)
[Try it online](https://tio.run/##y00syUjPz0n7///c4mT9R9NnaP//H21qaKRjFAsA) or [verify all test cases](https://tio.run/##y00syUjPz0n7X314TaGSwqO2SQpKhf/PLU7WfzR9hvb/gv/R0UYGJhaxOtGGBkYmOiACxjY1NNIxMjXTMTSy0DEz0TE20jE007HQMdExAqoASkJIMM8EJGVmEhsLAA).
**Explanation:**
```
Œ£         # Sum of the (implicit) input-list
 c/       # Divide it by -2
   ‚óò+     # Add 1024 to it (and output implicitly)
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 5 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
O;≈æBŒ±
```
Port of [*@LuisFelipeDeJesusMunoz*' JavaScript answer](https://codegolf.stackexchange.com/a/175769/52210).
[Try it online](https://tio.run/##yy9OTMpM/f/f3/roPqdzG///jzY1NNIxigUA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@koGunoGRf@d/f@ug@p3Mb/@v8j442MjCxiNVRiDY0MDLRARFwjqmhkY6RqZmOoZGFjpmJjrGRjqGZjoWOiY4RSAlQFkpB@CYgWTOT2FgA).
**Explanation:**
```
O        # Sum of the (implicit) input-list
 ;       # Halved
  ≈æB     # Push 1024
    Œ±    # Absolute difference between the two (and output implicitly)
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 10 bytes
```
2√∑‚ç®2048-+/
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///3@jw9ke9K4wMTCx0tfX/pz1qm/Cot8/wUVfzofXGj9omPuqbGhzkDCRDPDyD/6cpGGkZGnKBKQMFQwMw61HP3ke9m6EcSwipAFFkpGCiYAYA "APL (Dyalog Unicode) ‚Äì Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 25 bytes
Based on [@Shaggys' comment and answer](https://codegolf.stackexchange.com/a/175768/78039)
*-3 bytes from @Arnauld =D*
```
_=>1024-eval(_.join`+`)/2
```
[Try it online!](https://tio.run/##dY3BDoMgEETv/RKIq5XtSrjoj5hGicVGQ9imNv4@lqvByxxm3sysdrfb9F0@vzLwy8W5jUPbqRqpdLv1YqhWXsJYjPKOceKwsXeV57eYRY81maeUt5OdypDkKmsUAjYaFBrQBA8EpcEAAWYafzjvZmlKUzo9xwM "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# [J](http://jsoftware.com/), 10 bytes
```
2048-:@-+/
```
[Try it online!](https://tio.run/##VcpBCoMwFEXReVZxcSJFTZPvN4SA0L2UhuLEgWPXHrUg1cnj8jhTyctocSRcEaexS6@ueZaHqSx1Hm1Ny5rIizGf93cmc6izvRP9ze0YvCBDwEskKL3gAxFFTraLS/5/PWTQsgE "J ‚Äì Try It Online")
## Alternative:
# [J](http://jsoftware.com/), 10 bytes
```
1024-1#.-:
```
[Try it online!](https://tio.run/##VYvLCoMwFAX3@YrBLqSgIff2GkLArxFD6caFa789PkDabg7DMOdTyzp6AplQJaj18vB9rk/XeNoy@paOLVNW5@bpvVDQYOnm83HNnxhE0SEimojGS5FIwtA7O4of/Ho7y2h1Bw "J ‚Äì Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 17 bytes
```
->l{1024-l.sum/2}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y6n2tDAyEQ3R6@4NFffqPZ/gUJadDRISMfU0EjHyNRMx9DIQsfMRMfYSMfQTMdCx0THKDaWC6zMBCRiZhIb@x8A "Ruby ‚Äì Try It Online")
[Answer]
# [Catholicon](https://github.com/okx-code/Catholicon), 5 bytes
```
-`LÃá¬Ω·πñ
```
Explanation:
```
-      subtract
 `LÃá    1024
       from
   ¬Ω   half of the
    ·πñ  sum [of the input]
```
[Answer]
# TI-Basic, 8 bytes
```
4^5-.5sum(Ans
```
[Answer]
# JavaScript, 28 bytes
```
a=>a.map(n=>x-=n/2,x=1024)|x
```
[Try it online](https://tio.run/##PY3BCsIwEETv@ZIEtrVZt6GXzY@EHEJtRalJaUVy8N@jUfEyw@MNzDU8wj5ul/XexHSayswlsA3tLawyss0NxwNCZt0hqWcuY4p7WqZ2SWfphMOOBg/CVQ01/tBrBOwNaBzAEBwRtIEBCLBO3vZXX6ZqDXnhP8@Z7SyzUqq8AA)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~7~~ 6 bytes
```
HS·∫°‚ÅΩ¬°√ß
```
[Try it online!](https://tio.run/##y0rNyan8/98j@OGuhY8a9x5aeHj5////o010DM10zExiAQ "Jelly ‚Äì Try It Online")
**Explanation:**
```
HS·∫°‚ÅΩ¬°√ß    Example input: [4,16,64]
H         Halve input. [2, 8, 32]
 S        Sum. 42
   ‚ÅΩ¬°√ß    Number 1024.
  ·∫°       Difference. 982
```
 -1 byte by using a base-250 number
[Answer]
# Japt, ~~7~~ 6 bytes
```
xz nH¬≤
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.6&code=eHogbkiy&input=WzEwMjQsNTEyLDI1NiwxMjgsNjQsMzIsMTYsOCw0LDJd) or [verify all test cases](https://ethproductions.github.io/japt/?v=1.4.6&code=eHogbkiy&input=WwpbMjA0OF0sClsxMDI0LDEwMjRdLApbMTAyNCw1MTIsMjU2LDEyOCw2NCwzMiwxNiw4LDQsMl0sCls1MTJdLApbNTEyLDJdLApbNCwxNiw2NF0KXQotbVI=)
```
 z         :(Floor) divide each by 2
x          :Reduce by addition
   n       :Subtract from
    H      : 32
     ¬≤     : Squared
```
[Answer]
# perl -aE, 27 bytes
```
$"=$:;say eval"(2048-@F)/2"
```
This reads a line with numbers (whitespace separated) from `STDIN`, and writes the answer to `STDOUT`.
What it does is subtract all the numbers from the input from 2048, and it divides the remainder by 2. The `-a` switch puts the in the array `@F` (one number per element). If we interpolate an array into a string (which is what we are doing here), perl puts the value of `$"` between the elements. The little used variable `$:` is be default `\n-`; and since white space between tokens is ignored, the result is subtracting all the numbers from 2048. The `eval` does the calculation.
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), 5 bytes
```
‚àëk¬¶Œµ¬Ω
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%E2%88%91k%C2%A6%CE%B5%C2%BD&inputs=&header=&footer=)
```
‚àë     # Sum
 k¬¶   # 2048
   Œµ  # Abs. diff.
    ¬Ω # halved
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 33 bytes
```
a=>!a.map(n=>x-=n/2,x=1024)>x?0:x
```
[Try it online!](https://tio.run/##VY5BDsIgFET3vYU7SH4rfCkhJuBBCAtSW6Op0Fhj/u1R1E03M5mZt5hbfMV1eFyXZ5vyeSyTLdG6XezucWHJOmpt2iOQlQIVd3QSRypDTmuex27OF@Ybj0KZAI2vCFTZhG3TSwTsNUg0oBUcEKQGAwqwIp/1b7@s6qpVaML3D1k3MeKclzc "JavaScript (Node.js) ‚Äì Try It Online")
Why you don't do on `[1024,1024,1024]`?
[Answer]
# [R](https://www.r-project.org/), 17 bytes
```
4^5-sum(scan())/2
```
[Try it online!](https://tio.run/##K/r/3yTOVLe4NFejODkxT0NTU9/ovwmXoRmXmQnXfwA "R ‚Äì Try It Online")
[Answer]
# [TeaScript](https://teascript.readthedocs.io/en/latest/index.html), 11 bytes
```
4p5)-(xx)/2
```
[Try it online!](https://vihan.org/p/TeaScript/?code=x.r(R(x%5B0%5D%2C%27gi%27)%2C%27%27)&input=Test)#?code=%224p5)-(xx)%2F2%22&inputs=%5B%22%5B1024,512,256,128,64,32,16,8,4,2%5D%22%5D&opts=%7B%22ev%22:true,%22debug%22:false,%22nox%22:true%7D)
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 6 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
√´3i‚îÄ‚ô†√∑
```
[Run and debug it](https://staxlang.xyz/#p=893369c406f6&i=[2048]%0A[1024,1024]%0A[1024,512,256,128,64,32,16,8,4,2]%0A[512]%0A[512,2]%0A[4,16,64]&a=1&m=2)
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 12 bytes
```
1024-*.sum/2
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvw39DAyERXS6@4NFff6L81V3FipUKaRrSRgYlFrCacC1KkAyLQxUwNjXSMTM10DI0sdMxMdIyNdAzNdCx0THSMkFQCFaHyUGRNQFrMQCb/BwA "Perl 6 ‚Äì Try It Online")
Anonymous Whatever lambda that takes a list and returns a number.
[Answer]
# AWK, 26 bytes
```
{s+=$1}END{print 1024-s/2}
```
Input numbers are separated by newlines (i.e. one per line)
[Answer]
# Neim, 6 bytes
Pretty new to Neim but got it working
```
ùê¨·ö∫œÇ·ö´·õ¶ùï§
```
Explanation:
```
  ùê¨         : Sum input
   ·ö∫        : Divide by 2 (stack now [input summed and divided by 2])
    œÇ       : Variable set to 16 pushed to stack
     ·ö´      : Multiply by 2
      ·õ¶     : Square (stack now [input summed and divided by 2, 1024])
       ùï§    : Subtract then absolute
```
[Try it online!](https://tio.run/##ATwAw/9uZWlt///wnZCs4Zq6z4Lhmqvhm6bwnZWk//9bMTAyNCA1MTIgMjU2IDEyOCA2NCAzMiAxNiA4IDQgMl0)
[Answer]
**JAVA, 30 bytes** 
```
2048-IntStream.of(a).sum()/2;
```
[Answer]
# [RAD](https://bitbucket.org/zacharyjtaylor/rad), 10 bytes
```
1024-+/œâ√∑2
```
[Try it online!](https://tio.run/##K0pM@f/f0MDIRFdb/3zn4e1G////N9IyUjBRMAMA "RAD ‚Äì Try It Online")
[Answer]
# [Clojure](https://clojure.org/), 24 bytes
```
#(- 1024(/(apply + %)2))
```
[Try it online!](https://tio.run/##dY1BCoMwFET3nmJAhB@KmPx@Q@4iLqQ10BJskHbh6aPpso3bmfdmbuH1/KxzSjW1MJqFOppiDBsuaBQrleg@e3ic9aqiuD6Wd1hAHgNrceNvmL2vXG56w@DewrCDFVwZxsJBwH/8gZayAil5xObHtAM "Clojure ‚Äì Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 16 bytes
```
(1024-).(/2).sum
```
An anonymous function, takes a list and returns a float.
[Try it online!](https://tio.run/##y0gszk7Nyfn/P03BVkHD0MDIRFdTT0PfSFOvuDT3f25iZh5QvKAoM69EQUUhTSEapEJHwdTQSEfByNRMR8HQyEJHwQwoZAwUMQQKALlAnlHsfwA "Haskell ‚Äì Try It Online")
[Answer]
# F#, 24 bytes
```
fun f->1024-List.sum f/2
```
1024 minus the sum divided by 2.
]