Field Trip
면접 대비시간 제한3초메모리 제한1024 MB
학급 구간을 연속된 세 묶음으로 나눠 각 묶음의 학생 수가 같도록 만들 수 있는지 판별하고, 가능하면 두 경계 번호를 출력한다.
문제
You and your classmates are going on an exciting field trip to a downtown museum. Because the museum is an hour away, three buses of identical capacity and a van are dispatched as a means of transportation to the museum and back. The buses will first start loading only students, and once all students have been loaded then teachers will begin to fill in the remaining spots on the buses. Any remaining teachers will ride on the van. To make the bus ride more exciting, all the students are hoping for a "teacher free bus ride"! A teacher free bus ride is when none of the teachers are on a bus.
Students are grouped in class sections of different sizes. Each class section is assigned a number from to . All students in one class section must ride on the same bus. The buses will board class sections in increasing order by number. In other words, the first bus will load sections numbered to , the second bus will load sections numbered to , and the third bus will load the sections numbered to . Every bus must have at least one class section assigned to it.
Given the sizes of each of the class sections, determine if it is possible to load students onto identical buses and end up with a "teacher free bus ride!"
입력
The first line of input contains one integer , the number of class sections (). The second line of input contains integers, the integer represents the size of class section with number . Class section sizes can range from .
출력
If it is possible to load the students onto three identical buses in the above-described fashion and have a teacher free bus ride, then output two integers and () where is the number of the class section which is to be loaded last into the first bus, and is the class section which is to be loaded last into the second bus. We can assume the third bus will load class sections to .
If it is not possible, print "-1".