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 <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

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

}

C++: #include<iostream>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,a[1001];
int main(){
  while(cin>>n>>m,n){
    int ans=0;
    r(i,n)cin>>a[i];
    r(i,n)r(j,n)if(i!=j)
      if(a[i]+a[j]<=m)ans=max(ans,a[i]+a[j]);
    if(ans)cout<<ans<<endl;
    else cout<<"NONE"<<endl;
  }
}

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

int main() {

    int n,m;

    while(1){

        cin >> n >> m;

        if(n==0 && m==0) break;

        int a[n];

        for(int i=0; i<n; i++){
            scanf(" %d",&a[i]);
        }

        int ans = 0;

        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(i!=j){
                    if(ans < a[i] + a[j] && m >= a[i] + a[j]){
                        ans = a[i] + a[j];
                    }
                }
            }
        }

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

    }

    return 0;
}

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

int main(){
  while(true){
    
    int n,m;
    cin>>n>>m;
    if(n==0&&m==0){
      break;
    }
    vector<int> a(n);
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    int max=0;
    sort(a.begin(),a.end());
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	int price = a[i]+a[j];
	if(price>max && price<=m){
	  max=price;
	}
      }
      
    }
    if(max==0){
      cout<<"NONE"<<endl;
      continue;
    }
    cout<<max<<endl;
  }
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;



signed main(){
    int N, M;
    while( cin >> N >> M, N | M ){
        vector<int> a( N );
        REP( i, N ) cin >> a[i];

        int ans = 0;
        REP( i, N - 1 ){
            FOR( j, i + 1, N ){
                if( a[i] + a[j] <= M ){
                    chmax( ans, a[i] + a[j] );
                }
            }
        }
        if( ans ) cout << ans << endl;
        else cout << "NONE" << endl;
    }
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  vector<int> a;
  int n,m,b,max=0;
  while(n!=0 && m!=0){
    max=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
      cin>>b;
      a[i]=b;
    }
  
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
	if(j!=k){
	  if(max<a[j]+a[k] && a[j]+a[k]<=m){
	    max=a[j]+a[k];
	  }
	}
      }
    }
    if(max==0 && n!=0&&m!=0){
      cout<<"NONE"<<endl;
    }else if(n!=0&&m!=0){
      cout<<max<<endl;
    }
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,m;
int a[1010];

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

C++: //あるごりずむ 1616
#include<iostream>
using namespace std;

int main(){
  while(true){
    int n,m;
    cin>>n>>m;
    if(n==0 && m==0)break;

    int a[1000];
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    int sum=-1;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        int p=a[i]+a[j];
        if(p<=m && p>sum){
          sum=p;
        }
      }
    }
    if(sum!=-1){
      cout<<sum<<endl;
    }else{
      cout<<"NONE"<<endl;
    }
  }
  return 0;
}