Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n, m := io.NextInt(), io.NextInt()
		if n == 0 {
			break
		}
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = io.NextInt()
		}
		ans := 0
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				if a[i]+a[j] <= m {
					ans = intMax(a[i]+a[j], ans)
				}
			}
		}
		if ans == 0 {
			io.Println("NONE")
		} else {
			io.Println(ans)
		}
	}
}

func intMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

Python: 
while True:
    (n,m) = map(int,input().split())
    if n == 0 and m == 0:
        break
    iss = list(map(int, input().split()))
    best = max([ (iss[i] + iss[j] if not ( i == j) and iss[i] + iss[j] <= m else -1) for i in range(0,n) for j in range(0,n) ])
    if(best < 0):
        print("NONE")
    else:
        print(best)

Python: n, x = map(int, input().split())

A=[0 for i in range(n)]
A=input().split()

max=(int)(A[0])+(int)(A[1])

for i in range(len(A)-1):
	for j in range(i+1, len(A)):
		if max<(int)(A[i])+(int)(A[j]) and (int)(A[i])+(int)(A[j])<=x:
			max=(int)(A[i])+(int)(A[j])

print(max)

Python: while 1:
  n,m= map(int, input().split())
  if n==0 and m==0:
    break
  A = list(map(int, input().split()))
  B = []
  for i in range(n):
    for j in range(1+i,n):
      b = A[i]+A[j]
      B.append(b)
  #print(B)

  B = sorted(B, reverse=1)
  #print(B)
  B = [x for x in B if x <= m]
  print(B[0] if len(B) > 0 else "NONE")

Python: A=[0 for i in range(2)]
A=input().split()
n=int(A[0])
m=int(A[1])


max=[]
k=0
while n>0 and m>0:
    B=[0 for i in range(n)]
    B=input().split()
    for i in range(n):
        B[i]=int(B[i])
    ma=0
    for i in range(n):
        for j in range(i+1,n):  
            x=0 
            x=B[i]+B[j]
            if ma<x and x<=m:
                ma=x
    max.append(ma)
    A=input().split()
    n=int(A[0])
    m=int(A[1])
    k+=1
for i in range(k):
    if max[i]>0:
        print(max[i])
    else:
        print("NONE")

Python: # Taro's Shopping
while True:
  n, m = map(int, input().split())
  if n+m == 0:
    break
  a = sorted(list(map(int, input().split())))
  ans = 0
  pos = n-1
  for i in range(n):
    while pos>i and a[i]+a[pos]>m:
      pos -= 1
    if pos<=i:
      break
    ans = max(ans , a[i]+a[pos])
  print(ans if ans>0 else 'NONE')

Python: while True:
    t = 0
    n,m = map(int,input().split())
    if n != 0:
        a = list(map(int,input().split()))
        a.sort(reverse=True)
        for i in range(n - 1):
            k = a[i]
            for j in range(n - i - 1):
                if k + a[i+j+1] <= m:
                    if k + a[i+j+1] >= t:
                        t = k + a[i+j+1]
                    break
        if t == 0:
            print("NONE")
        else:
            print(t)
    else:
        break

Python: while(True):
    max=0
    b=list(map(int,input().split()))
    n=b[0]
    m=b[1]
    if(n == 0 and m == 0):
        break
    a=list(map(int,input().split()))
    for i in range(n):
        for j in range(i+1,n):
            sum=a[i]+a[j]
            if(sum>max and sum<m):
                max=sum
    if m==0:
        print("NONE")
    else:
        print(max)

Python: A=[0 for i in range(2)]
A=input().split()
n=int(A[0])
m=int(A[1])
max=[]
k=0
while n>0 and m>0:
    B=[0 for i in range(n)]
    B=input().split()
    for i in range(n):
        B[i]=int(B[i])
    ma=0
    for i in range(n-1):
        for j in range(i,n):   
            x=B[i]+B[j]
            if ma<x and x<=m:
                ma=x
    max.append(ma)
    A=input().split()
    n=int(A[0])
    m=int(A[1])
    k+=1
for i in range(k):
    if max[i]>0:
        print(max[i])
    else:
        print("NONE")

Python: st = []
while 1:
    n,m = list(map(int, input().split()))
    max = -1
    if n==0:
        break
    
    a = list(map(int, input().split()))
    
    for i in range(len(a)):
        for j in range(i+1,len(a)):
            sum = a[i]+a[j]
            if sum<=m:
                if sum>max:
                    max = sum
    
    if max==-1:
        st.append("NONE")
    else:
        st.append(max)
            
for i in range(len(st)):
    print(st[i])

Python: #16D8102008K Taro'sShopping Yagyu Hazuki
s=[]
cnt=0
while 1:
    n,m=map(int,input().split())

    if n==0 and m==0:
        break
    a=list(int(i) for i in input().split())
    max=0

    for i in range(n):
     for j in range(1,n-1):
        c=a[i]+a[j]
        if max<=c and c<=m:
            max=c    
    if max==0:
        s.append(0)
    else: 
        s.append(max)
    a=[0]
    cnt=cnt+1

for i in range(cnt):
    if s[i]==0:
        print("none")
    else:
        print(s[i])
        
"""
3 45      
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
40
10
99
none
20
"""

Python: while True:
    (n, m) = tuple(map(int, input().split()))
    if n == 0:
        break
    arr = list(map(int, input().split()))
    arr.sort()
    
    res = -1
    for i, e in enumerate(arr[:-1]):
        d = i + 1
        if e + arr[i + 1] > m:
            break
        u = n
        while u - d > 1:
            medi = int((u + d) / 2)
            if e + arr[medi] > m:
                u = medi
            else:
                d = medi
        res = max(res, e + arr[d])
    if res < 0:
        print("NONE")
    else:
        print(res)

Python: while True:
    n, m = list(map(int, input().split()))
    if n == 0 and m == 0:
        break
    a = [int(i) for i in input().split()]
    total = []
    i = 0
    for i in range(n-1):
        for j in range(i+1, n):
            if a[i] + a[j] <= m:
                total.append(a[i] + a[j])

    if len(total) > 0:
        print(max(total))
    else:
        print("NONE")

Python: import itertools
def main(n,m):
    a = list(map(int, input().split()))
    select = list(itertools.combinations(range(n), 2))
    ans = 0
    for x,y in select:
        if ans < a[x] + a[y] <= m:
            ans = a[x] + a[y]
    if ans == 0:
        print("NONE")
    else:
        print(ans)
    return 1
while 1:
    n, m = map(int, input().split())
    if n == m == 0:
        break
    main(n,m)