[Question]
  [
Given an array of integers. Find out its longest sub-array (contiguous subsequence) whose sum is 0.
The sub-array for output *may* be an empty array.
## Input
Input an array of integers.
## Output
Output the longest zero sum sub-array. If there are multiple such arrays, output any one of them.
## Output Format
You may output in one of following acceptable format:
1. Output an array of integers;
2. Output the index of first (inclusive) and last (inclusive) element of sub-array;
	* Output (last = first - 1) for empty sub-array
3. Output the index of first (inclusive) and last (exclusive) element of sub-array;
4. Output the index of first (inclusive) element and length of sub-array;
You may choose 0-indexed or 1-indexed value for 2~4 options. But your choices should be consistent for both first and last element.
## Rules
* This is code golf, shortest codes win.
* As usual, [standard loopholes](https://codegolf.meta.stackexchange.com/q/1061/) are forbidden.
* Your program *may* fail due to integer overflow (as long as this not trivialize this challenge, [which is a standard loophole](https://codegolf.meta.stackexchange.com/a/8245/44718)).
* This is code golf. We don't care the performance of your algorithm / implementation.
## Testcases
```
Input -> Output
[] -> []
[0] -> [0]
[1] -> []
[-1,1] -> [-1,1]
[-1,1,2] -> [-1,1]
[-2,-1,1,2] -> [-2,-1,1,2]
[1,2,3,4,5] -> []
[1,0,2,0,3,0] -> [0]
[1,2,-2,3,-4,5] -> [1,2,-2,3,-4]
[1,2,3,4,5,-4,-3,-2,-1,0] -> [4,5,-4,-3,-2]
[0,1,0,0,0,1] -> [0,0,0]
[0,0,0,1,0,0,1] -> [0,0,0]
[0,0,0,1,0,0,-1] -> [0,0,0,1,0,0,-1]
[-86,14,-36,21,26,-2,-51,-11,38,28] -> [26,-2,-51,-11,38]
[0,70,65,-47,-98,-61,-14,85,-85,92] -> [0,70,65,-47,-98,-61,-14,85]
[4,-4,2,0,4,-2,-2,1,0,1,-4,0,-2,2,2,-4,0,-1,2,1,-4,-2,3,4,3,0,3,2,-4,2,3,3,1,2,3,-3,-4,3,-4,4,0,-3,-1,-5,-4,1,-3,4,-4,2,-1,-4,0,2,-5,-5,2,1,-4,0,-1,4,3,3,-5,-4,-5,3,-3,-1,-5,1,-2,3,0,3,-4,1,-5,-1,4,-5,2,1,-3,4,4,1,-1,-5,-5,-2,4,0,-3,4,1,-3,0,-3] -> [4,-4,2,0,4,-2,-2,1,0,1,-4,0,-2,2,2,-4,0,-1,2,1,-4,-2,3,4,3,0,3,2,-4,2,3,3,1,2,3,-3,-4,3,-4,4,0,-3,-1,-5,-4,1,-3,4,-4]
```
  
[Answer]
# [Python 3](https://docs.python.org/3/), 47 bytes
```
f=lambda x,*a:f(*a,x[1:],x[:-1])if sum(x)else x
```
[Try it online!](https://tio.run/##dY/BboMwEETvfMXeYkfjCkNCCBL9EcTBVUFBAmIVaOnX0zVQSiJVlq3dN@sZ2373t3sbTlOZ1qZ5ezc04miSUhwNxkwnOZ@J0rmsSuqGRoyyqLuCxunrVtUF6cSjqrWg@9BbSqkxVhSfpoajQy/kS2frqhcHUq90kNIj@1G1vSgF65LSdL4opyx3A1nuZf5S@VzqDSqNtZmrBSB4RAEe6NayEQKEOOG8GWr4zHym@zxGyk2qbXSH9j5uQoVYMlaHPXb/gFt6OdcM1zxJaq/9Mf5OHEE7uwgB50Zz2FmzqBHGCOLl3rMw2198RO4xF6hrDBU58YSYEe9r8Jv431j@Aw "Python 3 – Try It Online")
It's simple breadth-first search, implemented recursively. The `if...else` is slightly bothering me; it feels like there is an improvement somewhere...
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 7 bytes
```
ŒéʒO_}θ
```
[Try it online!](https://tio.run/##yy9OTMpM/f//6KTDK09N8o@vPbfj//9oXQszHUMTHV1jMx0jQx0jMx1dIx1dU0MdXUNDHWMLHSOLWAA "05AB1E – Try It Online")
```
Œ        # sublists of the input
 é       # sort by length
  ʒ  }   # keep those where:
   O_    #   the sum equals 0
      θ  # take the last one
```
The output of `Œ` doesn't contain the empty list, but if the result of the filter is empty, `θ` fails and leaves the empty list on the stack.
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), ~~24~~ ~~22~~ 21 bytes
```
{t@'*<-/t:&x=/:x}0,+\
```
[Try it online!](https://ngn.bitbucket.io/k#eJzlUstqwzAQvOsrQigNpLtYD8dxTF//4ZoGAoH07ENKyL93dyTbiqG0p16KkL07uzMroTk2l/51tX7kom/uz09Fc75aengzpj80+9Pd/uNl2bYdtVa2k82Ohh95DTyNsXwpUEkbxFYyK7kyLWmuy6U+1lYeehNPAQ4UNSMPnJGZ54xz1BU5JVXkRaYCd+Ok6CjU5GuQtpYqFd8S72riSusl1QLJ3unRSx2t5y2h4DHDKWg10xVjPStwjmcOuKOP9CArXoZxOXxAC8pkXNBpluZxGuFR2wzamFNCLnLkGyYRF4fbqB91tX8QUHngLslKezpFGq9x1y2NOa76gzz1Zf35fr6ukJnCtN2CnxdtZ+TZEVkJ3QjCA0gQmcENN9Doi4iOqclsMgjmZhnn5Z6JoCaJP9kHpQzKB8z8hNYcxpTcYTdzZmabahNmfmFA8OYFyP9kyzTxuzbR+I+2Ta/49xfvvgBV2gdM)
*-1 byte thanks to coltim and Traws*
Unfortunately(?), I found a 2-byte golf that bumps the time complexity to \$\mathcal{O}(n^2 \log n)\$ (and space complexity to \$\mathcal{O}(n^2)\$). This one utilizes "equality table" `=/:` and "deep where" `&` to extract *all* pairs of indices that represent zero-sum subarrays. Finding the pair that represents the longest such subarray is algorithmically the same.
---
# [K (ngn/k)](https://codeberg.org/ngn/k), 24 bytes
```
*<!/1-/'\(*'1|:\)'.=0,+\
```
[Try it online!](https://ngn.bitbucket.io/k#eJzlUstOwzAQvPsrSoUUCLvUjyRNIx4fkkZUqlQJzj2AgH9nd+wkbiUEJy7IcrI7uzNry3PoyruLleNVsb0qC/fRba+L23tLN1tjjvtu93y5e3lc9v1AvZXtZLOj8UdeA09TLF8KVFGN2EpmJVemJc11udTH2spjb+IpwIGiZuSBMzHznHGOtiGnpIa8yDTg1k6KjkJLvgVpbalR8TXxpiVutF5RK5DsjR690tF63goKHjOcglYzXTHWswLneOaAO/pID7LiZRiXwwe0oEzGBZ1maR6nER61etTGnApykSPfMIu4ONxG/air/aOAygN3SVba0ynSeI2HYWnMoTju5anfy7en188CmVmZfljww6IfjDw7Iiuhm0B4AAkiM7rhBJp8EdEpNZlNRsHcLNO83DMR1CTxZ/uglEH5gDM/oTWHMSV32MmcM7PNtRkzvzAgeOcFyP9kyzTxuzbR+I+2Ta/49xcfvgB5AwaK)
Runs in \$\mathcal{O}(n \log n)\$ time and \$\mathcal{O}(n)\$ space. A monadic function train that takes a list of integers and returns `[start index (inclusive), end index (exclusive)]`. (For reading test case output, `!0` and `()` are notations for empty lists, and `,0` is a notation for the singleton list `[0]`.)
```
*<!/1-/'\(*'1|:\)'.=0,+\   monadic train; x: integer list
                    0,+\   prepend 0 to the cumulative sum of x
                   =       group; gives a dict of {value:indices}
                  .        extract values of the dict
                      any ordered pair inside each row forms a valid
                      (start,end) pair with subarray sum of zero
         (*'1|:\)'    for each list, extract (first,last)
 <!/1-/'\             sort this list by ascending order of (first-last)
*                     extract the first pair
```
It is actually shorter than a function that generates all contiguous subsequences and operates on them (which is \$\mathcal{O}(n^3)\$ time and space):
# [K (ngn/k)](https://codeberg.org/ngn/k), 26 bytes
```
{*(0=+/)#,/x{y'x}/:|!1+#x}
```
[Try it online!](https://ngn.bitbucket.io/k#eJzlUstqwzAQvOsr0qSQtllhPWzHCbT9EGMIBALtOQeXNP/e3dHDiqG0p16KkL07uzMjoT3tL08P5nlTPa6oGi8f6/Fa7T/v7GY1XpU6H/eHt/vD++uy7wfqDW/LW1tKP3ISOMoxf8lTTQ1iw5nhXJiGJJdlY5+WVp16I08A7SloBh44mVnmGufoWrJCasmxTAtuY7loyXfkOpC2hloR35LedaRbqdfUMcR7J0evxVrOW0PBwcMKaCSTFWI5K3AdzuxxRxfonle4jMbl8AHNC1Pjglay6KejhUOtSdrwqSEXOPz1k4gN5iboB13pTwIiD9xGWW6Pp4j2Eg/DUqnT+nxUqlL9sNAvi35Q/NCIDIc2g3h1JIhUev8bKE9CQHOqisFIguV4ZL9ySgIoSeRPA4NSAZUGswlCawnDpZypG5/ZeE21CVO/GDnw5gXI/zSI0fG7Ntb4j4MaX/HvLz58AUzsA8k=)
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-h`](https://codegolf.meta.stackexchange.com/a/14339/), 5 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
ã k_x
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWg&code=4yBrX3g&input=WzAsNzAsNjUsLTQ3LC05OCwtNjEsLTE0LDg1LC04NSw5Ml0) or [run all test cases](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=4yBrX3g&footer=zA&input=WwpbXQpbMF0KWzFdClstMSwxXQpbLTEsMSwyXQpbLTIsLTEsMSwyXQpbMSwyLDMsNCw1XQpbMSwwLDIsMCwzLDBdClsxLDIsLTIsMywtNCw1XQpbMSwyLDMsNCw1LC00LC0zLC0yLC0xLDBdClswLDAsMCwxLDAsMCwxXQpbMCwwLDAsMSwwLDAsLTFdClstODYsMTQsLTM2LDIxLDI2LC0yLC01MSwtMTEsMzgsMjhdClswLDcwLDY1LC00NywtOTgsLTYxLC0xNCw4NSwtODUsOTJdCls0LC00LDIsMCw0LC0yLC0yLDEsMCwxLC00LDAsLTIsMiwyLC00LDAsLTEsMiwxLC00LC0yLDMsNCwzLDAsMywyLC00LDIsMywzLDEsMiwzLC0zLC00LDMsLTQsNCwwLC0zLC0xLC01LC00LDEsLTMsNCwtNCwyLC0xLC00LDAsMiwtNSwtNSwyLDEsLTQsMCwtMSw0LDMsMywtNSwtNCwtNSwzLC0zLC0xLC01LDEsLTIsMywwLDMsLTQsMSwtNSwtMSw0LC01LDIsMSwtMyw0LDQsMSwtMSwtNSwtNSwtMiw0LDAsLTMsNCwxLC0zLDAsLTNdCl0tbVI)
```
ã k_x     :Implicit input of array
ã         :Sub-arrays
  k       :Remove elements that return truthy (not 0)
   _      :When passed through the following function
    x     :  Reduce by addition
          :Implicit output of last element of resulting array (or undefined if empty)
```
[Answer]
# JavaScript (ES6), 60 bytes
```
f=(b,...a)=>eval(b.join`+`)?f(...a,b.slice(1),b.pop()?b:b):b
```
[Try it online!](https://tio.run/##dY/PToNAEMbvPsXEC7txdgNUEWtoT3rwoIceaxMXulQaBARsNMY3MPHiUd/D5/EFfIQ6C/1DTQxhM/Obb75vd64WqorKpKhFlk/1chkHLEQppeLBQC9UykI5z5Ps5uCGD2NmBhjKKk0izRxOZZEXjA/Dfsj74bLU9w9JqZkVVxaXpVbT8yTVo6csYjaXdT6qyySbMS6rIk1qtn@d7XMZ5@WZim5ZBcEAnvcAxqAQ9GOho1pPYQIBVOsFEAOglTtVMHM5fkryUtMmxEw1XZRnVZ5qmeYzdjG6upRVk5nET4yEHBv5AVgWBME2ZAjWz9fb98c7nRb0wfr@fLXI74UvxxMTOp7sje22sql0NlA4uGqaqgXo7iIXd@imJSN0sYeHeLQxdNAmZhPt5hESRik20g7q@hiF6GGbsXLoYvMONJ/TnqsM0/wZie5sy@g5voeOsfPQpVyvCTtyaOhgz0fXb/f@Dhr7Yxs9c5ljFCc@Cs8MD9EnRP@Ju078Tzb5BQ "JavaScript (Node.js) – Try It Online")
### Commented
```
f = (                 // f is a recursive function taking:
  b,                  //   b[] = next array
  ...a                //   a[] = list of all other arrays
) =>                  //
  eval(b.join`+`) ?   // if the sum of b[] is not zero:
    f(                //   do a recursive call:
      ...a,           //     first try with the other arrays that were
                      //     already passed to this iteration
      b.slice(1),     //     then try with b[] without the leading term
      b.pop() ? b : b //     and finally with b[] without the trailing term
                      //     NB: we don't mind modifying b[] at this point,
                      //         and this is shorter than b.slice(0, -1)
    )                 //   end of recursive call
  :                   // else:
    b                 //   success: return b[]
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jellylanguage), 7 bytes
```
ẆSÐḟṪȯ$
```
[Try It Online!](https://jht.hyper-neutrino.xyz/tio#WyIiLCLhuoZTw5DhuJ/huarIryQiLCLDh+KCrMWS4bmY4oKsWSIsIiIsWyJbMCw3MCw2NSwtNDcsLTk4LC02MSwtMTQsODUsLTg1LDkyXSwgWzEsMiwzXSwgWzAsMSwyLDNdIl1d)
Converted from a full program to a link for the same byte-count thanks to Jonathan Allan.
```
ẆSÐḟṪȯ$    Main Link
Ẇ          Get all sublists (unfortunately excludes the empty sublist)
  Ðḟ       Filter to remove elements with a non-falsy/non-zero
 S           sum
      $    Apply monadically to the resulting list of sublists:
    Ṫ      - take the last one (returns zero if the list is empty)
     ȯ     - logical OR; if 0 was returned, instead return the list
             of sublists, which is the empty list
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 7 bytes
```
ÞS'∑¬;t  # main program
```
```
ÞS       # sublists
  '∑¬;   # filter
   ∑¬    # by the negated sum
      t  # take the tail
```
Similar to @hyper-neutrino's answer.
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%C3%9ES%27%E2%88%91%C2%AC%3Bt&inputs=%5B-86%2C14%2C-36%2C21%2C26%2C-2%2C-51%2C-11%2C38%2C28%5D&header=&footer=)
[Answer]
# [J](http://jsoftware.com/), 28 bytes
```
<\\.;@{.@(\:#&>)@#~&,0=+/\\.
```
[Try it online!](https://tio.run/##xVFNT8MwDL3zKywmrUxsJU7SrisUVULitBPnSj6gTRMXfgASf734I1lXDc4oSmI/2@85zsd4WxZH6FooYA0OWt6bEl7e9q/j0zCUj/1X2d8N7WL5vOoX38u16@4fGB9XN4f30ycUBWxaOPJtvoOOPTcPormEgAaI9RsGPqE@uSnkZ9EzLccDRKgupZFvzzvkJiSLJJHiVJaBVMqGeBQkMOeecG7BZSVZmmcm2nkZNYjwOo1Snq@VtUJGEEKT3trUgCJZg8frHN9kka2DWrrbAu0aoFpSIjRVFvwzTrx3Pj@cnyfjiqrjtUUU0Ikny2yZh@Jkcwk6Ym/lgZcNjHSqemhZkErSIaJ48fwL/6Ksn6i0XmNV5ladqHRWw2eYSNDEnfEbr@RnAqFXHBMtp6cukrzY4w8 "J – Try It Online")
* `<\\....#~&,0=+/\\.` All boxed sublists `<\\.` filtered by those with 0 sum `#~ 0=+/\\.` after flattening both `&,`.
* `(\:#&>)@` Sort down by length
* `;@{.@` And open the first element.
[Answer]
# [Factor](https://factorcode.org/) + `math.unicode`, 64 bytes
```
[ [ "1"] when-empty all-subseqs [ Σ 0 = ] filter ?last >array ]
```
[Try it online!](https://tio.run/##xVRLboMwFNxzimn2RtgmhLRquqy66abqKsqCUkeJSoCCozaKcprep1dK/SM4IlkXC8ue997M@FmwzHJZNcfXl6fnx1tkTZPtWnyIphQFNplchdtynVfvAnUjpNzVzbqUaMXnVpS5aPtVKL5lk7W4C4J9APXsgQNuQGZm5aCox6ITSC8kEurDdueH2LUgG8Z76CTIwBFjfEGYKmNMvfyaV6YJOchZuQ8PVRRIuPPhsZ6F@g7pQd3sOYg8F34SGWT1eNeUNAHVQgmYcpUYK2OqUih4Cpb2DINgLzmJkGjDE5BpCpLolBipgtQ7Zb6Lq6kdW6wPrtscGzlmPFMNRnqnh13rJhqc2GZyczXMlnM1bJeJ6byZTBnXlcS0l@qd0yNOgpnYuOM2OrGhszVq5j0JteKR5be8Or8j0PQGp45WpTsXTt6svXv/h8MfgsNxjjlGdLTA10qURGxquUNWFKTdvqnvuFXR3x9FcI8FlutCigYPRdZKzMxvAQtFEIahiubVpq5aAZHlq@Mf "Factor – Try It Online")
* `[ "1"] when-empty` Unfortunately necessary to handle the empty sequence. `all-subseqs` blows up otherwise. `"1"` is simply the shortest thing you can stick in there that ultimately produces the empty sequence.
* `all-subseqs` Get every subsequence of a sequence.
* `[ Σ 0 = ] filter` Select the ones that sum to 0.
* `?last >array` Take the last (also longest) element (or `f` if the sequence is empty) and then convert it to a sequence. Necessary because the `filter` can return an empty sequence.
[Answer]
# Wolfram Language (Mathematica), ~~37~~ 36 bytes
```
Last@*Select[Tr@#==0&]@*Subsequences
```
-1 byte from att using function composition
[Try it online!](https://tio.run/##fVDBasMwDL33KwyDHYYNsp2k6SGQD@ihsN1KDlkwXWEtrHFPo9@e2ZbsxG0ZOI70nvT0rFNvv8ypt8ehnw7NtO1H2769m28z2P3HpX1pGnjtHHL9HM3P1ZwHM067y/Fs28P@99atUgzLRC4TITl7BDhTGaY4e4b7nDPNWcFZeUdA4CDQ8NgksFE86ZwlkRcay72DTAmCPgRfFPxPi/yldeW4MMAFyk@uaFIpfbG7dO3Q@k517b4qmFu7a@NKRBUanFbtcX9tsk0V@BTcSEFTVLQmkQXE8ETAcSvGmEpVIu1Hx/2qpK7DSUsUtGKvQCHJapQWtGOJ0GxTzJ4UlZXcyyyckL0ijo1i/q/zGTL5hsxNtIAyPlRLM1Qhk4OgQg@CVEYNAbh10x8)
`Subsequences` generates all contiguous subsequences, sorted by length; `Select[Tr@#==0&]` selects those whose trace (total) is 0; `Last` selects the last, and thus longest, of these subsequences.
att also shows, in the comments, a different approach from mine that is 35 bytes:
```
Last@Pick[#,Tr/@#,0]&@*Subsequences
```
[Answer]
# [Risky](https://github.com/Radvylf/risky), 12 bytes
```
{_*_1?+?:_0{_-+_0+_0+_0
```
[Try it online!](https://radvylf.github.io/risky?p=WyJ7XypfMT8rPzpfMHtfLStfMCtfMCtfMCIsIlswLDIsLTEsMSwzXSIsMF0)
### Explanation
Here's a rough tree diagram of how the program parses:
```
           {
     ?           +
  *     :     +     +
{  _  +  _  _  _  _  _
 _  1  ?  0  -  0  0  0
```
The left half generates a list of all sublists that sum to zero:
```
{_                       List of sublists of the input (ordered shortest to longest)
  *_1                    Repeat 1 time (no-op)
     ?                   Filter by this function:
      +?                  The sum of the input
        :                 Equals
         _0               Zero
```
The right half, using a ton of no-ops to balance the parse tree, evaluates to -1. Finally, `{` gets the element of (left half's result) at index (right half's result): i.e. the last and therefore longest sublist.
[Answer]
# [Python 3](https://docs.python.org/3/), 85 bytes
```
lambda a:[(s,l)for l in range(len(a))for s in range(len(a)-l)if 0==sum(a[s:s+l])][-1]
```
[Try it online!](https://tio.run/##XchLDsIgEADQq7Bk4kwCWvtLOAmyGGPRJlPaQF14emxcunibt33215ouNbpbFV7uD1Y8el1QIK5ZiZqTypyek5YpaYbflv8lgTkq41x5L5p9GctJAgRPNtQtz2nXUXuDncH2itR0SEOP1Fok22B/1GE4B4D6BQ "Python 3 – Try It Online")
-5 bytes thanks to totallyhuman
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), ~~13~~ 9 bytes
*-4 bytes thanks to a [clever trick](https://codegolf.stackexchange.com/a/231602/16766) from [Unrelated String](https://codegolf.stackexchange.com/users/85334/unrelated-string)*
```
⊇.+0&s.∨Ė
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//1FXu562gVqx3qOOFUem/f8fbaBjpBNvqGMY@z8CAA "Brachylog – Try It Online") (Note that negative numbers in the input must be indicated with underscores rather than minus signs.)
### Explanation
It would have been nice to use this 6-byte solution:
```
s.+0∨Ė
s.       A contiguous sublist of the input is the output
  +0     and its sum is zero
    ∨   Or, if it is impossible to satisfy those conditions...
     Ė   the output is the empty list
```
Unfortunately, the order in which the `s` predicate tries sublists is [ordered by start index](https://tio.run/##SypKTM6ozMlPN/r/v/jhrs5HXUv//4820DHSiTfUMYwFAA), not by length. However, the `⊇` predicate, which gives not-necessarily-contiguous sublists, *is* [ordered by length](https://tio.run/##SypKTM6ozMlPN/r//1FX@8NdnY@6lv7/H22gY6QTb6hjGAsA). So we can start by getting the longest sublist and then afterwards check that it's contiguous:
```
⊇.+0&s.∨Ė
⊇.          A sublist of the input is the output
  +0        and its sum is zero
    &       and furthermore
     s.     the output is a contiguous sublist of the input
       ∨   Or, if it is impossible to satisfy those conditions...
        Ė   the output is the empty list
```
[Answer]
# [Haskell](https://www.haskell.org/), 64 bytes
```
k=length
f l|sum l==0=l|h:t<-l=f t#(f.init)l
a#b|k a>k b=a|1>0=b
```
[Try it online!](https://tio.run/##ZY3RisIwEEXf8xUD7oPCzDJJNUYx/oFfIH1IwW5L0yIa3/rvNbFZtrCEzNw5uXPTuGd3836aOutvw09oRA1@fL568Nay9WNzDCfytoawWtff7dCGjRduVY0duHMHlXWjPLOtpt61A1jo3f0C90c7BPhKA6zrzRUEwLXEVHlucm4kcaFQZa1wOUaBBW5x9ztyBBwR/71TstDCk1cSowLnxOxnTEfO9T@izICMRpnWNaoYqD8pOxkNEguDymQf455Rp6/2SAeDpJNniyaieA@qhFKI6Q0 "Haskell – Try It Online")
* `f` return longest sublist by checking if list sum is 0 or choosing the best result coming from recursively inspecting tail and init
* a`#` b used by `f` to choose longest result
[Answer]
# [Haskell](https://www.haskell.org/), ~~75~~ 73 bytes
*-2 bytes thanks to [Joseph Sible](https://codegolf.stackexchange.com/users/81540).*
```
f i|e<-length i=last[(s,l)|l<-[0..e],s<-[0..e-l],0==sum(take l$drop s i)]
```
[Try it online!](https://tio.run/##dVBBjsMgDLznFT7sIZHsCEibUql5Ql@AOCCVblFJGhX21r9noc0lyS4IC8@Mx@CbCXfr/TRdwb3sibwdvuMNXOdNiKoM6KuXP5FidW01hvlGXiPruvDTl9HcLfivy/MxQgBX6SnaEAN0oEDpAuaFoNgi44uMOG4BFEtI4B9oyrHBHe5XKEs4SwzbqCkX0LZi9skUNfjptqxmmDf/xH8ZWv1EtsizZYsiNWnfznueZBwbiUKujA4M2/yIA9JRIrVZuUOZoHSOQoMuit64IU24N@MZyvHphgg1XCt4j376BQ "Haskell – Try It Online")
[Answer]
## Clojure, 98 bytes
```
#(or(first(for[n[(count %)]i(range n)j(range n i -1):when(=(apply +(subvec % i j))0)][i j]))[1 0])
```
Returns an exclusive range, or `[1 0]` if no such range is found. For example:
```
[1,2,3,4,5,-4,-3,-2,-1,0] -> [3 8]
```
[Answer]
# [Perl 5](https://www.perl.org/), 73 bytes
```
sub{(sort{@$b-@$a}grep!sum(@$_),map[@_?@_[$_/@_..$_%@_]:()],0..@_**2)[0]}
```
[Try it online!](https://tio.run/##nVRNb9swDD3Pv0INtMU2qMySE9eN4VX3DetlO7mG0RZu6y4fXuxgK4L89kyk1HwBuzRKBPKRfI@irbT1ajbZ8cd8163vN363XPUbze@F5nfbp1XdXnTrua95FcD8ri10da2rglefdTUa8eqjrsqpH5QQjUa6CkMVFFG53WXe/JXpvu763PeKkuVfWFGCZ2JkRmjLAywkOI8sh4A6wxScwHsXyUBBDGOYHEglRAaMDHyiajCBuWKffASdUGGKiMHqOI5jmA4EuKTdnQw65zFxHDxgeKo0AYmMCSgjnZDeRJqohDgFldrC84AVuIwgwYYuQVylIBKMjiE1kPldqTfN/6UhyRjPg3Mak4Ci5iSCEXq4rI1zIVzY@cQ0W48pSxCbZUcnaLi0UWGMtYLmJtFzisKJEMMEv2qvK4k/dlVmjw800jYQWQVp6jELK94oUIK0pCM2Ba4T1wLapcfMxz7Ud4/A@4B9vGsEZZB5f56bWe3TRQk21M/81efNogVe/22DvGtnzUNNcXybM5fC@NOyzz/xR3MvTXJg8XbVLHr2smwW/hCGoDEpYPXvYwhZ2TUbLH8xit8uBmzKBmEYsu83P9jN1wuDZN7WW3c1@9Z0/XT6s29mbGj@BIbZ7h8 "Perl 5 – Try It Online")
[Answer]
# [Desmos](https://desmos.com/calculator), ~~154~~ ~~139~~ 137 bytes
*Thanks [@fireflame241](https://codegolf.stackexchange.com/users/68261/fireflame241) for helping me golf a couple of bytes (on Discord)*
```
A=length(l)
B=[1...A-f]
Z=[0...A]
h(a,b)=\{\sum_{C=a}^bl[C]=0,0\}
f=\max((Z+1)\sign(\sum_{n=1+Z}^Ah(n-Z,n)))
g(l)=[f,\max(Bh(B,[f...A]))]
```
Uses Output Format #4. The first element in the outputted list is the length of the subarray, while the second element is the starting index of the subarray in respect to the inputted array.
[Try It On Desmos!](https://www.desmos.com/calculator/w3h6rp5vpz)
[Try It On Desmos! - Prettified(and a more verbose version)](https://www.desmos.com/calculator/s5savobsr4)
[Answer]
# [PHP](https://www.php.net/), 101, 99, 90
```
for(;$argc>$j=++$i;)for(;$j;)array_sum(array_slice($argv,$j--,$l=$argc-$i))||die("$j,$l");
```
[Try It Online](https://tio.run/##K8go@G9jXwAk0/KLNKxVEovSk@1Usmy1tVUyrTUhYlnWmolFRYmV8cWluRpQVk5mcqoGSHWZjkqWrq6OSo4tWK@uSqamZk1NSmaqhpJKFlBYSdP6////Zv8N/xv91zX@b/Jf1@S/AQA)
Input is array elements as the command line argument list.
Outputs the zero based start position and length of sub array.
Does not output anything for the null case.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 26 bytes
```
Ｆ⊕ＬθＦ⊕⁻Ｌθι⊞υ✂θκ⁺κι¹Ｉ⊟Φυ¬Σι
```
[Try it online!](https://tio.run/##ZcyxCsIwGATg3afI@Af@DEm1FBwFQVAJdCwdSow2NE1smvj6sZkcvPW@OzUOQfnB5vz0gcDFqaBn7aJ@wFW7VxxhoZSSv/JmXFp/BIkpTKZ1hISktUZpWJBMSKTd4FQAEk7pcSeDcRFOwxpB@jecjY06lNXdR2jTDOVqyzHnrmNNjXyPrKpRcBQ1MoHswJFxjlWDoun7zD72Cw "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｆ⊕ＬθＦ⊕⁻Ｌθι⊞υ✂θκ⁺κι¹
```
Carefully list the subsequences of the input in ascending order of length.
```
Ｉ⊟Φυ¬Σι
```
Get those with a zero sum (or no sum at all, in the case of the empty subsequences) and output the last i.e. the longest.
[Answer]
# [Haskell](https://www.haskell.org/), 88 bytes
```
f=head.filter((0==).sum).concat.iterate(concat.zipWith map[tail,init].replicate 2).(:[])
```
[Try it online!](https://tio.run/##LYxBCoMwEEWvMgsXCabB6k7IAXqCLkIWox3J0JhKnFLo5W2ELv9/vBdxf1JKxw7oisfwiVQIisJx0o4X2N9rJa6TSBkQKO2VNlPbes4sgEaQE2A4FhcJH3bhJFSU6pzTtsrazq88o1iuNwqp//zydmeJsOLmz4Q5c8EW2hJXTtBrq0Yf9LEiZ7cVztIsfjBX05vLMI63LOH4AQ "Haskell – Try It Online")
[Answer]
# [jq](https://stedolan.github.io/jq/), 53 bytes
```
[.[keys[]:keys[]+1]|select(add==0)]|max_by(length)//.
```
[Try it online!](https://tio.run/##bU/bbsIwDH3fl4CwIU7aUJD4kiqaGFTbGINN7cOQ@PZ1Pk66vUyWE9/OOfbpcxzbZfvW3fo2bfO3kHTvu3N3GGb743G3c/N0f99/PT7dZufu8jy8zFerpcLSQ@vURZ2Fpo88Ak@/sb4UqKLaYqeZ09yVDqPJU7dMosCBMgsmHQEJE8ss@jdn26OJJKCI5JU0GlMt2hQKDfnGQGtHEVJr4k1DHNGvqNGS@garV1gE@1bG4E1DUHTIYDnG5lbnfEGwG32GB7V8Gtup9hgsAMl2riArelwkvPXqidt0KqPLGH3DH4lkcZf5My/mJwLQW10KrY6XLYo84vR9/Rher5d@5MMP "jq – Try It Online")
**Explanation:**
```
[
  .[keys[]:keys[]+1]   #calculates all subarrays
  |select(add==0)      #selects these which add up to 0
]
|max_by(length)        #picks the longest one
//.                    #if there is no such subarray returns an empty array
```
]