[Question]
  [
## Intro
A friend posed this question today in a slightly different way - "Can a single [Python] command determine the largest of some integers AND that they aren't equal?".
While we didn't find a way to do this within *reasonable* definitions of "a single command", I thought it might be a fun problem to golf.
## ¬†Challenge
"*Return the largest of a list of integers if-and-only-if they are not all equal.*"
More specifically:
Given a string containing only a comma-separated list of integers:
* If they are all equal, return/output nothing
* Else, return/output the largest
## Rules
* The **input** must be a string containing only a comma-separated list of integers
* The **output** must be either nothing (no output of any kind), or else the largest element from the input, represented as it is in the input
Entries may be a full program or just a function, provided you provide some way to test them!
## Assumptions
* Assume input list elements may be more than one digit but no larger than 
( 232 ‚àí 1 )
* Assume the input list has no more than a million elements
* Assume the input will not include negative values
* Assume the input will never be empty
For the avoidance of doubt, the explanation of the challenge given just after "More specifically" shall supersede the statement of the challenge above it ("Return the largest...").
## ¬†Examples
(1) All equal:
```
Input: 1,1
Output:
```
(2) Dissimilar:
```
Input: 1,2
Output: 2
```
(3) Zero!:
```
Input: 0,0,0,0,0,0,0,1,0,0
Output: 1
```
(4) Random:
```
Input: 7,3,8,4,8,3,9,4,6,1,3,7,5
Output: 9
```
(5) Larger numbers, larger list:
```
Input: 627,3894,863,5195,7789,5269,8887,3262,1448,3192
Output: 8887
```
### Additional examples:
(6) All equal, larger list:
```
Input: 7,7,7,7,7,7,7,7,7
Output:
```
(7) All equal, larger list, larger numbers:
```
Input: 61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976,61976
Output:
```
(8) Not equal, larger list, larger numbers:
```
Input: 96185,482754,96185,96185,96185,96185,96185,96185,7,96185,96185,96185,96185,96185,96185,96185,96185,96185,96185,96185,96185,96185,96185,96185,96185,961185,96185,96185,96185
Output: 961185
```
## Scoring
This is `code-golf`, so the code with the shortest number of bytes wins!
  
[Answer]
# [R](https://www.r-project.org/), ~~50~~ 37 bytes
-33 bytes thanks to digEmAll! -13 bytes thanks to rturnbull!
```
x=scan(se=",");if(any(diff(x)))max(x)
```
[Try it online!](https://tio.run/##K/r/v8K2ODkxT6M41VZJR0nTOjNNIzGvUiMlMy1No0JTUzM3sQJI/zfUMdQx1jH8DwA "R ‚Äì Try It Online")
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf), 5 bytes
```
√®‚ñÄs‚ïû‚ïô
```
[Try it online!](https://tio.run/##DcuxDYAwDATAPlP8CnYSxx6HBihAFDAASwSJhpo92CSLBBevl@7163DM07aMvX9vu8691afVu3cCBQKHgghF8kSYt7gLu6o5SkQmyyhFDZnFoKo@sjAoJT@RcfgB "MathGolf ‚Äì Try It Online")
## Explanation
```
√®      Read whole input as int array
 ‚ñÄ     Get unique elements
  s    Sort list
   ‚ïû   Discard from left of array
    ‚ïô  Get maximum of list
```
This works because both the max operator and the discard from left operator don't do anything for empty lists. Well, the max operator removes the list and pushes nothing for empty lists. 
It could be 4 bytes if input could be taken as a list. 
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~26 23~~ 22 bytes
*-1 byte thanks to nwellnhof*
```
{.max if .Set>1}o&EVAL
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvwv1ovN7FCITNNQS84tcTOsDZfzTXM0ee/NVdxYqVCmoaSoY6hkiYyT8cYiW9maGlupjMISCQ3WZoZWpjqmFgYmZua6EA4@ElzolRRSGKVUNL8DwA "Perl 6 ‚Äì Try It Online")
Returns an empty slip if everything is equal.
### Explanation
```
                o&EVAL  # Eval the string to a list of integers
{              }         # Pass to code block
 .max            # Return the max
      if .Set>1  # If the list converted to a set has more than one element
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
·∏ü·πÄE?
```
A full program accepting the input as a command line argument (unquoted) which prints the required output
(Note that it deals with: empty input like , single item input like `7` and multiple item input like `7,8,7` like the spec seems to currently require.)
**[Try it online!](https://tio.run/##y0rNyan8///hjvkPdza42v///99ABxkagkgA "Jelly ‚Äì Try It Online")**
### How?
```
·∏ü·πÄE? - Full program: if one argument is present it is evaluated using Python
     -                 so 7,8,7 -> [7,8,7], while 7 -> 7
·∏ü·πÄE? - Main Link: list or integer OR no argument (in which case an implicit argument of 0)
   ? - if...
  E  - ...condition: all equal? (for any integer E yields 1 since the argument is
     -                           treated as a list like [integer])
·∏ü    - ...then: filter discard (since it's undefined the right argument is implicitly 
     -                          equal to the left; both are treated as lists, so this
     -                          yields an empty list)
 ·πÄ   - ...else: maximum (again an integer is treated as a list)
     - implicit print (Jelly's representation of an empty list is an empty string
     -                 furthermore no newline is printed in either case)
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 12 bytes
Full program. Prompts for string from stdin.
```
{1‚â†‚â¢‚à™‚çµ:‚åà/‚çµ}‚éï
```
[Try it online!](https://tio.run/##zY49CgJBDIX7OYUHeINmfjPeZkGwWXBbEWt3Qe3sxdLeC81F1qw2ziIi2JgwL0zeR5KqqfViXdWrZZ/bXdNvKHfn3F1ye82H2zzv26nUbT6eBr/XWqvJIxpFIKXKhikbM7wmDVoCERYMJ88iSQ0CWUT4EgtGQE7CBQtPySNGTvAmJDCzmCYYkHMyh5IZ7xjlaDalGPAHWp6VArGHYxO9w/PzWeNX1I/61rgD "APL (Dyalog Unicode) ‚Äì Try It Online")
`‚éï`‚ÄÉprompt for and evaluate expression (commas concatenate the numbers into a list)
`{`‚Ä¶`}`‚ÄÉapply the following anonymous lambda (`‚çµ` is the argument; the list of numbers):
‚ÄÉ`1‚â†`‚ÄÉ[if] 1 is different from‚Ä¶
‚ÄÉ`‚â¢`‚ÄÉthe tally of‚Ä¶
‚ÄÉ`‚à™`‚ÄÉthe unique numbers in‚Ä¶
‚ÄÉ`‚çµ`‚ÄÉthe list
‚ÄÉ`:`‚ÄÉthen
‚ÄÉ`‚åà/`‚ÄÉreturn the max across (lit. max reduction)‚Ä¶
‚ÄÉ`‚çµ`‚ÄÉthe list
‚ÄÉ[else: do nothing]
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 6 bytes
```
‚ç™‚åà/~‚åä/
```
[Try it online!](https://tio.run/##zY5NCsJADIX3PUUP8ErN/CbHGSoVoaDQlRuXIlLBc3isucg4Tl2IiAhuJOQ9ki8JCduhWe7CsFk13RDGcd2l1MfDpY7na5yO7T5OpzalpuprAlWzq@ILPAfdtfQ9NBgmp4Zkd5lpeNhCncqcJWOnYUksvGeBVU7AzBkqp0DG5HUS9bj4EvMlEu/wB1q@EUdsYVh5azAXn9V/NfWjvgU3 "APL (Dyalog Classic) ‚Äì Try It Online")
a [train](https://codegolf.stackexchange.com/questions/17665/tips-for-golfing-in-apl/43084#43084) computing the maximum (`‚åà/`) without (`~`) the minium (`‚åä/`) turned into a matrix (`‚ç™`)
if the input contains only one distinct element, `‚åà/~‚åä/` will be empty and `‚ç™` will return a 0√ó1 matrix which renders as nothing
otherwise, `‚åà/~‚åä/` will be a 1-element vector and its `‚ç™` will be a 1x1 matrix (visually indistinguishable from a scalar) that contains the maximum
[Answer]
# [CJam](https://sourceforge.net/p/cjam), ~~16~~ 13 bytes
```
q',/:iL|$1>W>
```
[Try it online!](https://tio.run/##S85KzP3/v1BdR98q06dGxdAu3O7/f2MdKAQA "CJam ‚Äì Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 37 bytes
outputs to stderr (debug on tio).
```
a=input();m=max(a);m>min(a)>exit(`m`)
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P9E2M6@gtERD0zrXNjexQiMRyLDLzcwDMuxSKzJLNBJyEzT//7c0M7Qw1TGxMDI3NdGBcPCT5kSpopDEKgEA "Python 2 ‚Äì Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), ~~42~~ 41 bytes
```
a=input();print('',max(a))[len(set(a))>1]
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P9E2M6@gtERD07qgKDOvRENdXSc3sUIjUVMzOic1T6M4tQTEtjOM/f//PwA "Python 2 ‚Äì Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), ~~77~~ ~~75~~ 61 bytes
```
f.read.('[':).(++"]")    
f a=[0|any(/=a!!0+0)a]>>show(maximum a)
```
[Try it online!](https://tio.run/##DclBCoJAFADQfacYJXAGf6ajjn8C3XQBl4G5@Jim5BioUUFnb@ptX0/LrR1Ha2iYWM6GaW1nala2ZWfbBXNLl4B7lXcQAfd9t3bFpmOUV@GHpjff5@Q4oR8Kqoti6e9Pbug1mIdhJKxVMoMYdQKoYkgjnUKWoYZUKg2I@E@pJERJghBHWn6bbqTrYnenY1n@AA "Haskell ‚Äì Try It Online")
`('[':).(++"]")` takes a string (e.g. `"1,2,1,3"`) and encloses it in bracket chars (`"[1,2,1,3]"`). Then `read` turns the string into a list of integers (`[1,2,1,3]`). 
The function `f` uses [this tip](https://codegolf.stackexchange.com/a/150792/56433) for a shorter conditional if one of the outcomes is the empty list. `any(/=a!!0+0)a` checks whether the list `a` contains any element that is not equal to its first element `a!!0`. (The `+0` is needed such that `read` knows it has to look for a list of numbers.) If all elements are equal this test results in `False` and the empty string is returned. Otherwise `show(maximum a)`, that is the maximum of the list converted to a string, is returned.
[Answer]
# Red, 81 bytes
```
x: split input","forall x[x/1: load x/1]sort x: unique x if 1 <>length? x[last x]
```
Like the R solution, a huge chunk of the code is handling the input string "1,1,2,44,1". If we can have that as a block, eg: `x: [1 1 2 44 1]`, then we can do it in 41 bytes:
```
sort x: unique x if 1 <>length? x[last x]
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 49/53 bytes
## My original version using `.every()`, 53 bytes
Does a function returning '' count as no output? Sure this can be improved upon...
```
s=>(a=s.split`,`).every(e=>a[0]==e)?'':Math.max(...a)
```
[Try it online!](https://tio.run/##dclBCoMwEADAez@SDcRFr8LqC3xBEVx0Yy2pETdIfX0s3ssc580H67gvWyrWOEnOnpQaYFLULSxpcINFOWQ/QajhZ9kTiW2NqTtOL/zwFxCR7WOMq8YgGOIMHkzlbsb@m/JXOV8 "JavaScript (Node.js) ‚Äì Try It Online")
---
## Improved version using `Set()` by [Shaggy](https://codegolf.stackexchange.com/users/58974/shaggy), 49 bytes
```
s=>new Set(a=s.split`,`).size>1?Math.max(...a):``
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@7/Y1i4vtVwhOLVEI9G2WK@4ICezJEEnQVOvOLMq1c7Q3jexJEMvN7FCQ09PL1HTKiHh/38A "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# [Neim](https://github.com/okx-code/Neim), 4 bytes
```
ùêêùêéŒûùê†
```
Explanation:
```
  Œû   If
ùêê    all elements are equal
  ùêé  not
      then
   ùê†  get greatest element
```
[Try it online!](https://tio.run/##y0vNzP3//8PcCROAuO/cPCC54P//aDMjcwVjC0sTBQszYwVTQ0tTBXNzC0sFUyMzSwULCwugpJGZkYKhiYmFgrGhpVEsAA "Neim ‚Äì Try It Online")
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 28 bytes
Returns the maximum (a number, which is an 1x1 matrix) or an empty (1x0) matrix.
```
@(a)max(a)(1+all(a(1)==a):1)
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999BI1EzN7ECSGoYaifm5Ggkahhq2tomaloZav635krTiDbQAcJYTRjTMFbzPwA "Octave ‚Äì Try It Online")
[Answer]
# Japt, 16 bytes
This would be 9 if not for the unnecessarily strict input format, 7 if throwing an error counts as outputting nothing.
Assumes the string contains at least 2 integers.
```
q, mn
√¢ √ä√â?Urw:P
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.6&code=cSwgbW4K4iDKyT9Vcnc6UA==&input=IjgsOCI=)
[Answer]
# Common Lisp, 102 bytes
```
(lambda(x &aux(c(read-from-string(concatenate'string"#.`("x")"))))(or(apply'= c)(princ(apply'max c))))
```
[Try it online!](https://tio.run/##LcrbCoMwEIThV5Et1AlEoe1136XrakXIiagQnz4u6A9z8zHiljVVVDj2w8gozZP3AkGeeOz@Ofpu3fISZkgMwtsUdO1F9Oh/oEKGjIaYwSm5o/02YpD0ITd4LkpapZd92w@ZegI)
The size is mainly due to inputting the data; with input as a regular list, the length reduces to 46 bytes:
```
(lambda(x)(or(apply'= x)(princ(apply'max x))))
```
[Answer]
# [K4](http://kx.com/download), 38 35 bytes
```
{$[1=#:t:?:(7h$","\:x)-48;;*:t@>t]}
```
**Test Cases:**
```
q)k){$[1=#:t:?:(7h$","\:x)-48;;*:t@>t]}"1,2,4,4"
,4
q)k){$[1=#:t:?:(7h$","\:x)-48;;*:t@>t]}"4,4,4,4"
q)
q)k){$[1=#:t:?:(7h$","\:x)-48;;*:t@>t]}"7,3,8,4,8,3,9,4,6,1,3,7,5"
,9
q)k){$[1=#:t:?:(7h$","\:x)-48;;*:t@>t]}"7,7,7,7,7,7,7,7,7,7,7,7,7"
q)
```
I'm not very fluent in any of the k variants available on TiO, so no online example available, I'll try to come up with one though
**Explanation**
If you're wondering why certain operations are performed before others, K4 does not have operator precedence, it instead interprets from right to left (though you can use parentheses for precedence). Expressions seperated by semicolons.
```
   $[expr;`True;`False] is the conditional format
{$[1=#:t:?:(7h$","\:x)-48;;*:t@>t]}
               ","\:x                 //split string on commas
            7h$                       //cast strings to long
                      -48             //they'll be from ascii format, so compensate
         ?:                           //get distinct list      
       t:                             //set list to variable t        
     #:                               //get count of t
   1=                                 //check if count t = 1
                         ;;           //return nothing if true
                             t@>t  //if false, sort t descending
                           *:         //return first value
```
Can probably be golfed down more, not a fan of having to use that makeshift max function at the end.
EDIT: If the commas in output are a problem, it can be fixed with two more bytes:
```
q)k){$[1=#:t:?:(7h$","\:x)-48;;*:,/t@>t]}"1,2,4,4"
4
                                 ,/                 //joins the single element lists into one
```
Taking the total to 40 37, but the comma before the number simply means that it's a single element list as opposed to an atom.
[Answer]
## PHP (<=5.6) ~~64~~ 74 bytes
```
 echo array_count_values($a=split(',',$argn))[$m=max($a)]==count($a)?'':$m;
```
Run as pipe with `-nR` or test it [online](http://sandbox.onlinephpfunctions.com/code/8dd641d7b372b891909904c4dba616ba0b9a8498)
`split` was removed in PHP7, but as I had to add 10 to fix a few issues, it was worth using instead of `explode` which is roughly equivalent in this case.
[Answer]
# [Japt](https://github.com/ETHproductions/japt) `-hF`, 8 bytes
```
q, √ºn √Öc
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.6&code=cSwg/G4gxWM=&input=IjEsMiIKCi1oRgo=)
`-3` bytes if the input could be taken as an array.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~9~~ 8 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
',¬°Zs√ãi√µ
```
-1 byte thanks to *@Cowabunghole*.
[Try it online](https://tio.run/##yy9OTMpM/f9fXefQwqjiw92Zh7f@/29maGlupkNHEgA) or [verify all test cases](https://tio.run/##zYwxCgJBDEX7OcViY/MLk5nJJNXew07BYiuLBWFBWxs7b@AhvIB7Ey8yRmxERAQbCXkheUnW/WLZrep2M7ST5ro/NpN2qFNcTvN@PHTjue5QCRQIHGZ4DrozFEQokmeEeRWfRxTkIOxOzZVEZLKMUtSQWQyq6pKFQSn5KRn7p5cIQlYEf8BgQpqRlEtOeDSfWb7a@pFvxQ0).
**Explanation:**
```
',¬°        '# Split the (implicit) input by ","
   Z        # Push the maximum (without popping the list)
    s       # Swap so the list is at the top of the stack again
     √ãi     # If all elements are equal:
       √µ    #  Push an empty string ""
            # (Implicitly output the top of the stack to STDOUT as result)
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~45~~ 49 bytes
*+4 bytes thanks Veskah*
```
($l=$args-split','|sort{+$_}-u)[-1]|?{$l.count-1}
```
[Try it online!](https://tio.run/##TY5BCsIwFET3OcUnfDXBRJouhaIH8AYiRWrUQmxrkqKQ9uyxVKvObubNwDT1Q1t31cZEPEMGITI0GR7txUnXmNIvxKJztfVhiXkvW76X6tBtAppVUbeVl6qPPSFbRmCQYFQJRYH/XEoFpH9eJWOkEk44dDCDMDKs2tuudF4A6mejC69PwxvM39Bq1xo/BPPh5FQdEUX2oVLfv1O@njaU9PEF "PowerShell ‚Äì Try It Online")
Less golfed:
```
$list=$args-split','|sort{+$_}-unuqie
$max=$list[-1]
$max|?{$list.count-1}
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 5 bytes
```
‚âà[¬§|G
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLiiYhbwqR8RyIsIiIsIjYyNywzODk0LDg2Myw1MTk1LDc3ODksNTI2OSw4ODg3LDMyNjIsMTQ0OCwzMTkyIl0=)
```
‚âà[    # If all same 
  ¬§   # ""
   |G # Else max
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes
```
·πÄ·∏ü·πÇ
```
[Try it online!](https://tio.run/##zZE9CgIxEIWvYiu8wpkk83MUkS1tZC9gJzYew2u4tSfJSeJktxEREWxkmPeYfJNHIIf9OB5bq9Op3q51Orf7Zb1tbUegAasw7rbBc1HXfqxIMOToBA@XQAmK0qFwYPOgklDIC1TNUVgcZhaQhUE5x21yXvJeas4hV8EfaH@MC1lBNtaSsQyfVb/a@lHfgvn7hgc "Jelly ‚Äì Try It Online")
TIO link uses function I/O for the sake of having a test harness, but [it works just fine with a plain comma-separated list](https://tio.run/##y0rNyan8///hzoaHO@Y/3Nn0//9/cx1jHQsdEyA21rEE0mY6hkCWuY4pAA). I'd prefer to let a challenge like this stay dead, but if it's been bumped anyways...
```
·πÄ      The maximum,
 ·∏ü     unless it's equal to
  ·πÇ    the minimum.
```
[Answer]
# [Python 2](https://docs.python.org/2/), 44 bytes
```
k=eval(input())
if~-len(set(k)):print max(k)
```
[Try it online!](https://tio.run/##zY7PTsMwDMbPy1PkllYz0pI2/zb1WK5ceICVErSoXVtlGXQXXr243QUhhEBcJis/x/n8OR4u8dB3Yqr7Z0cLyhibmsK9Vm3iu@EckzQl/uX9rnVdcnIxadJ0OwTfRXqsRqwmNBDiiw15O/jW0cdwdluyiuGCXPl1wXf02s/KsToO2MLWe79H0Y2uTuZvU4L32g2Rlg/3ZQh9mL1PwVUNIcv8v2y0WCbGgTOCFMgNfA4@E181ZGAgx5OBxaxQyUCDRE0JVI1FUWUguZWgtbEghbJgjEFRKAE8z9HMrVimfYl5CrdawQ0Qd7GKGwm5EVrmcC1@pv5V1z/5rcCmDw "Python 2 ‚Äì Try It Online")
[Answer]
# [Ohm v2](https://github.com/nickbclifford/Ohm), 9 bytes
```
Ul1E?Oq¬ø‚Üë
```
[Try it online!](https://tio.run/##y8/INfr/PzTH0NXev/DQ/kdtE///jzbSAcLY/wA "Ohm v2 ‚Äì Try It Online")
Explanation:
```
Ul1E?Oq¬ø‚Üë
U         Uniquify input
 l        Get length
  1E      Push whether length is equak to 1
    ?Oq   If so immediately quit
       ¬ø‚Üë Else print maximum
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 15 bytes
```
‚âîÔº©‚™™Ôº≥,Œ∏¬ø‚Ä∫‚åàŒ∏‚åäŒ∏Ôº©‚åàŒ∏
```
[Try it online!](https://tio.run/##S85ILErOT8z5/9@xuDgzPU/DObG4RCO4ICezRMMzr6C0JLikKDMvXUNTR0FJR0kTSBVqWnNlpilouBelJpakFmn4JlZk5pbmahQC5Xwz86BsTU2FAKDGEoh5CDWamtb//5vroMH/umU5AA "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Explanation:
```
‚âîÔº©‚™™Ôº≥,Œ∏
```
Split the input on commas and cast each value to integer.
```
¬ø‚Ä∫‚åàŒ∏‚åäŒ∏
```
Test whether the maximum value is greater than the minimum value.
```
Ôº©‚åàŒ∏
```
If so then cast the maximum value to string and print.
[Answer]
# Mathematica, 43 bytes
```
If[!Equal@@#,Max@#]&@@#~ImportString~"CSV"&
```
Pure function. Takes a comma-separated string as input and returns either a number or `Null`. I believe this is valid, as `Null` is not graphically displayed:
![](https://i.stack.imgur.com/idnDr.png)
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 91 bytes
```
M(s)char*s;{long m=atol(s),o,l=0;for(;s=strchr(s,44);o<0?m-=o:0)l|=o=m-atol(++s);s=l?m:-1;}
```
[Try it online!](https://tio.run/##pY9tS8MwEMdfu08RMoTEXaHpU5LWMPZigugQNn3nm1LbbdCH0RQU5r66XTa7YUVEkCN3ubvf/7hLrGWStO2MaJqs4vpKR9u8KpeoUHFT5aYKFeTKjrKqJpFWuqmTVU00eB6Nqmt7XFiqCm2av6tKFdZRMxppatB8XIQWi3bt8CXN1mWKJovFdP5I0rcNRZt6XTYZwROt07pBlzpEeGg6@LnEgMxnjB/ucIhvJrf3T/MppoMiXpeEbgcX3RiLIaXQjGAGDFManRvOue706ifehq/GDr7HyY7j4IIAzzwXpImBYV3g4PdoIQTvBIFjJEIaReCCz6QPnAsJvhNIOGDgOoEDzPPMRCb7y52v4fDNjthptYAx4XekSYQPnnC478Fn8rvnf6L@6X9sHG/YtR9JlsdL3Vqvew "C (gcc) ‚Äì Try It Online")
### Degolf
```
M(s)char*s;{
    long m=atol(s),o,l=0; // Read the first integer from string
    for(;s=strchr(s,44); // Advance pointer to next ','
           o<0?m-=o:0) // End of loop: if difference <0, deduct from max, increasing it to new max.
        l|=o=m-atol(++s); // Read next number, and subtract it from current max. 
                          // Bitwise-OR the difference into the l-variable
    s=l?m:-1; // End of function: if l is non-zero, there were at least two different values.
              // Return -1 if l is zero, otherwise the max value.
}
```
[Answer]
# XPath 3.1, 54 bytes
with the input string as the context item:
```
let$t:=tokenize(.,',')!xs:int(.)return max($t)[$t!=$t]
```
Could be reduced by one character if you allow the context to bind a shorter prefix than "xs" to the XML Schema namespace.
Explanation: takes the input string, tokenizes on "," separator, applies `xs:int()` to each token to convert to an integer, computes the max of the sequence, outputs the max provided the predicate `$t!=$t` is true. If A and B are sequences, then `A!=B` is true iff there is a pair of items (a from A, b from B) such that `a!=b`.
If the input can be supplied as a sequence of integers $s rather than a comma-separated string then the solution reduces to
```
max($s)[$s!=$s]
```
(15 bytes - which might well be the shortest solution in a language that isn't purpose-designed for brevity)
**NOTE**: this doesn't satisfy the requirement "represented as it is in the input" - if there's an integer with leading zeroes or a plus sign in the input, these will be lost. I suspect that's true of many other solutions as well.
[Answer]
# Pyth, 7 bytes
```
Itl{QeS
```
[Try it online!](https://pyth.herokuapp.com/?code=Itl%7BQeS&input=1%2C3&debug=0)  
[All test cases (slightly different code for better output formatting)](https://pyth.herokuapp.com/?code=Itl%7BQpeS&test_suite=1&test_suite_input=1%2C1%0A1%2C2%0A0%2C0%2C0%2C0%2C0%2C0%2C0%2C1%2C0%2C0%0A7%2C3%2C8%2C4%2C8%2C3%2C9%2C4%2C6%2C1%2C3%2C7%2C5%0A627%2C3894%2C863%2C5195%2C7789%2C5269%2C8887%2C3262%2C1448%2C3192%0A7%2C7%2C7%2C7%2C7%2C7%2C7%2C7%2C7%0A61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%2C61976%0A96185%2C482754%2C96185%2C96185%2C96185%2C96185%2C96185%2C96185%2C7%2C96185%2C96185%2C96185%2C96185%2C96185%2C96185%2C96185%2C96185%2C96185%2C96185%2C96185%2C96185%2C96185%2C96185%2C96185%2C96185%2C961185%2C96185%2C96185%2C96185&debug=0)
As Pyth is based on Python, user input is always interpreted as a string, which then may be passed through `eval()`. All Pyth programs automatically run `Q=eval(input())` as their first instruction.
Explanation:
```
Itl{QeS  | Full code
Itl{QeSQ | with implicit variables filled
---------+-------------------------------
I        | If
 t       | one less than
  l      | the length of
   {Q    | the deduplicated input
         | is truthy (!=0),
         | print
     e   | the last element of
      SQ | the sorted input
```
]