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 <iostream>
#include <vector>

using namespace std;

int main(void) {
	int N,M;
	while (cin >> N >> M,N,M) {
		int res = -1;
		vector<int> data(N);
		for (int i = 0; i < N; ++i) {
			cin >> data[i];
		}
		for (int i = 0; i < N-1; ++i) {
			for (int j = i+1; j < N; ++j) {
				if (data[i]+data[j] <= M) {
					res = max(data[i]+data[j],res);
				}
			}
		}
		if (res < 0) {
			cout << "NONE" << endl;
		}
		else {
			cout << res << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>

int main(){
    int n,m;
    int tmp;
    int ans;
    bool flag;
    std::vector<int> p;
    std::cin >> n;
    std::cin >> m;

    while(n!=0 && m!=0){
        ans =-1;
        flag = false;
        for(int i=0;i<n;i++){
            std::cin >> tmp;
            p.push_back(tmp);
        }
        std::sort(p.begin(),p.end());
        for(int i=n-1;i>0;i--){
            for(int j=i-1;j>=0;j--){
                if(p[i]+p[j] <= m){
                    if(p[i] + p[j] > ans){
                        ans = p[i] + p[j];
                        flag = true;
                        break;
                    }
                }
            }
            if(flag){
                break;
            }
        }
        if(ans==-1){
            std::cout << "NONE\n";
        }else{
            std::cout << ans <<"\n";
        }
        std::cin >> n;
        std::cin >> m;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,b) for (int i = a; i < b; i++)
#define REP(i,n) rep(i,0,n)
using namespace std;

int main() {
  int n,m;
  while (cin >> n >> m, n) {
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    int ans = -1;
    REP(i,n) rep(j,i+1,n) {
      int tmp = a[i]+a[j];
      if (tmp > m) continue;
      ans = max(ans,tmp);
    }
    if (ans < 0) cout << "NONE" << endl;
    else cout << ans << endl;
  }
}

C++: // g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};
int main(){
	int n,m;
	while(cin>>n>>m,n){
		vi in(n);rep(i,n)cin>>in[i];
		int out=-1;
		rep(i,n)loop(j,i+1,n)if(in[i]+in[j]<=m)out=max(out,in[i]+in[j]);
		if(out+1)cout<<out<<endl;
		cout<<"NONE"<<endl;
	}
}

C++: #include<stdio.h>

int main()
{
	int n=1,m=1;
	int obj[1000],max,min,temp=0;
	while(1)
	{
		max=0;
		min=1000000;
		
		scanf("%d",&n);
		scanf("%d",&m);
		
		if(n==0 && m==0) break;
		
		for(int i=0;i<n;i++)
		{
			scanf("%d",&obj[i]);
		}
		//printf("%d %d\n",n,m);
		for(int i=0;i<n;i++)
		{
			for(int t=i+1;t<n;t++)
			{
				temp=obj[i]+obj[t];
				if(temp>max && temp<=m) max=temp;
				//printf("%d\n",temp);
				if(temp<min) min=temp;
			}
		}
		if(min>m) printf("NONE\n");
		else printf("%d\n",max);
	}
	
	return 0;
}