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;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    while(1) {
        int n,m;
        cin>>n>>m;
        if(n+m==0) break;
        vector<int> a(n);
        cin>>a;
        int ans=0;
        REP(i,n) {
            REPF(j,i+1,n) {
                if(a[i]+a[j]<=m) chmax(ans,a[i]+a[j]);
            }
        }
        cout<<(ans==0?"NONE":to_string(ans))<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  vector<int> a(1000);
  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>

#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

vector<int> b(2000006);
signed main() {
  int n, m;
  while (cin >> n >> m) {
    if (n == 0 && m == 0) break;

    vector<int> a(n);
    rep(i, n) cin >> a[i];
    fill(all(b), 0);

    rep(i, n) {
      loop(j, i + 1, n) {
        if (a[i] + a[j] < 2000006) {
          b[a[i] + a[j]] = 1;
        }
      }
    }
    int ans = -INF;
    for (int i = m; i >= 0; i--) {
      if (b[i] == 1) {
        ans = i;
        break;
      }
    }
    cout << (ans == -INF ? "NONE" : to_string(ans)) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
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++)
            cin >> a[i];

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

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

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

C++: #include<cstdio>

int main(){
  int n,m;
  int A[10000];
  int B[10000];
  int max;

  std::scanf("%d %d",&n,&m);
  
  while(!(n == 0 && m == 0)){
    bool flag = 1;
    for(int i = 0;i < n;i++){
      std::scanf("%d",&A[i]);
    }

    max = A[0] + A[1];
    
    if(max < m){
      flag = 0;
    }
  
    for(int i = 0;i < n;i++){
      for(int j = i + 1;j < n;j++){
	if(max < A[i] + A[j] && (A[i] + A[j]) <= m){
	  max = A[i] + A[j];
	  flag = 0;
	}
      }
    }

    if(!flag){
      std::printf("%d\n",max);
    }else{
      std::printf("NONE\n");
    }
    
    std::scanf("%d %d",&n,&m);
  }
  
  return 0;
}