#include <iostream>
#include <iterator>
template<class B,class E> struct range_iter{
B b; E e;
range_iter(B b_,E e_):b(b_),e(e_){}
B& begin(){return b;} E& end(){return e;}
range_iter<B,E>& operator++(){++b; return *this;}
typename std::iterator_traits<B>::reference operator*(){return *b;}
bool has_next(){return b!=e;}
bool is_last(){B b2(b); return ++b2==e;}
};
template<class B,class E> range_iter<B,E> to_ri(B b, E e){return range_iter<B,E>(b,e);}
int main(){
int a[] = {0,10,20,30,40};
for(auto it=to_ri(a+1, a+3); it.has_next(); ++it){std::cout<<*it<<(it.is_last()?"(last)":"")<<std::endl;}
//for(auto e : to_ri(a+1, a+3)){...}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aXRlcmF0b3I+Cgp0ZW1wbGF0ZTxjbGFzcyBCLGNsYXNzIEU+IHN0cnVjdCByYW5nZV9pdGVyewogIEIgYjsgRSBlOwogIHJhbmdlX2l0ZXIoQiBiXyxFIGVfKTpiKGJfKSxlKGVfKXt9CiAgQiYgYmVnaW4oKXtyZXR1cm4gYjt9IEUmIGVuZCgpe3JldHVybiBlO30KICByYW5nZV9pdGVyPEIsRT4mIG9wZXJhdG9yKysoKXsrK2I7IHJldHVybiAqdGhpczt9CiAgdHlwZW5hbWUgc3RkOjppdGVyYXRvcl90cmFpdHM8Qj46OnJlZmVyZW5jZSBvcGVyYXRvciooKXtyZXR1cm4gKmI7fQogIGJvb2wgaGFzX25leHQoKXtyZXR1cm4gYiE9ZTt9CiAgYm9vbCBpc19sYXN0KCl7QiBiMihiKTsgcmV0dXJuICsrYjI9PWU7fQp9Owp0ZW1wbGF0ZTxjbGFzcyBCLGNsYXNzIEU+IHJhbmdlX2l0ZXI8QixFPiB0b19yaShCIGIsIEUgZSl7cmV0dXJuIHJhbmdlX2l0ZXI8QixFPihiLGUpO30KCmludCBtYWluKCl7CiAgaW50IGFbXSA9IHswLDEwLDIwLDMwLDQwfTsKICBmb3IoYXV0byBpdD10b19yaShhKzEsIGErMyk7IGl0Lmhhc19uZXh0KCk7ICsraXQpe3N0ZDo6Y291dDw8Kml0PDwoaXQuaXNfbGFzdCgpPyIobGFzdCkiOiIiKTw8c3RkOjplbmRsO30KLy9mb3IoYXV0byBlIDogdG9fcmkoYSsxLCBhKzMpKXsuLi59CiAgcmV0dXJuIDA7Cn0=