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)
}

C++: #include <bits/stdc++.h>
using namespace std;

int main ()
{
    while (1)
    {
        int n, m;
        std::cin >> n >> m;
        
        if (n == 0 and m == 0) break;
        
        int a[1100];
        for (int i = 0; i < n; i++) 
        {
            std::cin >> a[i];
        }
        
        int max = 0;
        for (int i = 0; i < n-1; i++) 
        {
            for (int j = i+1; j < n; j++) 
            {
                int temp;
                temp = a[i] + a[j];
                
                if (temp > max and temp <= m)
                {
                    max = temp;
                }
            }
        }
        
        if (max == 0) std::cout << "NONE" << std::endl;
        else          std::cout << max << std::endl;
    }
    
    return 0;
}

C++: #include <iostream>
using namespace std;

int n, m;
int a[1000];

int main() {
	
	while (cin >> n >> m) {
		if (!n) break;
		for (int i = 0; i < n; i++) cin >> a[i];
		int ans = -1;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (a[i] + a[j] <= m) {
					ans = max(ans, a[i] + a[j]);
				}
			}
		}
		
		if (ans == -1) { cout << "NONE" << endl; }
		else { cout << ans << endl; }
	}
	return 0;
}

C++: /*Problem sennobushige 16D8104015E 18.5.16*/
#include <iostream>


int main(){
  int n=1,max;
  int A[50000],k=0;


  while(n!=0){
    int p=0,tmp;
    std::cin>>n;
    int a[n]={0};
    std::cin>>max;
    if(n==0)break;
    for(int i=0;i<n;i++){
      std::cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	A[k]=a[i]+a[j];
	if(A[k]>=A[k-1]&&A[k]<=max){
	  p++; 
	}
      }
    }
    if(p==0) A[k]=0;

      k++;
    //if(p!=0) std::cout<<sum<<"\n";
    //else std::cout<<"NONE\n";
  }
  for(int i=0;i<k;i++){
    if(A[i]!=0){
      std::cout<<A[i]<<"\n";
    }else{
      std::cout<<"NONE\n";
    }
   
  }



}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,m;
    while(cin>>n>>m,n||m){
        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int ans=-1;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(m>=a[i]+a[j])ans=max(ans,a[i]+a[j]);
            }
        }
        if(ans==-1)cout<<"NONE"<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}

C++: //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1616&lang=jp
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;

int main(void)
{
    ll n, m;
    while (cin >> n >> m, n || m)
    {
        vector<ll> v(n);
        for (int i = 0; i < n; ++i)
            cin >> v[i];

        ll maxV = 0;
        for (int i = 0; i < n; ++i)
        {
            for (int j = i + 1; j < n; ++j)
            {
                if (v[i] + v[j] <= m)
                {
                    maxV = max(maxV, v[i] + v[j]);
                }
            }
        }
        if (maxV != 0)
            cout << maxV << endl;
        else
            cout << "NONE" << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vi a(n);
		int res=-1;
		for(int i=0;i<n;i++) cin>>a[i];
		for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) if(a[i]+a[j]<=m) res=max(res,a[i]+a[j]);
		if(res==-1) cout<<"NONE"<<endl;
		else cout<<res<<endl;
	}
}

C++: #include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
ll inf = 1e18;

ll n, m;
ll a[1010];

int main(){
	while(cin >> n >> m && n > 0 && m > 0){
		ll ans = 0;
		REP(i,0,n){
			cin >> a[i];
		}
		REP(i,0,n){
			REP(j,i+1,n){
				if(a[i] + a[j] <= m){
					ans = max(ans, a[i] + a[j]);
				}
			}
		}
		if(ans > 0) p(ans);
		else p("NONE");
	}

	return 0;
}

C++: //https://onlinejudge.u-aizu.ac.jp/problems/1616

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, m;

    while (cin >> n >> m, n | m) {
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }

        sort(a.begin(), a.end());

        int ans = 0;
        for (int i = 0; i < n and a[i] < m; ++i) {
            for (int j = i + 1; j < n and a[i] + a[j] <= m; ++j) {
                ans = max(ans, a[i] + a[j]);
            }
        }

        if (ans == 0) {
            cout << "NONE" << endl;
        } else {
            cout << ans << endl;
        }
    }
    return 0;
}

/*
 * 愚直に全検索
 * 
 */