import Foundation

var s = readLine()!
if s[s.startIndex] != "A" { print("WA"); exit(0) }
let start = s.index(s.startIndex, offsetBy: 2)
let end = s.index(s.endIndex, offsetBy: -2)
var count = 0
var index: String.Index!
for (i, c) in s[start...end].enumerated() {
  if c == "C" {
    count += 1
    index = s.index(s.startIndex, offsetBy: i + 2)
  }
}
if count != 1 { print("WA"); exit(0) }
else { s.remove(at: index) }
s.removeFirst()
if s.lowercased() != s { print("WA"); exit(0) }
print("AC")


import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

/*************** メインプログラム ***************/

let S = readLine()!.toArray()
var ans = "AC"
var flag = false
for (i, c) in S.enumerate() {
    if i == 0 {
        if c != "A" {
            ans = "WA"
            break
        }
    } else if i == 1 || i == S.count-1 {
        if c == c.uppercased() {
            ans = "WA"
            break
        }
    } else if c == c.uppercased() {
        if c != "C" || flag {
            ans = "WA"
            break
        } else {
            flag = true
        }
    }
}
if flag == false {
    ans = "WA"
}
print(ans)


import Foundation
var s = readLine()!
if s[s.startIndex] != "A" { print("WA"); exit(0) }
let start = s.index(s.startIndex, offsetBy: 2)
let end = s.index(s.endIndex, offsetBy: -2)
var count = 0
for (i, c) in s[start...end].enumerated() {
  if c == "C" {
    count += 1
    s.remove(at: s.index(s.startIndex, offsetBy: i + 2))
  }
}
if count != 1 { print("WA"); exit(0) }
s.removeFirst()
if s.lowercased() != s { print("WA"); exit(0) }
print("AC")


import Foundation

var s = readLine()!
var ans = "AC"
if s[s.startIndex] != "A" { ans = "WA" }
let start = s.index(s.startIndex, offsetBy: 2)
let end = s.index(s.endIndex, offsetBy: -2)
var count = 0
for (i, c) in s[start...end].enumerated() {
  if c == "C" {
    count += 1
    s.remove(at: s.index(s.startIndex, offsetBy: i + 2))
  }
}
s.removeFirst()
if count != 1 { ans = "WA" }
if s.lowercased() != s { ans = "WA" }
print(ans)


import Foundation
var s = readLine()!
var ans = "AC"
if s[s.startIndex] != "A" { ans = "WA" }
let start = s.index(s.startIndex, offsetBy: 2)
let end = s.index(s.endIndex, offsetBy: -2)
var count = 0
for (i, c) in s[start...end].enumerated() {
  if c == "C" {
    count += 1
    s.remove(at: s.index(s.startIndex, offsetBy: i + 2))
  }
}
s.removeFirst()
if count != 1 { ans = "WA" }
if s.lowercased() != s { ans = "WA" }
print(ans)


const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};
const main=()=>{
  let s=ts()
  let q1=false,q2=false,q3=true
  if(s[0]=='A')q1=true
  let c=0
  for(let i=1;i<s.length;i++){
    if(i>=2&&i<=s.length-2&&s[i]=='C')c++
    else if(s[i] === s[i].toUpperCase())q3=false
  }
  if(c===1)q2=true
  to(q1&&q2&&q3?'AC':'WA')
}
main()


const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.trim().split('\n')[0]

const ans = _ => {
  let head,
    cCount = 0,
    lCase = true

  for (let i = 0; i < s.length; i++) {
    if (i === 0) {
      head = s[i] === 'A'
    } else if (i >= 2 && i < s.length - 1) {
      if (s[i] === 'C') cCount++
    } else {
      lCase = lCase && isLowerCase(s[i])
    }
  }

  const mid = cCount === 1

  return head && mid && lCase ? 'AC' : 'WA'
}

const isLowerCase = str => str === str.toLowerCase()

console.log(ans())


declare var require: (x: string) => any;

function validate(s: string) {
  if(s[0] != 'A') return false;

  let appeared = false;
  for(var i = 1; i < s.length; i++) {
    if (s[i] === s[i].toUpperCase()){
      if(i==1 || i == s.length-1) return false;
      if(appeared) return false;
      appeared = true;
    }
  }
  return appeared;
}

function Main(input: string[]) {
  console.log(validate(input[0]) ? 'AC' : 'WA');
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'));


const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.trim().split('\n')[0]

const ans = _ => {
  let head, mid = false, lCase = true

  for (let i = 0; i < s.length; i++) {
    if (i === 0) {
      head = s[i] === 'A'
    } else if (i >= 2 && i < s.length - 1) {
      mid = mid ? s[i] !== 'C' : s[i] === 'C'
    } else {
      lCase = lCase && isLowerCase(s[i])
    }
  }

  return head && mid && lCase ? 'AC' : 'WA'
}

const isLowerCase = str => str === str.toLowerCase()

console.log(ans())


const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.trim().split('\n')[0]

const ans = _ => {
  let head, mid = false, lCase = true

  for (let i = 0; i < s.length; i++) {
    if (i === 0) {
      head = s[i] === 'A'
    } else if (i >= 2 && i < s.length - 2) {
      mid = mid ? s[i] !== 'C' : s[i] === 'C'
    } else {
      lCase = lCase && isLowerCase(s[i])
    }
  }

  return head && mid && lCase ? 'AC' : 'WA'
}

const isLowerCase = str => str === str.toLowerCase()

console.log(ans())


const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.trim().split('\n')[0]

const ans = _ => {
  let head, mid = false, lCase = true

  for (let i = 0; i < s.length; i++) {
    if (i === 0) {
      head = s[i] === 'A'
    } else if (i >= 2 && i < s.length - 2) {
      mid = !mid && s[i] === 'C'
    } else {
      lCase = lCase && isLowerCase(s[i])
    }
  }

  return head && mid && lCase ? 'AC' : 'WA'
}

const isLowerCase = str => str === str.toLowerCase()

console.log(ans())


import sys

def main():
  n, *lst = map(int, sys.stdin.read().split())
  max1 = max(lst)
  idx = lst.index(max1)
  max2 = max(lst[:idx] + lst[idx+1:])
  print('\n'.join(str(max1) if j != max1 else str(max2) for j in lst))

if __name__ == '__main__':
  main()


import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=[0]*N
    Mi=-1
    M=0
    for i in range(N):
        A[i]=I()
        if A[i]>M:
            Mi=i
            M=A[i]

    A[Mi]=0

    for i in range(N):
        if i!=Mi:
            print(M)
        else:
            print(max(A))

main()


n,*a=map(int,open(0).read().split())
p=max(a)
k=a.index(p)#かり
s=max(a[:k]+a[k+1:])#second
print('\n'.join(str(p) if i!=k else str(s) for i in range(n)))


n = int(input())
a = []
for _ in range(n):a.append(int(input()))

for i in range(n):
    tmp = a[i]
    a[i] = 0
    print(max(a))
    a[i] = tmp


n = int(input())
a = [int(input()) for i in range(n)]
if len(set(a)) == 1:
    for i in range(n):
        print(sorted(set(a))[-1])
    exit()
x = sorted(set(a))[-1]
y = sorted(set(a))[-2]
for i in range(n):
    if a[i] != x:
        print(x)
    else:
        print(y)


import java.io.*;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        try (BufferedScanner in = new BufferedScanner();
             PrintWriter out = new PrintWriter(System.out)) {
            //
            int n = in.nextInt();
            int[] a = new int[n];
            int max1 = 0, max2 = 0;

            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
                if (max1 <= a[i]) {
                    max2 = max1;
                    max1 = a[i];
                } else if (max2 <= a[i]) {
                    max2 = a[i];
                }
            }

            if (max1 == max2) {
                for (int i = 0; i < n; i++) {
                    out.println(max1);
                }
            } else {
                for (int i = 0; i < n; i++) {
                    if (a[i] != max1) {
                        out.println(max1);
                    } else {
                        out.println(max2);
                    }
                }
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

class BufferedScanner implements Closeable {
    private InputStream in = System.in;
    private int BUFFER_SIZE = 65536;
    private int toBuffers = 0;
    private byte buffer[] = new byte[BUFFER_SIZE];
    private int nextByte = 0;

    boolean isEOF() {
        if (nextByte >= toBuffers) {
            fill();
            if (nextByte >= toBuffers) {
                return true;
            }
        }
        return false;
    }

    private void fill() {
        nextByte = 0;

        try {
            toBuffers = in.read(buffer);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    private int read() {
        if (isEOF()) {
            return -1;
        }
        return buffer[nextByte++];
    }

    String nextLine() {
        if (!hasNext()) {
            return null;
            //throw new NoSuchElementException("EOF");
        }

        StringBuilder result = new StringBuilder();
        int now;
        for (now = read(); isPrintableByte(now) || now == ' '; now = read()) {
            result.append((char) now);
        }

        if (now == '\r') {
            now = read();
        }

        if (now == '\n') {
            read();
            return result.toString();
        }
        throw new IllegalArgumentException("???");
    }

    String next() {
        if (!hasNext()) {
            return null;
            //throw new NoSuchElementException("EOF");
        }

        StringBuilder result = new StringBuilder();
        for (int now = read(); isPrintableByte(now); now = read()) {
            result.append((char) now);
        }

        return result.toString();
    }

    long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException("EOF");
        }

        boolean isMinus;
        int result = 0;
        int now = read();
        if (now == '-') {
            isMinus = true;
            now = read();
        } else if (isNumber(now)) {
            isMinus = false;
        } else {
            throw new NumberFormatException("notNumber");
        }

        for (; isNumber(now); now = read()) {
            result = result * 10 + (now & 15);
        }

        if (!isNumber(now) || now == -1) {
            return isMinus ? -result : result;
        }

        throw new NumberFormatException("notNumber?");
    }

    int nextInt() {
        long result = nextLong();
        if (result > Integer.MAX_VALUE || result < Integer.MIN_VALUE) {
            throw new NoSuchElementException("isLong");
        }
        return (int) result;
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    boolean hasNext() {
        while (!isEOF() && !isPrintableByte(buffer[nextByte])) {
            ++nextByte;
        }
        return !isEOF();
    }

    private static boolean isPrintableByte(int c) {
        return ' ' < c && c <= 126;
    }

    private static boolean isNumber(int n) {
        return n >= '0' && n <= '9';
    }

    @Override
    public void close() throws IOException {
        in.close();
    }
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main{
    public static void main(String[] args) {
    	InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        Solve solver = new Solve();
        solver.solve(1, in, out);
        out.close();
    }
    static class Solve {
    	public void solve(int testNumber, InputReader in, OutputWriter out) {
    		int n = in.nextInt();
    		int second;
    		int ind = 0;
    		int first = second = 0;
    		for (int i = 0; i < n ; i ++) {
    			int next = in.nextInt();
    	        if (next > first) {
    	            second = first;
    	            first = next;
    	            ind  = i;
    	        }
    	        else if (next > second && i != ind)
    	            second = next;
    	    }
    		for (int i = 0; i < n ; i ++) {
    			if(i==ind)out.println(second);
    			else out.println(first);
    	    }
    	}
    }

    static class OutputWriter {
	    private final PrintWriter writer;

	    public OutputWriter(OutputStream outputStream) {
	        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	    }

	    public OutputWriter(Writer writer) {
	        this.writer = new PrintWriter(writer);
	    }

	    public void close() {
	        writer.close();
	    }

	    public void println(String string) {
	        writer.println(string);
	    }

	    public void println(int number) {
	        writer.println(number);
	    }

	    public void println(long number) {
	        writer.println(number);
	    }

	    public void println(double number) {
	    	writer.println(number);
	    }

	    public void print(long number) {
	        writer.print(number);
	    }

	    public void print(int number) {
	        writer.print(number);
	    }

	    public void print(String string) {
	        writer.print(string);
	    }

	    public void print(double number) {
	    	writer.print(number);
	    }
	}

	static class InputReader {
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public String nextLine() {
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (b!=10) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author osiruko
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        CExceptionHandling solver = new CExceptionHandling();
        solver.solve(1, in, out);
        out.close();
    }

    static class CExceptionHandling {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int ar[] = in.readIntArray(n);
            int ans[] = new int[n];
            int s = 0;
            int f = 0;

            for (int i = 0; i < n; i++) {
                if (s < ar[i]) {
                    f = s;
                    s = ar[i];
                } else if (f < ar[i]) {
                    f = ar[i];
                }
            }
            for (int i = 0; i < n; i++) {
                if (s == ar[i]) {
                    out.printLine(f);
                } else {
                    out.printLine(s);
                }
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = readInt();
            }
            return array;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }

    }
}


a = []
t = int(input())
s = ""
for i in range(t):
    a.append(int(input()))

for i in range(t):
    b = a[i]
    del a[i]
    print(max(a))
    a.insert(i,b)


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            a.add(tmp);
            max = Math.max(max, tmp);
        }
        for (int i = 0; i < n; i++) {
            int tmp = a.get(i);
            if(max == tmp) {
                a.set(i, 0);
                int ans = Collections.max(a);
                System.out.println(ans);
                a.set(i, tmp);
            } else {
                System.out.println(max);
            }

        }
    }
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextInt());
        }
        int max = Collections.max(a);
        for (int i = 0; i < n; i++) {
            int tmp = a.get(i);
            if(max == tmp) {
                a.set(i, 0);
                int ans = Collections.max(a);
                System.out.println(ans);
                a.set(i, tmp);
            } else {
                System.out.println(max);
            }

        }
    }
}


//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}
int n;
char c[6];
inline void putsaidai() {
	for (int i = n - 1; i >= 0; i--)* di++ = c[i];
	*di++ = '\n';
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int N = getint();
	int A[200000];

	int saidai = 0;
	int niban = 0;
	rep(i, N) {
		A[i] = getint();
		if (niban < A[i]) {
			niban = A[i];
			if (niban > saidai) swap(niban, saidai);
		}
	}

	int kari = saidai;
	while (kari) {
		*(c + n) = '0' + kari % 10;
		kari /= 10;
		n++;
	}

	if (saidai == niban) {
		rep(i, N) putsaidai();
	}
	else {
		rep(i, N) {
			if (A[i] == saidai) putint(niban);
			else putsaidai();
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}


//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) *di++ = (*(C + i));
	*di++ = '\n';
}
int n;
char c[6];
inline void putsaidai() {
	for (int i = n - 1; i >= 0; i--) *di++ = c[i];
	*di++ = '\n';
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int N = getint();
	int A[200000];

	int saidai = 0;
	int niban = 0;
	rep(i, N) {
		A[i] = getint();
		if (niban < A[i]) {
			niban = A[i];
			if (niban > saidai) swap(niban, saidai);
		}
	}

	int kari = saidai;
	while (kari) {
		*(c + n) = '0' + kari % 10;
		kari /= 10;
		n++;
	}

	rep(i, N) {
		if (A[i] == saidai) putint(niban);
		else putsaidai();
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}


#include <cstdio>
using namespace std;

#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)

const int is = 1 << 14;
char ib[is], *ip = ib + is, it;
inline char getc() {
	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }
	return *ip++;
}
inline int read() {
	int r = 0;
	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
	else while ((it = *ip++) & 16) r = r * 10 + it - '0';
	return r;
}

const int os = 1 << 14;
char ob[os], *op = ob, ot;
inline void putc(const char c) {
	*op++ = c;
	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }
}
// x shoud be greater than or equal to zero
inline void write(int x) {
	char d[6];
	int i = 0;
	while (true) {
		d[i] = x % 10 + 48;
		x /= 10;
		++i;
		if (x <= 0) break;
	}
	while (i--) {
		putc(d[i]);
	}
}

int A[200000];
signed main() {
	int n = read();
	int m0 = 0;
	int m1 = 0;
	REP(i, n) {
		int a = read();
		if (a > m0) {
			m1 = m0;
			m0 = a;
		} else if (a > m1) {
			m1 = a;
		}
		A[i] = a;
	}
	REP(i, n) {
		int a = A[i];
		if (a == m0) {
			write(m1);
		} else {
			write(m0);
		}
		putc('\n');
	}
	fwrite_unlocked(ob, 1, op - ob, stdout);
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <deque>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    //input
    int n; cin >> n;
    vector<int> a(n + 1);
    vector<vector<int>> c(n + 1, vector<int>());
    for(int i = 1; i < n + 1; i++) cin >> a[i];

    //compute
    for(int i = 1; i < n + 1; i++) {
        for(int j = 1; j < n + 1; j++) {
            if(i != j){
                c[i].push_back(a[j]);
            }else{
            }
        }
    }

    for(int i = 0; i < n + 1; i++){
        sort(c[i].rbegin(),c[i].rend());
    }

    //output
    for(int i = 1; i < n + 1; i++){
        cout << c[i][0] << endl;
    }

}


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

int main(){
    int n, a[200000], b[20000];

    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b+n, greater<int>());

    for ( int i = 0; i < n; i++ ) {
        cout << (a[i] == b[0] ? b[1] : b[0] ) << endl;
    }

    return (0);
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> a(n);
    int m = 0, mm = 0; queue<int> mi;
    for(int i=0; i<n; ++i){
        cin >> a[i];
        if(m<a[i]){
            mi.push(i);
            mm = m;
            m = a[i];
        }else if(mm < a[i]){
            mm = a[i];
        }
    }
    for(int i=0; i<n; ++i){
        if(i!=mi.front() || mi.size()>1){cout << m << endl; mi.pop();}
        else{cout << mm << endl;}
    }
    return 0;
}


// AtCoder ABC134: C - Exception Handling
// 2019.8.26 bal4u

#include <stdio.h>

//// 高速入力
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

char *out(char *s, int n) { // 非負整数の表示（出力）
	int i;

	if (!n) { *s = '0', *(s+1) = 0; return s; }
	s[11] = 0, i = 11; while (n) s[--i] = n % 10 + '0', n /= 10;
	return s+i;
}

void outs(char *s) { while (*s) pc(*s++); pc('\n'); }

int a[200005]; int N;

int main()
{
	int i, f, fi, s;
	char t1[15], t2[15], *s1, *s2;

	N = in(); f = s = 0;
	for (i = 0; i < N; i++) {
		a[i] = in();
		if (a[i] > f) s = f, f = a[i], fi = i;
		else if (a[i] > s) s = a[i];
	}
	s1 = out(t1, f), s2 = out(t2, s);

	for (i = 0; i < N; i++) {
		if (i == fi) outs(s2);
		else outs(s1);
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define getchar_unlocked getchar
char input[3000000];
char *p = input;
int ri() {
	int r=0, s=0;
	for(;;){if(*p=='-'){s=1;break;}if(*p<='9'&&*p>='0'){r=*p-'0';break;}p++;}p++;
	for(;;){if(*p<'0'||*p>'9')break;r=r*10+*p-'0';p++;}
	if(s)r=-r;
	return r;
}
char buf[3000000];
char *ptr = buf;
void wi(int n) {
	static char tmp[12];
	char *cur = tmp + 11;
	if (n) {
		while (n) {
			*--cur = n % 10 + '0';
			n /= 10;
		}
	} else *--cur = '0';
	while (*cur) *ptr++ = *cur++;
	*ptr++ = ' ';
}

int main() {
	fread(input, 1, 3000000, stdin);
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	int max = 0, x = 0;
	for (int i = 0; i < n; i++) if (max < a[i]) max = a[i], x = 1; else if (max == a[i]) x++;
	int max2 = 0;
	for (int i = 0; i < n; i++) if (a[i] != max && max2 < a[i]) max2 = a[i];
	for (int i = 0; i < n; i++) {
		if (x == 1 && a[i] == max) wi(max2);
		else wi(max);
	}
	fwrite(buf, 1, ptr - buf, stdout);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define getchar_unlocked getchar
int ri() {
	int r=0, c, s=0;
	for(;;){c=getchar_unlocked();if(c=='-'){s=1;break;}if(c<='9'&&c>='0'){r=c-'0';break;}}
	for(;;){c=getchar_unlocked();if(c<'0'||c>'9')break;r=r*10+c-'0';}
	if(s)r=-r;
	return r;
}
char buf[3000000];
char *ptr = buf;
void wi(int n) {
	static char tmp[12];
	char *cur = tmp + 11;
	if (n) {
		while (n) {
			*--cur = n % 10 + '0';
			n /= 10;
		}
	} else *--cur = '0';
	while (*cur) *ptr++ = *cur++;
	*ptr++ = ' ';
}

int main() {
	int n;
	scanf("%d", &n);
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	int max = 0, x = 0;
	for (int i = 0; i < n; i++) if (max < a[i]) max = a[i], x = 1; else if (max == a[i]) x++;
	int max2 = 0;
	for (int i = 0; i < n; i++) if (a[i] != max && max2 < a[i]) max2 = a[i];
	for (int i = 0; i < n; i++) {
		if (x == 1 && a[i] == max) wi(max2);
		else wi(max);
	}
	fwrite(buf, 1, ptr - buf, stdout);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a;
	int i,m=0,m1=0,x=0,y=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(m<a){
			m1=m;
			m=a;
			x=i+1;
		}
		else if(m1<a){
			m1=a;
			y=i+1;
		}
	}
	for(i=1;i<=n;i++){
		if(i==x){
			printf("%d\n",m1);
		}
		else{
			printf("%d\n",m);
		}
	}
	return 0;
}


#include <stdio.h>
int main(void){
  int N;
  int A[2000010];
  int max=0;
  int t;
  int max2=0;
  int i;
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&A[i]);
    if(max<A[i]){
      max=A[i];
      t=i;
    }
  }
  for(i=1;i<=N;i++){
    if((A[i]<max)&&(max2<A[i])){
      max2=A[i];
    }
  }
  if(max2==0){
    max2=max;
  }
  for(i=1;i<=N;i++){
    if(A[i]==max){
      printf("%d\n",max2);
    }
    else{
      printf("%d\n",max);
    }
  }
  return 0;
}


function Main(input) {
  tmp = input.split("\n");

  var length = parseInt(tmp.shift(), 10);
  var max = 0;
  var next_max = 0;
  var max_index = 0;
  var value = 0;

  for (var i = 0; i < tmp.length; i++) {
    // 1つ目に大きい数字と、2つ目に大きい数字を見つける
    value = parseInt(tmp[i], 10);

    if (max < value) {
      next_max = max;
      max = value;
      max_index = i;
    } else if (next_max < value) {
      next_max = value;
    }
  }

  var answer = "";
  for (var x = 0; x < length; x++) {
    if (x == max_index) {
      answer += (next_max + "\n");
    } else {
      answer += (max + "\n");
    }
  }

  console.log('%s', answer.slice(0, -1));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


'use strict'

const INF = 900719925474099;
function mapint(temp){
  return temp.split(' ').map((v)=>parseInt(v));
}

function Main(input){
  let temp = input.trim().split('\n');
  let n = temp[0];
  let a = new Array(n);
  let f = 0;
  let s = 0;

  for(let i=1;i<=n;i++){
    a[i-1] = parseInt(temp[i]);
    if(f<=a[i-1]){
      s = f;
      f = a[i-1];
    }else if(s<a[i-1]){
      s = a[i-1];
    }
  }

  let ans = new Array(n);
  for(let i=0;i<n;i++){
    if(f == a[i]){
      ans[i] = s;
    }else{
      ans[i] = f;
    }
  }
  console.log(ans.join('\n'));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict";
const input = require("fs").readFileSync("/dev/stdin", "utf8");
const inputs = input.trim().split("\n");

const get = (inputs) => {
  const As = inputs.slice(1);

  let max = 1;
  let max2 = 1;
  for (const A of As) {
    const a = +A;
    if (max < a) {
      max = a;
    } else if (max2 < a) {
      max2 = a;
    }
  }

  return As.map(A => +A === max ? max2 : max).join("\n")
}

console.log( get(inputs) );


function Main(input){
    const arr = input.trim().split('\n');
    const N = Number(arr.shift());
    for(let i=0; i<arr.length; i++){
        const box = arr.concat();
        box.splice(i, 1);
        console.log(Math.max.apply(null, box));
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input){
    const arr = input.trim().split('\n');
    const N = Number(arr.shift());
    for(let i=0; i<arr.length; i++){
        const box = arr.concat();
        box.splice(i, 1);
        console.log(String(Math.max.apply(null, box)));
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input){
    const arr = input.split('\n');
    const N = Number(arr.shift());
    for(let i=0; i<arr.length; i++){
        const box = arr.concat(); // 引数なしなら新しい配列が作成される
        box.splice(i, 1);
        console.log(Math.max.apply(null, box));
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const (
	maxBufferSize     = 2000000 // check
	initialBufferSize = 20000
)

func Max(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}

func JoinInt(a []int, sep string) string {
	aStrs := make([]string, len(a))
	for i := 0; i < len(a); i++ {
		aStrs[i] = strconv.Itoa(a[i])
	}
	return strings.Join(aStrs, sep)
}

func solve() {
	sc := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, initialBufferSize)
	sc.Buffer(buffer, maxBufferSize)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	m0 := make([]int, n+1)
	m1 := make([]int, n+1)
	for i := 1; i <= n; i++ {
		m0[i] = Max(m0[i-1], a[i-1])
	}
	for i := n - 1; i >= 0; i-- {
		m1[i] = Max(m1[i+1], a[i])
	}

	ans := make([]int, n)
	for i := 0; i < n; i++ {
		ans[i] = Max(m0[i], m1[i+1])
	}

	buf := JoinInt(ans, "\n")

	fmt.Println(buf)
}

func main() {
	solve()
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	a := make([]int, n)
	max1, max2 := 0, 0
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		if a[i] > max1 {
			max1, max2 = a[i], max1
			continue
		}
		if a[i] > max2 {
			max2 = a[i]
		}
	}

	wr := bufio.NewWriter(os.Stdout)
	for _, v := range a {
		if v == max1 {
			wr.WriteString(strconv.Itoa(max2) + "\n")
		} else {
			wr.WriteString(strconv.Itoa(max1) + "\n")
		}
	}
	wr.Flush()
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	n := scanInt(sc)

	ns := make([]int, n)
	first := 0
	second := 0
	for i := 0; i < n; i++ {
		n := scanInt(sc)
		ns[i] = n

		if first < n {
			second = first
			first = n
		} else if second < n {
			second = n
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for i := 0; i < n; i++ {
		if ns[i] == first {
			fmt.Fprintln(w, second)
		} else {
			fmt.Fprintln(w, first)
		}
	}
	w.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func max(i, j int) int {
	if i > j {
		return i
	} else {
		return j
	}
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	x := make([]int, n)
	y := make([]int, n)

	x[0] = a[0]
	y[n-1] = a[n-1]

	for i := 1; i < n; i++ {
		x[i] = max(x[i-1], a[i])
	}
	for i := n - 2; i >= 0; i-- {
		y[i] = max(y[i+1], a[i])
	}

	fmt.Println(y[1])
	for i := 1; i < n-1; i++ {
		fmt.Println(max(x[i-1], y[i+1]))
	}
	fmt.Println(x[n-1])
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func max(i, j int) int {
	if i > j {
		return i
	} else {
		return j
	}
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	x := make([]int, n)
	y := make([]int, n)

	x[0] = a[0]
	y[n-1] = a[n-1]

	for i := 1; i < n; i++ {
		x[i] = max(x[i-1], a[i])
	}
	for i := n - 2; i >= 0; i-- {
		y[i] = max(y[i+1], a[i])
	}

	fmt.Println(y[1])
	for i := 1; i < n-1; i++ {
		fmt.Println(max(x[i]-1, y[i+1]))
	}
	fmt.Println(x[n-1])
}


package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	sc = initScanner(os.Stdin)
	n := scanInt(sc)
	a := scanIntSlice(sc, n)

	resolve(n, a)
}

func resolve(n int, a []int) {
	var max int
	for i:=0; i<n;i++ {
		max = 0
		for j:=0;j<n;j++ {
			if i == j {
				continue
			}
			if max < a[j] {
				max = a[j]
			}
		}
		fmt.Println(max)
	}
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}


gets
t = ARGF.map(&:to_i)
max2 = max = 0
t.each do |d|
  if(d > max)
    max2 = max
    max = d
    next
  end
  if(d > max2)
    max2 = d
  end
end
t.each do |d|
  if(d==max)
    print "#{max2}\n"
  else
    print "#{max}\n"
  end
end


gets
t = ARGF.map(&:to_i)
max2 = max = 0
t.each do |d|
  if(d > max)
    max2 = max
    max = d
    next
  end
  if(d > max2)
    max2 = d
  end
end
t.each do |d|
  if(d!=max)
    print "#{max}\n"
  else
    print "#{max2}\n"
  end
end


n=gets.to_i
a=Array.new(n,0)
n.times do |i|
    a[i]=gets.to_i
end

a_max=a.max
a_second=a.max(2)[1]
n.times do |i|
    if a[i]==a_max
        puts a_second
    else
        puts a_max
    end
end


n=gets.to_i
s=[]
n.times{|i|
  s[i]=gets.to_i
}
max=s.max(2)
n.times{|i|
  if i==max[0]
    puts max[1]
  else
    puts max[0]
  end
}


n = gets.to_i
array = []
while number = gets
  array << number.chomp.to_i
end
for i in 1..n
  ary = array.delete_at(i-1)
  puts ary.max
end


n = gets.to_i
arr = []
n.times do
  arr.push(gets.to_i)
end
if arr.count(arr.max) != 1
  n.times do
    puts arr.max
  end
else
  arr.freeze
  new_arr = arr.dup
  new_arr.delete(arr.max)
  second = new_arr.max
  arr.each do |num|
    if num == arr.max
      puts second
    else
      puts arr.max
    end
  end
end


use std::cmp::*;
use std::io::*;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

pub fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    let mut a_max0 = 0;
    let mut a_max1 = 0;
    let mut i_max0 = usize::max_value();

    for (i, a) in i.read_iter::<usize>(n).enumerate() {
        if a >= a_max0 {
            a_max1 = a_max0;
            a_max0 = a;
            i_max0 = i;
        } else {
            a_max1 = max(a_max1, a);
        }
    }
    for i in 0..n {
        if i == i_max0 {
            writeln!(o, "{}", a_max1).unwrap();
        } else {
            writeln!(o, "{}", a_max0).unwrap();
        }
    }
}

pub mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        b: Vec<u8>,
    }
    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                b: Vec::new(),
            }
        }
        pub fn read_word(&mut self) -> &[u8] {
            self.b.clear();
            let mut consume = 0;
            loop {
                self.r.consume(consume);
                let b = self.r.fill_buf().unwrap();
                assert!(b.len() != 0);
                if let Some(p) = b.iter().position(|&x| x == b' ' || x == b'\n') {
                    self.b.extend_from_slice(&b[..p]);
                    consume = p + 1;
                    break;
                }
                self.b.extend_from_slice(b);
                consume = b.len();
            }
            self.r.consume(consume);
            &self.b
        }
        pub fn read_word_str(&mut self) -> &str {
            unsafe { std::str::from_utf8_unchecked(self.read_word()) }
        }

        pub fn read_line(&mut self) -> &[u8] {
            self.b.clear();
            self.r.read_until(b'\n', &mut self.b).unwrap();
            if self.b.last() == Some(&b'\n') {
                &self.b[..self.b.len() - 1]
            } else {
                &self.b
            }
        }
        pub fn read_line_str(&mut self) -> &str {
            unsafe { std::str::from_utf8_unchecked(self.read_line()) }
        }

        pub fn read<T: CpIn>(&mut self) -> T {
            T::read_from(self)
        }

        pub fn read_vec<T: CpIn>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read()).collect()
        }
        pub fn read_iter<'a, T: CpIn>(&'a mut self, n: usize) -> CpIter<'a, R, T> {
            CpIter {
                r: self,
                n: n,
                _pd: Default::default(),
            }
        }
    }
    pub struct CpIter<'a, R: BufRead + 'a, T> {
        r: &'a mut CpReader<R>,
        n: usize,
        _pd: std::marker::PhantomData<fn() -> T>,
    }
    impl<'a, R: BufRead, T: CpIn> Iterator for CpIter<'a, R, T> {
        type Item = T;
        fn next(&mut self) -> Option<T> {
            if self.n == 0 {
                None
            } else {
                self.n -= 1;
                Some(self.r.read())
            }
        }
    }

    pub trait CpIn {
        fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self;
    }

    impl CpIn for u64 {
        fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
            read_u64_fast(&mut r.r)
        }
    }
    impl CpIn for i64 {
        fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
            read_i64_fast(&mut r.r)
        }
    }
    impl CpIn for char {
        fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
            let b = r.r.fill_buf().unwrap()[0] as char;
            r.r.consume(1);
            let s = r.r.fill_buf().unwrap()[0];
            assert!(s == b' ' || s == b'\n');
            r.r.consume(1);
            b
        }
    }

    macro_rules! cpin_tuple {
        ($($t:ident),*) => {
            impl<$($t: CpIn),*> CpIn for ($($t),*) {
                fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
                    ($($t::read_from(r)),*)
                }
            }
        };
    }

    macro_rules! cpin_cast {
        ($t_self:ty, $t_read:ty) => {
            impl CpIn for $t_self {
                fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
                    <$t_read>::read_from(r) as $t_self
                }
            }
        };
    }
    macro_rules! cpin_parse {
        ($t:ty) => {
            impl CpIn for $t {
                fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
                    r.read_word_str().parse().unwrap()
                }
            }
        };
    }
    cpin_cast!(usize, u64);
    cpin_cast!(u32, u64);
    cpin_cast!(u16, u64);
    cpin_cast!(i32, i64);
    cpin_cast!(i16, i64);
    cpin_cast!(i8, i64);

    cpin_parse!(f64);

    cpin_tuple!(T1, T2);
    cpin_tuple!(T1, T2, T3);
    cpin_tuple!(T1, T2, T3, T4);
    cpin_tuple!(T1, T2, T3, T4, T5);

    fn read_u64_fast<R: BufRead>(r: &mut R) -> u64 {
        let mut value = 0;
        loop {
            let mut idx = 0;
            let buf_len;
            {
                let buf = r.fill_buf().unwrap();
                buf_len = buf.len();
                assert!(buf_len != 0);
                while idx < buf_len && b'0' <= buf[idx] && buf[idx] <= b'9' {
                    value = value * 10 + (buf[idx] - b'0') as u64;
                    idx += 1;
                }
            }
            if idx < buf_len {
                r.consume(idx + 1);
                return value;
            }
            r.consume(idx);
        }
    }
    fn read_i64_fast<R: BufRead>(r: &mut R) -> i64 {
        let (consume, sign) = match r.fill_buf().unwrap()[0] {
            b'+' => (true, 1),
            b'-' => (true, -1),
            _ => (false, 1),
        };
        if consume {
            r.consume(1);
        }
        read_u64_fast(r) as i64 * sign
    }

}


/*------------------------------------------------------------------*/
/*------------------------- begin template -------------------------*/
/*------------------------------------------------------------------*/

// ref: tanakh <https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8>
// diff: using Parser
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut parser = Parser::from_str($s);
        input_inner!{parser, $($r)*}
    };
    (parser = $parser:ident, $($r:tt)*) => {
        input_inner!{$parser, $($r)*}
    };
    (new_stdin_parser = $parser:ident, $($r:tt)*) => {
        let stdin = std::io::stdin();
        let reader = std::io::BufReader::new(stdin.lock());
        let mut $parser = Parser::new(reader);
        input_inner!{$parser, $($r)*}
    };
    ($($r:tt)*) => {
        input!{new_stdin_parser = parser, $($r)*}
    };
}

macro_rules! input_inner {
    ($parser:ident) => {};
    ($parser:ident, ) => {};
    ($parser:ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($parser, $t);
        input_inner!{$parser $($r)*}
    };
}

macro_rules! read_value {
    ($parser:ident, ( $($t:tt),* )) => {
        ( $(read_value!($parser, $t)),* )
    };
    ($parser:ident, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($parser, $t)).collect::<Vec<_>>()
    };
    ($parser:ident, chars) => {
        read_value!($parser, String).chars().collect::<Vec<char>>()
    };
    ($parser:ident, char_) => {
        read_value!($parser, String).chars().collect::<Vec<char>>()[0]
    };
    ($parser:ident, usize1) => {
        read_value!($parser, usize) - 1
    };
    ($parser:ident, i64_) => {
        $parser.fast_i64()
    };
    ($parser:ident, usize_) => {
        $parser.fast_i64() as usize
    };
    ($parser:ident, usize1_) => {
        ($parser.fast_i64() - 1) as usize
    };
    ($parser:ident, $t:ty) => {
        $parser.next::<$t>().expect("Parse error")
    };
}

use std::io;
use std::io::BufRead;
use std::str;

// ref: tatsuya6502 <https://qiita.com/tatsuya6502/items/cd448486f7ef7b5b8c7e>
// ref: wariuni <https://qiita.com/tatsuya6502/items/cd448486f7ef7b5b8c7e#comment-7040a5ae96305e884eb9>
// diff: using std::io::BufRead::fill_buf()
pub struct Parser<R> {
    pub reader: R,
    buf: Vec<u8>,
    pos: usize,
}

impl Parser<io::Empty> {
    pub fn from_str(s: &str) -> Parser<io::Empty> {
        Parser {
            reader: io::empty(),
            buf: s.as_bytes().to_vec(),
            pos: 0,
        }
    }
}

impl<R: BufRead> Parser<R> {
    pub fn new(reader: R) -> Parser<R> {
        Parser {
            reader: reader,
            buf: vec![],
            pos: 0,
        }
    }
    pub fn update_buf(&mut self) {
        self.buf.clear();
        self.pos = 0;
        loop {
            let (len, complete) = {
                let buf2 = self.reader.fill_buf().unwrap();
                self.buf.extend_from_slice(buf2);
                let len = buf2.len();
                (len, buf2[len - 1] <= 0x20)
            };
            self.reader.consume(len);
            if complete {
                break;
            }
        }
    }
    pub fn next<T: str::FromStr>(&mut self) -> Result<T, T::Err> {
        loop {
            let mut begin = self.pos;
            while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
                begin += 1;
            }
            let mut end = begin;
            while end < self.buf.len() && (self.buf[end] > 0x20) {
                end += 1;
            }
            if begin != self.buf.len() {
                self.pos = end;
                return unsafe { str::from_utf8_unchecked(&self.buf[begin..end]) }.parse::<T>();
            } else {
                self.update_buf();
            }
        }
    }
    pub fn fast_i64(&mut self) -> i64 {
        loop {
            let mut begin = self.pos;
            while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
                begin += 1;
            }
            if begin == self.buf.len() {
                self.update_buf();
                continue;
            }
            let mut res = 0;
            let (is_positive, mut end) = match self.buf[begin] {
                b'+' => (true, begin + 1),
                b'-' => (false, begin + 1),
                _ => (true, begin),
            };
            while end < self.buf.len() && (self.buf[end] > 0x20) {
                res = res * 10 + (self.buf[end] as i64 - '0' as i64);
                end += 1;
            }
            if begin != self.buf.len() {
                self.pos = end;
                return if is_positive { res } else { -res };
            } else {
                self.update_buf();
            }
        }
    }
}

#[allow(unused_imports)]
use std::cmp::*;

fn main() {
    input! {
        new_stdin_parser = parser,
    }
    let res = solve(&mut parser);
    print!("{}", res);
}

/*------------------------------------------------------------------*/
/*-------------------------- end template --------------------------*/
/*------------------------------------------------------------------*/

use std::fmt::Write;
fn solve<R: BufRead>(parser: &mut Parser<R>) -> String {
    let mut buf = String::new();
    input! {
        parser = parser,
        n: usize,
        xs: [usize; n],
    }
    let mut count = vec![0; 200000 + 1];
    for &x in &xs {
        count[x] += 1;
    }
    let max = *xs.iter().max().unwrap();
    for &x in &xs {
        if x != max {
            writeln!(buf, "{}", max);
        } else {
            assert_eq!(x, max);
            if count[x] == 1 {
                for y in (0..x).rev() {
                    if count[y] != 0 {
                        writeln!(buf, "{}", y);
                        break;
                    }
                }
            } else {
                writeln!(buf, "{}", x);
            }
        }
    }
    buf
}


use std::io::*;

// const SP: u8 = b' ';
const LF: u8 = b'\n';

struct CharacterInput<'a> {
    locked_stdin: StdinLock<'a>,
    bytes_buffer: Vec<u8>,
}

impl<'a> CharacterInput<'a> {
    fn read(&mut self, delimiter: u8) -> &[u8] {
        self.bytes_buffer.clear();

        let mut len = self
            .locked_stdin
            .read_until(delimiter, &mut self.bytes_buffer)
            .unwrap();

        if len > 0 {
            len -= 1;
        }

        &self.bytes_buffer[0..len]
    }

    fn scan_u(&mut self, delimiter: u8) -> u32 {
        self.read(delimiter)
            .into_iter()
            .fold(0, |accumulator, byte| {
                (byte - b'0') as u32 + accumulator * 10
            })
    }

    fn scan_u_vec(&mut self, n: usize, separator: u8, delimiter: u8) -> Vec<u32> {
        let mut vector = Vec::with_capacity(n as usize);
        for _i in 0..n - 1 {
            vector.push(self.scan_u(separator));
        }
        vector.push(self.scan_u(delimiter));
        vector
    }
}

fn create_cin<'a>(input: StdinLock<'a>, buffer_capacity: usize) -> CharacterInput {
    CharacterInput {
        locked_stdin: input,
        bytes_buffer: Vec::with_capacity(buffer_capacity),
    }
}

struct CharacterOutput {
    string_buffer: String,
}

impl CharacterOutput {
    fn push_s(&mut self, s: &str) {
        self.string_buffer += s;
    }

    fn add_s(&mut self, s: &str, separator: char) {
        self.push_s(s);
        self.string_buffer.push(separator);
    }

    fn push<T: ToString>(&mut self, n: T) {
        self.push_s(&n.to_string());
    }

    fn add<T: ToString>(&mut self, n: T, separator: char) {
        self.push(n);
        self.string_buffer.push(separator);
    }

    fn add_from_iterator<T: ToString, I>(
        &mut self,
        iterator: &mut I,
        length: usize,
        separator: char,
        delimiter: char,
    ) where
        I: Iterator<Item = T>,
    {
        for element in iterator.by_ref().take(length - 1) {
            self.add(element, separator);
        }
        self.add(iterator.next().unwrap(), delimiter);
    }

    fn flush(&mut self) {
        let out = stdout();
        let mut out = out.lock();
        out.write_all(self.string_buffer.as_bytes()).unwrap();
        self.string_buffer.clear();
    }
}

fn create_cout(capacity: usize) -> CharacterOutput {
    CharacterOutput {
        string_buffer: String::with_capacity(capacity),
    }
}

// ------------------------------------------------------------------------

fn main() {
    let cin = stdin();
    let cin = &mut create_cin(cin.lock(), 16);

    let mut max_a = 0;
    let mut second_max_a = 0;

    let n = cin.scan_u(LF) as usize;
    let a: Vec<u32> = (0..n)
        .map(|_| {
            let a_i = cin.scan_u(LF);

            if a_i > max_a {
                max_a = a_i;
            } else if a_i > second_max_a {
                second_max_a = a_i;
            }

            a_i
        })
        .collect();

    let cout = &mut create_cout(7 * n);

    for a_i in a {
        if a_i < max_a { cout.add(max_a, '\n'); }
        else { cout.add(second_max_a, '\n') }
    }

    cout.flush();
}


use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    };

    let a: Vec<usize> = a;
    let max = a.iter().max().unwrap();

    for i in 0..n {
        if a[i] == *max {
            let mut x = a.clone();
            x[i] = 0;
            println!("{}", x.iter().max().unwrap());
        } else {
            println!("{}", max);
        };
    }
}


use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    };

    let a: Vec<usize> = a;

    for i in 0..n {
        let mut x = a.clone();
        x[i] = 0;
        println!("{}", x.iter().max().unwrap());
    }
}


use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let mut a: Vec<u32> = Vec::new();
    for _ in 0..n {
        a.push(parse_line().unwrap());
    }
    for i in 0..n {
        let mut cp: Vec<u32> = a.iter().copied().collect();
        cp.remove(i);
        println!("{}", cp.iter().max().unwrap());
    }
}


let N = (Int)(readLine()!)!;
var maximum = 0;
var secondMaximum = 0;
var count: Array<Int> = Array(repeating: 0, count: 200020);
var A: Array<Int> = Array(repeating: 0, count: 200020);
for i in 0 ..< N {
    let a = (Int)(readLine()!)!;
    A[i] = a;
    if a > maximum {
        secondMaximum = maximum;
        maximum = a;
    }
    else if a > secondMaximum {
        secondMaximum = a;
    }
    count[a] += 1;
}
for i in 0 ..< N {
    if A[i] != maximum {
        print(maximum);
    }
    else if A[i] == maximum && count[A[i]] == 1 {
        print(secondMaximum);
    }
    else {
        print(maximum);
    }
}


import Foundation
let n = Int(readLine()!)!
var a: [Int] = .init(repeating: 0, count: n)
for i in 0..<n {
  a[i] = Int(readLine()!)!
}
let sort = a.sorted()
let maxV = sort.last!
let maxVPrev = sort[sort.count - 2]

for i in 0..<n {
  if maxV == maxVPrev {
    print(maxV)
  } else if maxV == a[i] {
    print(maxVPrev)
  } else {
    print(maxV)
  }
}


// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }

    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {

    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt

    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2

        if Int(ary[mid])! < key {
            left = mid

        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }

    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    var dicA = [Int: Int]()
    for i in 0..<n {
        dicA[i] = readInt()
    }

    let dicASorted = dicA.sorted { $0.value > $1.value }
    for i in 0..<n {
        for d in dicASorted {
            if d.key == i {
                continue
            } else {
                print(d.value)
                break
            }
        }
    }
}
main()


let n = Int(readLine()!)!

func solve(_ a: [Int]) -> [Int] {
  let n = a.count
  var ans: [Int] = .init(repeating: 0, count: n + 1)
  for i in (1...n).reversed() {
    var sum = 0
    var j = i + i
    while j <= n {
      sum ^= j
      j += i
    }
    ans[i] = sum ^ a[i]
  }
  return ans
}

var a: [Int] = .init(repeating: 0, count: n + 1)
let inputs = readLine()!
	.split(separator: " ")
	.map { Int($0)! }
	.enumerated()
	.forEach { a[$0+1] = $1 }

let ans = solve(a)

if ans.isEmpty {
  print(-1)
} else {
  let res = ans.enumerated().filter { $1 == 1 }
  print(res.count)
  res.forEach { print($0.0 + 1) }
}


export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const n: number = parseInt(tmp[0].split(" ")[0]);
    const list: number[] = [];
    let max1: number = 0;
    let max2: number = 0;
    for (let i = 1; i <= n; i++) {
      const a: number = parseInt(tmp[i].split(" ")[0]);
      list.push(a);
      if (max1 < a) {
        if (max2 < max1) {
          max2 = max1;
        }
        max1 = a;
      } else if (max2 < a || max1 == a) {
        max2 = a;
      }
    }
    const isMaxDouble: boolean = max1 == max2;
    const result: number[] = [];
    for (let i = 0; i < n; i++) {
      if (!isMaxDouble && list[i] == max1) {
        result.push(max2);
      } else {
        result.push(max1);
      }
    }
    return `${result.join("\n")}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


'use strict'
const main = (input: string) => {
    // for-n1はTLE
    // sortして1番目と2番目出せればいい？
    const std: number[] = input.trim().split('\n').map(Number)
    const n: number = std.shift()
    const a: number[] = std
    const s: number[] = [...a].sort((a,b)=>b-a)
    let r: number[] = []
    for (let i = 0; i < n; i++) {
        if (a[i] !== s[0]) {
            r.push(s[0])
        } else {
            r.push(s[1])
        }
    }
    console.log(r.join('\n'))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const as = input.slice(1).map(n => Number(n));
  const sortedAs = as.slice();
  sortedAs.sort((a, b) => a - b);
  const max = sortedAs[sortedAs.length - 1];
  const nextMax = sortedAs[sortedAs.length - 2];
  const result = [];
  for (const a of as) {
    if (a === max) {
      result.push(nextMax);
    } else {
      result.push(max);
    }
  }
  console.log(result.join("\n");
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let ar=tnn(n)
  let m=Math.max(...ar)
  // let m2=0
  // let c=0
  // for(let i=0;i<n;i++){
  //   if(m==ar[i])c++
  //   else m2=max(m2,ar[i])
  //   if(c==2){
  //     m2=m
  //     break
  //   }
  // }
  // for(let i=0;i<n;i++){
  //   to(ar[i]!=m?m:m2)
  // }
}
main()


const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let ar=tnn(n)
  // let m=max(...ar)
  // let m2=0
  // let c=0
  // for(let i=0;i<n;i++){
  //   if(m==ar[i])c++
  //   else m2=max(m2,ar[i])
  //   if(c==2){
  //     m2=m
  //     break
  //   }
  // }
  // for(let i=0;i<n;i++){
  //   to(ar[i]!=m?m:m2)
  // }
}
main()


const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let ar=tnn(n)
  let m=max(...ar)
  // let m2=0
  // let c=0
  // for(let i=0;i<n;i++){
  //   if(m==ar[i])c++
  //   else m2=max(m2,ar[i])
  //   if(c==2){
  //     m2=m
  //     break
  //   }
  // }
  // for(let i=0;i<n;i++){
  //   to(ar[i]!=m?m:m2)
  // }
}
main()


x = list(map(int, input().split()))
for i in range(5):
    if x[i] != i + 1:
        print(i + 1)
        exit()


x=list(map(int,input().split()))
print(x.index(0)+1)


l = list(map(int,input().split()))

for i in range(len(l)):
    if (l[i] == 0):
        print(i+1)
        break


data = [int(x) for x in input().split(" ")]

for i in range(len(data)):
  if data[i] == 0: print(i)


l = list(map(int, input().split()))
for i in range(5):
    if l[i] == 0:
        print(i)


x = list[map(int,input().split())]
print(x.index(0) + 1)


import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);

	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		int a = Integer.parseInt(st.nextToken());
	 		int b = Integer.parseInt(st.nextToken());
	 		int c = Integer.parseInt(st.nextToken());
	 		int d = Integer.parseInt(st.nextToken());
	 		int e = Integer.parseInt(st.nextToken());

 		if (a == 0){
 			out.println(1);
 		}
 		else if (b == 0){
 			out.println(2);
 		}
 		else if (c == 0){
 			out.println(3);
 		}
 		else if (d == 0){
 			out.println(4);
 		}
 		else if (e == 0){
 			out.println(5);
 		}

 		out.println();

 		out.close();

 	}
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;

public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);

    for(int i = 0; i < 5; i++){
      int a = sc.nextInt();
      if(a == 0){System.out.println(i+1);}
    }

  }

 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      public InputReader(InputStream stream) {
          this.stream = stream;
      }

      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }

      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }

      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }

      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }

      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }

      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFiveVariables solver = new AFiveVariables();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFiveVariables {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            ArrayList<Integer> list = new ArrayList<>();
            while (in.hasNext()) list.add(in.nextInt());

            out.println(list.indexOf(0) + 1);
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public int nextInt() {
            if (!hasNext()) throw new NoSuchElementException();
            int n = 0;
            boolean minus = false;
            byte b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}


import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int input = in.nextInt();
        int inp = in.nextInt();
        int output = variable(input, inp);
        System.out.println(output);
    }
    // x1, x2, x3, x4, x5 = 1 2 3 0 4

    public static int variable(int i, int number) {
        for (i = 0; i <= 5; i++) {
            if (number == 0) {

            }
        }
        return i;

    }

}


import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int A;
        for(int i=0;i<5;i++){
            A=sc.nextInt();
            if(A==0){
                System.out.println(i);
                return;
            }
        }

	}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      int[] a = new int[5];
      for (int i = 1; i <= 5; i++) {
         a[i] = in.nextInt();
         if (a[i] == 0) {
            out.println(i);
            return;
         }
      }
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

      public String nextToken() {
         while (st == null || !st.hasMoreTokens()) {
            try {
               st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
         return st.nextToken();
      }

      public int nextInt() {
         return Integer.parseInt(nextToken());
      }

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


#include <stdio.h>

int main()
{
	int a,b,c,d,e;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	if(a==0) printf("1");
	else if(b==0) printf("2");
	else if(c==0) printf("3");
	else if(d==0) printf("4");
	else if(e==0) printf("5");
}


#include <stdio.h>
#include <string.h>

int main()
{
	int ans = 0;
	for (int i = 0; i < 5; i++) {
		int x;
		scanf("%d", &x);
		if (x == 0) {
			ans = i + 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}


#include <cstdio>

int main(){

    for(int i=1;i<=5;i++){
        int temp;
        scanf("%d\n",&temp);
        if (temp==0) printf("%d\n",i);
    }

    return 0;
}


#include <iostream>
using namespace std;
int main(){
int x;
cin >> x;
if(x[0] == 0) cout << x[0] << endl;
else if(x[1] == 0) cout << x[1] << endl;
else if(x[2] == 0) cout << x[2] << endl;
else if(x[3] == 0) cout << x[3] << endl;
else if(x[4] == 0)cout << x[4] << endl;

}


#include <iostream>
using namespace std;

int main(){
  int a,b,c,d,e;
  cin >> a >> " " >> b >> " " >> c >> " " >> d >> " " >> e;
  if (a==0){
    cout << "1";
  }
  else if (b==0){
    cout << "2";
  }
  else if (c==0){
    cout << "3";
  }
  else if (d==0){
    cout << "4";
  }
  else{
    cout << "5";
  }
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int ar[5];
    for(int i=1; i<=5; i++)
    {
        cin>>ar[i];
    }
    for(int i=1; i<=5; i++)
    {
        if(ar[i]==0)
        {
            cout<<i<<endl;
        }
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b;
};

//小さい順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){
    int a[5];
    for(int i=0;i<5;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<5;i++){
        if(a[i]==0){
            printf("%d",i+1);
            return 0;
        }
    }
}


#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)
int main(){
  int a[5];
  rep(i,5){
    scanf("%d",&a[i]);
    if(a[i]==0){
      printf("%d\n",i+1);
    }
  }
  return 0;
}


#include<stdio.h>

int main(){

    int a,b,c,d,e;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);

    if(a!=1){
        printf("1");
        return 0;
    }
    if(b!=2){
        printf("2");
        return 0;
    }
    if(c!=3){
        printf("3");
        return 0;
    }
    if(d!=4){
        printf("4");
        return 0;
    }
    if(e!=5){
        printf("5");
        return 0;
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,x;
    for(i=0;i<5;i++)
    {
        if(scanf("%d",&x)==0)
            printf("%d",i+1);
    }
    return 0;
}


#include<stdio.h>
#include<math.h>

int main()
{
  long long int x,y,a,b;
  scanf("%lld %lld",&x,&y);

 if ( ( 4*x-y) % 2 ==0 && (4*x-y)>=0 && (y-2*x) % 2 ==0)
 {
 	printf("Yes");
   return 0;
 }

  printf("No");

  return 0;
}


#include<stdio.h>
#include<math.h>

int main()
{
  int x,y,a,b;
  scanf("%d %d",&x,&y);

 if ( ( 4*x-y) % 2 ==0 && (4*x-y)>0 )
 {
 	printf("Yes");
   return 0;
 }

  printf("No");

  return 0;
}


"use strict";

const main = (arg) => {
  const input = arg.trim().split("\n")[0];
  const numbers = input.split(" ");
  for (let i = 0; i < numbers.length; i++) {
    if (parseInt(numbers[i]) === 0) return console.log(i + 1);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main(input) {
  // 入力値の分離
  param = input.split(" ");
  var calc = 0;
  for(var i = 0; i < param.length; i++){
    calc += parseInt(param[i]);
  }
  var base = 1+2+3+4+5;
  const result = base - calc;
  console.log(parseInt(result));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));parseInt


function main(lines) {
  const input = lines.split(' ')
  let count = 0;
  for(let i=0; i<input.length; i++){
      count++
      if(input[i] == 0){
          break;
      }
  }
  console.log(count)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


#include<stdio.h>

int main (){
  int x[5];
  int x_length = sizeof x / sizeof x[0];
  for(int i = 0;i < x_length;i++){
    scanf("%d",&x[i]);
  }

  for(int i = 0;i < x_length;i++){
    if(x[i] == 0){
      printf("%d",i+1);
    }
  }
  return 0;
}


'use strict'

const main = (arg) => {
    console.log(arg);
    const nums = arg.split(" ");
    nums.forEach((num,index) => {
        if(num==0) console.log(index+1);
    });
}

main(require('fs').readFileSync('/dev/stdin','utf8'));


const main = (array) => {
    const args = array.split(" ")
    console.log(args.findIndex(element => element === "0") + 1)
}

main(require("fs").readFileSync('/dev/stdin', 'utf8'))


package main

import "fmt"

func main() {

	var x [5]int

	fmt.Scan(&x[0], &x[1], &x[2], &x[3], &x[4])

	for i, j := range x {
		if j == 0 {
			fmt.Println(i + 1)
			break
		}
	}

}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr()
	for idx, val := range list {
		if val == 0 {
			fmt.Printf("%d\n", idx+1)
			break
		}
	}
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


package main

import "fmt"

func main() {
	for i := 0; i < 5; i++ {
		var a int
		fmt.Scan(&a)
		if a == 0 {
			fmt.Println(i + 1)
		}
	}
}


func main() {

	var list [5]int

	fmt.Scan(&list[0], &list[1], &list[2], &list[3], &list[4]) // スペース区切りなのでそのままScanで取れる

	fmt.Println(list)

	// 0を代入したポジションを返す
	pos := func(arr [5]int, e int) int {
		for i, v := range arr {
			if v == e { return i + 1 }
		}
		return -1
	}(list, 0)

	fmt.Println(pos)
}


package main

import (
	"fmt"
)

func main() {
	a()
}

func a() {
	var list [5]int

	fmt.Scan(&list[0], &list[1], &list[2], &list[3], &list[4])

	fmt.Println(list)

	// 0を代入したポジションを返す
	pos := func(arr [5]int, e int) int {
		for i, v := range arr {
			if v == e { return i + 1 }
		}
		return -1
	}(list, 0)

	fmt.Println(pos)
}


package main

import (
	"fmt"
)

func main() {
	a()
}

func a() {
	var list [5]int

	fmt.Scan(&list[0], &list[1], &list[2], &list[3], &list[4]) // スペース区切りなのでそのままScanで取れる

	fmt.Println(list)

	// 0を代入したポジションを返す
	pos := func(arr [5]int, e int) int {
		for i, v := range arr {
			if v == e { return i + 1 }
		}
		return -1
	}(list, 0)

	fmt.Println(pos)
}


arr = gets.split.map(&:to_i)

cnt = 1

arr.each do |x|
    if x == 0
        puts cnt
        break
    end
    cnt += 1
end


X = $stdin.gets.split.map {|i| i.to_i }
X.each_with_index do |x, i|
  if x == 0
    puts i + 1
    exit
  end
end


line = gets.split(' ')
p line.index('0') + 1


x = gets.split.map(&:to_i)
for i in 0..4
  if x[i] == 0
    puts x[i]+1
    break
  end
end


x = gets.split.map(&:to_i)
for i in 0..4
  if x[i] == 0
    puts x+1
    break
  end
end


arr = gets.chomp.split().map(&:to_i)
a = arr.select { |i| i == 0 }
print(a.map{|i| i+1}.join(' '))


use std::io::*;
use std::str::FromStr;

fn main() {
	let mut temp: u32;
	for i in 1..6 {
		temp = read();
		if temp == 0 {
			println!("{}", i);
		}
	}
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}


fn main() {
    let (x1, x2, x3, x4, x5) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut iter = s.split_whitespace().map(|i| i.parse::<i32>().unwrap());
        (
            iter.next().unwrap(),
            iter.next().unwrap(),
            iter.next().unwrap(),
            iter.next().unwrap(),
            iter.next().unwrap(),
        )
    };
    if x1==0{
        println!("1");
    }
    if x2==0{
        println!("2");
    }
    if x3==0{
        println!("3");
    }
    if x4==0{
        println!("4");
    }
    if x5==0{
        println!("5");
    }
}


use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        xs: [usize; 5]
    }

    for i in 0..5 {
        if xs[i] == 0 {
            println!("{}", i+1);
        }
    }
}


//! # Bundled libraries

fn main() {
    todo!();
}

// The following code was expanded by `cargo-equip`.