[Question]
  [
## The task
In this challenge, you are given a number and a list.
Your task is to remove from the list all occurrences of the given number except the first (leftmost) one, and output the resulting list.
The other elements of the list should be left intact.
* The number will be a positive integer below 1000, and the list will only contain positive integers below 1000.
* The list is not guaranteed to contain any occurrences of the given number. It may even be empty. In these cases you should output the list as-is.
* Input and output formats are flexible within reason. You can output by modifying the list in place.
* The lowest byte count wins.
## Test cases
```
5 [] -> []
5 [5] -> [5]
5 [5,5] -> [5]
10 [5,5] -> [5,5]
10 [5,5,10,10,5,5,10,10] -> [5,5,10,5,5]
2 [1,2,3,1,2,3,1,2,3] -> [1,2,3,1,3,1,3]
7 [9,8,7,6,5] -> [9,8,7,6,5]
7 [7,7,7,7,7,7,7,3,7,7,7,7,7,7,3,7,1,7,3] -> [7,3,3,1,3]
432 [432,567,100,432,100] -> [432,567,100,100]
```
  
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~5~~ 4 bytes
```
üoEė
```
[Try it online!](https://tio.run/##yygtzv7///CefNcj0////29o8D/aVMdUx9AAhOCsWAA "Husk – Try It Online")
* Saved 1 byte thanks to Razetime
* Saved 2 bytes thanks to Jo King
Thanks to Razetime for suggesting `ü` and Jo King for letting me know I could leave the superscript arguments out, saving me 2 bytes. It removes duplicates with a custom predicate that makes sure both arguments are equal to the number to be removed.
Explanation:
```
üoEė
ü     Remove duplicates by binary function (implicit second argument)
 o    Compose 2 functions
   ė  Make a list of 3 elements (first element is implicitly added)
  E   Are they all equal?
```
[Answer]
# [R](https://www.r-project.org/), 30 bytes
```
function(l,d)unique(l,l[l!=d])
```
[Try it online!](https://tio.run/##K/qfpmCjq/A/rTQvuSQzP08jRydFszQvs7A0FcjMic5RtE2J1fyfppGZV5KanlqkYaCpY6rJlaaRrGGqY6pjaABCcJYmCP8HAA "R – Try It Online")
`unique()` has the signature `unique(x,incomparables = FALSE,...)`; this sets `incomparables` to the elements that aren't equal to `d`, so only `d` is uniquified.
[Answer]
# [Python 2](https://docs.python.org/2/), 50 bytes
```
l,n=input()
for x in l:
 if~n-x:print x;n^=-(x==n)
```
[Try it online!](https://tio.run/##ZYvNCoMwEITveYrFk8IISaw/VfIkwV6KYkBWEUvTS1/dGgtFKLvMNzvszK91mFhvz8GNHam68909iqJtBBvH82ONE9FPC3lyTGMtyPVvTn09L45X8g3fTBp7YzjZjqgRoW1b5MLmX8WJ6iCUDPtzey6FVdDIcNIWmoS9okKJIrRLYUucJ/u7VODxeck08mJPpETwO9tgPg "Python 2 – Try It Online")
Prints output one entry per line.
The idea is to store whether we have already encountered the entry-to-remove `n` in the sign of `n` rather than a separate Boolean variable. When we see a list entry that equals `n`, we negate `n`. To decide whether to print the current entry `x`, we check if it equals `-n`, which checks that it equals the original `n` and that we've already negated `n` due to an earlier match. Note that since `n` and list entries are positive, there's no way to get `x==-n` before `n` is negated.
Well, actually, instead of negating `n`, it's shorter to bit-complement it to `~n`, which is `-n-1`. To do the conditional complementing, we note that we can convert `[x,~x][b]` to `x^-b` (as in [this tip](https://codegolf.stackexchange.com/a/40795/20260)), using that bitwise xor `^` has `x^0==x` and `x^-1==~x`. So, we do `n^=-(x==n)`.
[Answer]
# JavaScript (ES6), ~~32~~ 30 bytes
Expects `(x)(list)`.
```
x=>a=>a.filter(v=>v^x||a[a=0])
```
[Try it online!](https://tio.run/##ldDRDkMwFAbg@z1FLys5o2Vlu@BFxJLGWCzCgogL7249YpuELl1VW/L79PQhe9mmTfHsjlV9y6Y8nIYwkqrbeVF2WUP7MOqvwzjKWIYssaa0rtq6zOyyvtOcEiIsGieWRcya45A4OewZwhhBQ2gQMGX2Ec7@R0DPAGfYPysNuzBLdFuZqzQOLniwGrVbRO2dm@8tGCjwAmcIwDeoFcFvehcLYH15myeO8/wjxPDd7s5OHpaqRhC@@ogxwLWafxzcOo3J6QU "JavaScript (Node.js) – Try It Online")
### How?
All values `v` that are not equal to `x` are preserved thanks to `v^x`. The first value that is equal to `x` is kept as well because `a[0]` is guaranteed to be a positive integer (except if `a` is empty, but then we don't enter the `.filter()` loop to begin with). For the next values that are equal to `x`, we have `a = 0` and `a[0] === undefined`, so they are rejected. This test doesn't throw an error because Numbers are Objects, so it's legal to access the (non-existent) property `'0'` of `0`.
[Answer]
# [Haskell](https://www.haskell.org/), 43 bytes
```
a%(b:c)|a==b=b:filter(/=a)c|1<2=b:a%c
_%x=x
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P1FVI8kqWbMm0dY2yTbJKi0zpyS1SEPfNlEzucbQxggolKiazBWvWmFb8T83MTNPwVahoCgzr0RBRcHE2EhBVSEaSOmYmpnrGBoY6IDYQDr2PwA "Haskell – Try It Online")
Ungolfed:
```
dedupl v (x:xs)
  | x == v = x : filter (/= v) xs
  | otherwise = x : dedupl v xs
dedupl _ [] = []
```
---
# [Haskell](https://www.haskell.org/), 40 bytes
This version takes a (negative) predicate for input instead.
```
f%(b:c)|f b=b:f%c|1<2=b:filter f c
_%x=x
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P01VI8kqWbMmTSHJNskqTTW5xtDGCMTKzClJLVJIU0jmiletsK34n5uYmadgq1BQlJlXoqCioKFva2JspKmgqhANpHVMzcx1DA0MdEBsIB37HwA "Haskell – Try It Online")
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 60 bytes
Saved 2 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!!  
Saved 2 bytes thanks to [ErikF](https://codegolf.stackexchange.com/users/79060/erikf)!!!
```
t;f(d,l)int*l;{for(t=0;*l;++l)*l==d&&t++||printf("%d ",*l);}
```
[Try it online!](https://tio.run/##fZNdb4IwFIbv/RUnJJgWasaHgK5j@yGbF4uVhaTDRbgwU347O/SAsNUMie9p3@d8pCn71cd@33WNLJgSmpdV42l5KY4n1uSBxNj3Nfd0nqvlsvH96/XrhEzBHFeBIzzNZdvhBny@lxXji8sC8Ok3oDnUTfi6gxwuQSt/70e0nwjLiUfnjrf@x0smLwz6d4osNiU2FJGIxfzfIjMit2IjMpHe67shIhPzX2ytQqNW9pay13EkkhSpIBB93OuM9QxbE2uOVdApksQka5KEJCXJSDYk27/91XRq42lFZmacYmDxKgDrE8pKHc5IB3IIn6Auvw/HgplK/GFYebSU4PuG40CX4tZYYRFqbvydnNse6MGuLXu8esxVHC8fYJObN42phiH1K4Y7M4Y68xs4L@TWrsI6DIEXB5xHx@FiyON2W1g9gzNvab4Ym3urRqpdtN0P "C (gcc) – Try It Online")
Inputs a number and a pointer to a null terminated array (as there's no way to know the length of an array passed into a function in C) and outputs the filtered array to `stdout`.
### Explanation
```
f(d,                        // function taking the duplicate number d,  
    l)int*l;{               // a null terminated array of int l  
  for(                      // loop...  
      t=0;                  //   init test flag t to 0, this will mark the  
                            //   1st (if any) occurance of d  
          *l;               // ...over the array elements  
              ++l)          // bumping the array pointer each time  
      *l==d                 // if the array element isn't d...  
           &&t              //   or it's the 1st time seeing d  
               ++           //   unmark t by making it non-zero  
      ||printf("%d ",*l);   // ...then print that element  
}
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~18~~ ~~15~~ 10 [bytes](https://github.com/abrudz/SBCS)
Thanks to [Adám](https://codegolf.stackexchange.com/users/43319/ad%C3%A1m) for -8 bytes!!!
```
∊⊢⊆⍨≠∨<\⍤=
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT/9/eNujtgnVj3p3AZECBG8FIhBVCyTmKhTk51SmZebkKKTlFykYWugZqBcDxZf8f9TR9ahr0aOutke9Kx51LnjUscIm5vA22/9pQPMe9fY96mp@1LvmUe@WQ@uNH7VNfNQ3NTjIGUiGeHgG/1dQMFVIA5qyRoEYAHIFF0SLjimxGkyhOkwVTInXYWhAmg4UPUAGECFYOPVAlQEdaATUaggkjVFIXNbB1IAxULc5ULelggWQNiPgZJBuuEqoTnMUaIzBMwTTIJ0gGmKniTHIxSDS1AyowsAAzAbR2O1EVgnEAA "APL (Dyalog Unicode) – Try It Online")
Example inputs: left argument `3`, right argument `1 2 3 4 3 4`.
`=` does element-wise not-equal comparison. `=> 0 0 1 0 1 0`  
`<\` Scans with less-than. This keeps just the first `1`, all other places are `0`. `=> 0 0 1 0 0 0`  
`≠∨` does element-wise *OR* with the `≠` mask. `=> 1 1 1 1 0 1`.  
`⊢⊆` partitions the input based on the vector, including positions with positive integers. `=> (1 2 3 4) (4)`
`∊` flattens the nested array. `=> 1 2 3 4 4`
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~6~~ 5 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
-1 thanks to [Sisyphus](https://codegolf.stackexchange.com/users/48931/sisyphus)'s suggestion to use `Ẇ` in place of `W€`
```
Ẇi¦⁹ḟ
```
A full program accepting the list and the value which prints the Jelly representation of a list with all but the first occurrence of the value removed (empty lists print nothing, lists with one element print that element).
**[Try it online!](https://tio.run/##y0rNyan8///hrrbMQ8seNe58uGP@////o02MjXQUTM3MdRQMDQx0FMBcICtW4T@QCQA "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##y0rNyan8///hrrbMQ8seNe58uGP@/8PL9R/ubFF51LTmxPJHDXP@/4@Ojo7VUTCN5dKJjjZFsEAMNI6hAZwH4kAwMg@hxlBHwUhHwRjIR2MAlRiBVVjqKFjoKJjrKJhBDDcHi5qDhdCQMW5BQwgbrt/EGGiJqRlIxgDoJDAXyIoFM2O5YgE "Jelly – Try It Online").
### How?
```
Ẇi¦⁹ḟ - Link: list, A; value V
  ¦   - sparse application...
 i ⁹  - ...to indices: first occurrence of V in A  ([0] if no V found)
W     - ...action: all non-empty sublists (since ¦ zips, the element, z, at any
                                           given index of A will be [z])
    ḟ - filter discard occurrence of V (leaves the [z] as is)
      - implicit print
```
---
I thought `ḟẹḊ¥¦` would work for 5, but it fails with a divide by zero error with `[5,5]` and `5`.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~10~~ 7 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
kÈ¶V©T°
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=a8i2VqlUsA&input=WzQzMiw1NjcsMTAwLDQzMiwxMDBdCjQzMgotUQ)
-3 bytes thanks to caffeine!
```
kÈ¶V©T°     :Implicit input of array U and integer V
k           :Remove the elements in U that return true
 È          :When passed through the following function
  ¶V        :Is equal to V?
    ©       :Logical AND with
     T°     :Postfix increment T (initially 0)
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 6 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
Ê0X.;Ï
```
Integer as first input, list as second input.
[Try it online](https://tio.run/##yy9OTMpM/f//cJdBhJ714f7//w0NuKINDQx0TIHQ0ACCkHixAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWWCy9EF/w93GUToWR/u/394vc7/6GhDAx0gNtAxBUIgG4UZG6ujEG2qEw2jTeEMHQgTpBmNDdGJZoYR0A4dIx1jHSQSLGGuE22pY6FjrmMGNQUoYK6DDI0xeIYgGqzYxBhoMIgwNTMHuxzEBtJw96D4Bt1vsQA).
**Explanation:**
```
Ê      # Check for each value in the second (implicit) input-list whether it's NOT equal
       # to the first (implicit) input-integer (1 if NOT equal; 0 if equal)
 0X.;  # Replace the first 0 with a 1
     Ï # And only keep the values in the (implicit) input-list at the truthy (1) indices
       # (after which the result is output implicitly)
```
[Answer]
# [Bash](https://www.gnu.org/software/bash/) + sed, 49 bytes
```
sed "s/\b$1\b/_/;s/\b$1\b \?//g;s/_/$1/"<<<${*:2}
```
[Try it online!](https://tio.run/##S0oszvifVpqXXJKZn6eQpqFZ/b84NUVBqVg/JknFMCZJP17fGsZWiLHX108HcuP1VQz1lWxsbFSqtayMav/XcnGlKZiCMIwE04YGKAwQhcwCShgpGAKxMTIJFDVXsFSwAJJmYM3maNAYg2cIooEqTYyNwNjUDChmYABmA@n/AA "Bash – Try It Online")
Takes the first argument as the duplicate and the rest as the array.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 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"))
Translation of [Galen Ivanov's J solution](https://codegolf.stackexchange.com/a/212384/43319).
Anonymous tacit infix function, taking number as left argument and list as right argument (though argument order can be switched by changing the `⊢`s into `⊣`s).
```
∊⊢⊆⍨≠∨∘≠⊢
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT/8f9ahtQvXh6Y/6pvo5qz/q3aVuBSQedS541LtV4VF3i4IGkPGodzOQ1LQF0Z2LgMxahUe9cxUK8nMq0zJzchTS8osUDC30DNSLFYA6/z/q6HrUtehRV9uj3hVRjzpWPOqYEQUU@J8GtOpRb9@jruZHvWse9W45tN74UdtEoM3BQc5AMsTDM/i/goKpQhrQ9DUKxACQK7ggWnRMidVgCtVhqmBKvA5DA9J0oOgBMoAIwcKpB6oM6EAjoFZDIGmMQuKyDqYGjIG6zYG6LRUsgLQZASeDdMNVQnWao0BjDJ4hmAbpBNEQO02MQS4GkaZmQBUGBmA2iMZuJ7JKIAYA "APL (Dyalog Unicode) – Try It Online")
`⊢` on the right argument
…`∘≠` apply nub-sieve (Boolean list with Trues where unique elements occur first), then:
 …`∨` element-wise OR that with:
  `≠` Boolean list with Trues where elements in the list are different from the number
…`⊆⍨` corresponding to runs of Trues in that, extract runs in:
 `⊢` the list
`∊` **ϵ**nlist (flatten)
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~26~~ 24 bytes
```
#2/.(a=#)/;a++>#:>Set@$&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7X9lIX08j0VZZU986UVvbTtnKLji1xEFF7X9AUWZeSbSyrl2ag4NyrFpdcHJiXl01V7WpjkJ1ba0OhGGKYOlA2IYGWDg6QAYQwVlgSSOgnKGOkY6xDhIJljEHyljqWOiY65hBDQKJmOsgQ2MMniGIBqs2MQaZDSJNzYDiBgY6IDaQrq3lqv0PAA "Wolfram Language (Mathematica) – Try It Online")
The pattern `(a=#)` to be matched is only evaluated once, at the very start. Then, the condition `a++>#` is only evaluated when the pattern is matched - so `a` will have been incremented on subsequent matches.
[Answer]
# [Red](http://www.red-lang.org), 46 bytes
```
func[n b][try[replace/all find/tail b n n[]]b]
```
[Try it online!](https://tio.run/##ZU9BDoMwDLvzCv8AGAO2PWPXKIcWWg2pKqiCw17fpcA2JJrKduLWUoLp49P0xJl9INrFd@ShmebwpmAmpzqTK@dgB9/nsxocNDw8MWuOdgxGdS9sXzLIqSFRu6j/Crsui3OTWO5PbeYFVApUOODmtKA7bkLNN0gmLY5VnboyMWN9fq0kPEHdiFEU60CYM6YpjNrAIm0UPw "Red – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 62 bytes
```
f=lambda n,l:l.count(n)>1and f(l.pop(~l[::-1].index(n)),l)or l
```
[Try it online!](https://tio.run/##ZU49b4MwEN35FbcF1AvCUEJrKdnStUs3xADBCBTHthxok6V/nZ5DEpAq2/fufdg@c@1brZJxbLayPFV1CQoll@FBD6r3VbBjpaqh8WVotPF/Zc75mhVhp2pxITtAGWgLcvxpOyngyw6CewC9vToA6JSBratD7wfh2ciO8OYoBImgyT2VxhffJTHK5TwuXhwmvJiCxnY0SePTXAHC6tzqQdZQiRXddglxOQjTw/7zY2@tthwqK8rjmEJewHpH1aM2nfp0IjhTFi05zgqyyO1n90zc1cKLIWcYY4KLOqUewu0UXgb5O75hhpvHRzN1ZobLlfxjzOF00Qn3V18TGoAKphuKRBG6nnAKLg0n/gE "Python 3 – Try It Online")
This function will recursively pop the last instance of the given value until no more than one instance is present. Then it returns the list.
or, for the same byte count
```
lambda n,l:[j for i,j in enumerate(l)if j!=n or i==l.index(n)]
```
[Try it online!](https://tio.run/##ZU47b4MwEN75FdcpRr1GPEpokeiWrl26UQ9QjDA1BjnQJr@enkMSkCLb9933ONv9aag7HU5V@jWpvC3KHDSqJGug6gxIbEBqEHpshckHwZQrK2geUg3WTVO1lboUR6ZdPv3VUgn4NKNIHIDBnCwAzfeQ2joOzN0eeiUJz45GUAgduW3eM/GbE6NclgT80WKY8DnYG6kHVjH6mYuwOdTdqEooxIambUIcv0U/wP7jfW9MZxIojMh/pggyDk9vVB1qo7mPZoIL9b01x0VB37P71t0SF5U7AWQ@Bhjiqs6pq3A@3Ikhe8UXjHF3fWih1oxxvcI75lucB61wufU5pA9QwWhHEc9D2xPOwbVhxX8 "Python 3 – Try It Online")
This is just a simple filter.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 8 bytes
```
ʒÊD¾ms_½
```
[Try it online!](https://tio.run/##yy9OTMpM/f//1KTDXS6H9uUWxx/a@/9/tKmOAhAZGkAwMi@Wy9AAAA "05AB1E – Try It Online")
**Commented**:
```
ʒ          # filter the first input on ...
 Ê         #   not equal to the second input (n)?
  D        #   duplicate this value
   ¾       #   push the counter variable initially 0
    m      #   power (value != n)**(counter)
           #   this is only 0 if value==n and counter is positive
     s     #   swap to (value != n)
      _    #   negate this
       ½   #   increment the counter variable if this is truthy (value == n)
```
[Answer]
# [Perl 5](https://www.perl.org/), 36 bytes
```
sub{$n=pop;$i=0;grep$n-$_||!$i++,@_}
```
[Try it online!](https://tio.run/##jVJta8IwEP6eX5GVY1S8QKuL3SwZ/QP7tm8iBVkqBU1LW2Gi/vYuSX1JtcL6csk9z93lyHOlrDa83dWSfsu6mc@/ikrGZLunkIm23q0OoERZlDHkIojXlSxBMUiPxxfIx2NM0lMbk6yofEL1s6Ac6WJJxaexS3RA3qH8HsYBIgx6DA5xqDf6u@6usWfUSZnojBAnOEXHdvEXwP5OSqRTPvAdI5xd2nDcXliE7jt98EKzdiUMcH/S29S0Zyyf6eAgQLPXa5fiEhYcbDF63uToYJft3geFsMnrBkH@liORQBqfKZqsi0a8QuYn5wg1unKQq6wQnhKgNGBo0UVpTx9Jqck1BbwuJa99z7roJeYkD20FXfBEfgol00bPWa7WccvNkDAzKoTbAWB2DqyDNzcMXB9vyOMIsP4IkMmg8OxBeBL1ro71btKQ/xSZ9UQmWrwn0rIBaf8A "Perl 5 – Try It Online")
Pop last input value from @\_ into $n. The remaining @\_ is the input list. Filter (grep) @\_ for the values that either isn't equal to $n (`$n-$_` is truthy when $n and current list value $\_ is different) or is the first equal to $n since `!$i++` is truthy for the first and not for the rest.
[Answer]
# [J](http://jsoftware.com/), ~~15~~ 10 bytes
-5 bytes thanks to xash!
```
]#~=<:~:@]
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/Y5XrbG2s6qwcYv9rcilwpSZn5CsoKJgqpCkYqBggc3VMkXmmcK6hAYirgM4FMYAIzoJpNgJKGwJJY2QSJmkOlLRUsADSZnADwYLmKNAYg2cIoiEaTIxBVoBIUzOghIEBmA2k/wMA "J – Try It Online")
## My initial solution:
# [J](http://jsoftware.com/), 15 bytes
```
[#~~:+i.@#@[=i.
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/o5Xr6qy0M/UclB2ibTP1/mtyKXClJmfkKygomCqk1SkYqBig8HVMUbimcL6hAZivgMEHsYAIzoLpNwLJGwIpY2QSJmsOkrVUsAAyzOBmQkTNUaAxBs8QREN0mBiDbQFRpmZAGQMDMBtI/wcA "J – Try It Online")
[Answer]
# APL+WIN, 19 bytes
Prompts for vector followed by element to be removed:
```
((v≠n)+<\v=n←⎕)/v←⎕
```
[Try it online! Thanks to Dyalog Classic](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qvz6O2CcZcjzra0/5raJQ96lyQp6ltE1NmmwcUB8pr6pdBGP@BSrj@p3E96l3DZcqVBsRgUgFBGxpAGAqGBiAEZ0EkDBWMFIwVkEguI6CopYKFgrmCGVC3OZBnroAMjTF4hiAarNLE2EjB1AwoYmCgAGIDaZAYFwA "APL (Dyalog Classic) – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~13~~ 12 bytes
```
F+ṀΓ·:f≠⁰↕≠⁰
```
[Try it online!](https://tio.run/##yygtzv7/30374c6Gc5MPbbdKe9S54FHjhkdtUyGM////Gxr8jzbVMdUxNAAhOCsWAA "Husk – Try It Online")
user's answer.(-3 bytes, then -1 byte.)
# [Husk](https://github.com/barbuz/Husk), 16 bytes
```
J²fI§e←of≠²→↕≠²⁰
```
[Try it online!](https://tio.run/##yygtzv7/3@vQpjTPQ8tTH7VNyE971Lng0KZHbZMetU2FMBs3/P//3@R/tLkOMjTG4BmC6FgA "Husk – Try It Online")
~~Can probably be shortened with `Γ`.~~
There may be an extremely short solution with `ü` as well.[user's answer](https://codegolf.stackexchange.com/a/212417/80214)
+2 bytes after supporting numbers not in the list.
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 42 bytes
```
a=>b=>a.Where((x,i)=>x!=b|i==a.IndexOf(b))
```
[Try it online!](https://tio.run/##jY7BCoJAFEX3fsXL1QxMogtXOrOJAkNo6VrtVQ/sCc5IQvXtpi5s0yK4i3s5cLi13daWxkPPdZqTdSmxMwqWPVUF2Z77O3Zl1eDCjIHLBEHDWGpTaVMGxQ07FGJQJLUZNrp6kdZlkPEZh9NFVFKOieftWrZtg0HRkcOcGIV1HfE1OLbEwle@mr2C8QHrESHhGatYReGctcFbiiiUUiZ/WOG3Fr6S8QM "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# [Scala](http://www.scala-lang.org/), ~~62~~ ~~61~~ 58 bytes
```
a=>s=>{val(c,d)=s splitAt s.indexOf(a)+1;c++d.filter(a!=)}
```
[Try it online!](https://tio.run/##fY9BT4MwFMfvfIrnrQ3PDYYMnSnJjh6MB48Lh0rLgiEV18YsWfbZsR2TlI0JlP55/f0erS55w7uvj09ZGnjltQK5N1IJDeu2PQQAP7yB7QpelAGWw7v83thYjHPHWa5ZfrAsKVFQpkG3TW3WBvSsVkLu3yrCaRg/l2EoZlXdGLkj/I7RYwf2ErICC5z@gqBXQ2sKDLbWJJoGDmx3tTKNIhVJ0UGEUgrzOdznsCmmibRHHJHeQjD1@lxRcTSJ4X8g2myfIY3F89Klv@j1GBeYoPf25L/qaVz6We8/4SNmuBztdqjdcDL07@TqK3az189VJ/fwkJxP4UK6tGYUoct29nx/1Y4iCI7dLw "Scala – Try It Online")
* Thanks to [Galen](https://codegolf.stackexchange.com/users/75681/galen-ivanov) for -1 character
* Thanks to [user](https://codegolf.stackexchange.com/users/95792/user) for -3 characters
[Answer]
# [Haskell](https://www.haskell.org/), 55 bytes
```
f n=foldl(\a x->if x==n&&x`elem`a then a else a++[x])[]
```
[Try it online!](https://tio.run/##ZVFha8MgEP0rRxgl1iskzdJsMLs/sMFgH42sQg0pM7ZEx/Jh/z3TrJiM4nn33vOdB9pK@6m0HscGDGvO@qjTWsKw2Z8aGBgzq9VwUFp1BwmuVQYkKG0VSEr5IAgXYydPBlgnL68fcPly765/McCTJoWE0tS2528whNJkpnqiBPa1iVoftNrAGt6kter4PNvvoGfMTT1r3/GTGtToyNOGpyVy4YNgQKUI@4oxsjyLFJcC@uojIhHVq2@LPMctFrjIYtamHXwV8kd8wAp305QZ/51VuFzFDctDFcFXzHfeF356SOXOO7IMA/ZV/FeDQgRq5fwb@Q8ELcZf "Haskell – Try It Online")
* Previous answer was complicated and not so good so I decided to try a more expressive approach inspired by @Caagr98 answer, mine is still longer but I feel better now =)
---
# Previous 72 bytes
```
g b n(h:t)
 |h/=n=h:g b n t
 |b>0=g 1n t
 |1>0=h:g 1n t
g b n _=[]
f=g 0
```
[Try it online!](https://tio.run/##ZZHfSsMwFMbv9xSH4kWyHrFd7TqHmS@gIHiZhdFhuw6zONqIN3v3epKOtEPy53zfL18SSJqy@6q07vsD7MGwZm35DC7NgzCiWXsGlsB@k4gDpINJybhFb4fMTkg1qymS9KfyaECcyvPbDs4/9sO2rwZkVDOI4ph1zfcvGB7H0Wi1txw2WxNY69jWwBzey66rPl/G@B20Qli/Z047LsygRsuf7yXLUSrqHJ3KlRtXjcGlSbA4BUiVelAq0GtugTLFBWY4mdXI/HC5AuUTrrDApb9l1MNagdOW/XOpq8rlsvHMx4xud1O@pESSoNNU1S11hCvUlaU3qulftOr/AA "Haskell – Try It Online")
[Answer]
# [PowerShell Core](https://github.com/PowerShell/PowerShell), ~~50~~ 31 bytes
```
param($a,$b)$b|?{$_-$a-or!$o++}
```
-19 bytes thanks to mazzy!
[Try it online!](https://tio.run/##K8gvTy0qzkjNydFNzi9K/a@SZlv9vyCxKDFXQyVRRyVJUyWpxr5aJV5XJVE3v0hRJV9bu/Z/LReXhppKmoKhgYKpjqmOoQEIwVmaCrpZ@Zl5Cuo66lB1RgqGOkY6xjpIJKYicwVzHWRojMEzBNFIGv8DAA "PowerShell Core – Try It Online")
Iterates on the array passed as the second parameter and ignores the duplicate occurrence of the first parameter.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 117 113 93 bytes
```
function x(i,j){var d,e,o=[];for(x in i){e=i[x]==j;!(e&&d)?o.push(i[x]):0;e?d=1:0;}return o;}
```
[Try it online!](https://tio.run/##FchNCoMwEEDhq6QbSWAqFn8WDcGDBBfBjG1EMpKoBMSzp5a3@ODN5jBxDG7dnp4s5jztftwceZa4g1mchwnMAgIpPciJAk/MeebEicrpNCg1ywfHorCip3Ld45f/t3hXEnurXrdXwG0PnpG88kg@0oLlQh@euK5raFvo7poGugE6IWT@AQ "JavaScript (Node.js) – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 12 bytes
```
ＩΦη∨⁻ιθ⁼κ⌕ηι
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM5sbhEwy0zpyS1SCNDR8G/SMM3M6@0WCNTR6FQU0fBtbA0MadYI1tHwS0zLwWkIlMTDKz//4820ok21DHSMdZBImNj/@uW5QAA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
  η             Input list
 Φ              Filtered where
     ι          Current element
    ⁻           Subtract (i.e. does not equal)
      θ         Input integer
   ∨            Logical Or
        κ       Current index
       ⁼        Equals
         ⌕      First index of
           ι    Current element in
          η     Input list
Ｉ               Cast to string
                Implicitly print
```
The last character could also be `θ` of course since the two variables are equal at that point.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~55~~ 52 bytes
Thanks to [xnor](https://codegolf.stackexchange.com/users/20260/xnor) for -3 bytes!
Output is newline-separated.
```
n,l=input()
x=1
for d in l:
 if x|d-n:print d;x*=d-n
```
[Try it online!](https://tio.run/##ZU1Lb8IwDL77V/iWMTlSH5RuTL2tHOHCbcoB2iCiVWkVBVEk/nuxYZrQpljfw/bnDJd47H02NX1rsUKl1OSpq5wfTvFlBmOVwqEP2KLz2C0B3QHHa6v9cgjOR2w/xteK7cRBgPPRdRa34WR5E2O4CCHa0TYoH9zdI6i0rtefWiuQeWOHiPVmVYfQh0doH@zueyoIvwwIFj9ELNLkryIWXL/KQMaDlDLK6QkNlNx@pzcqaSF5sSU9v/yfS4UNzHM5KVgsuJkkJJrZ3AA "Python 2 – Try It Online")
[Answer]
# [K (Kona)](https://github.com/kevinlawler/kona), 21 bytes
```
{y@&(~x=y)+(!#y)=y?x}
```
[Try it online!](https://tio.run/##y9bNzs9L/P8/zaq60kFNo67CtlJTW0NRuVLTttK@ovZ/WrSptYZmLBeI1jEF0QoKptamUKahgbWpAjITSIEQnAXRYGRtqGCkYKyAREIkzK0tFSwUzBXMoIYABcwVkKExBs8QRIMUmxgbWQOxgqkZUNDAQAHEBtKx/wE "K (Kona) – Try It Online")
[Answer]
# [Stacked](https://github.com/ConorOBrien-Foxx/stacked), 28 bytes
```
[@y:0@b[b\y=:b+@b*¬]"!keep]
```
[Try it online!](https://tio.run/##bVBLDoIwFNxzitFNQQMpIKAkmt4DWVDtQomFAC64k6fwYrWlakg0r5k3v3bRfqhOtTgrVbAxp4wX/Djuc75mfPV8lMtFLURbKpYPoh8cx3UAN4EGz/vSZM7xViH9p6CJPl9m08jcDBEhxgxtlplshy0ypJ/XJi/DfOIfFZpt@5s4spCk2qcUhuutUw@FbgRBwKquA5OmLkECAqM70XYgvn@wUsL8wuR6IHquzUWiuQ9wStyqVr0A "Stacked – Try It Online")
## Explanation
```
[@y:0@b[b\y=:b+@b*¬]"!keep]
[                         ]   anonymous function (expects 2 args)
 @y                           save top as y
    0@b                       initialize b = 0
   :   [           ]"!        for each element E in the input array:
        b\                      save the current value of b for later computation
          y= b+@b               b = max(b, y == E)
        b y=:    *¬             not both (old b) and (y == E) are true
                                for y != E, and for the first y == E, this is 1, else 0
                              this generates a mask of 1s and 0s
                      keep    keep only the elements in the input which correspond to a 1
      
```
## Other Solutions
**51 bytes:** `[@y()@z{e:[z e push][z y∈¬*]$!e y=ifelse}[[email protected]](/cdn-cgi/l/email-protection)]`
**41 bytes:** `[@y::inits[:y index\#'1-=]map\y neq+keep]`
**36 bytes:** `[@y:0@b[b\:y=b\max@b y=*¬]map keep]`
**33 bytes:** `[@y:0@b[b\:y=b+@b y=*¬]map keep]`
[Answer]
# PHP 63 Bytes
Number provided in $n, list provided in $a,
```
$p=explode($n,$a,2);echo$p[0].$n.str_replace("$n,", '', $p[1]);
```
# Ungolfed:
```
$p = explode($n,$a,2);
echo $p[0].$n.str_replace("$n,", '', $p[1]);
```
e.g.
```
$n=432;
$a="[432,567,100,432,100]";
$p = explode($n,$a,2);
echo $p[0].$n.str_replace("$n,", '', $p[1]);
```
(I'm unsure if it's ok not to count the input into the bytes, or the opening '<?php' for that matter...)
]