In an orchard, pear trees and apple trees are all planted along a straight line, each spaced 1 meter apart from the next. The orchard's owner, Mr. Wiktor, wants to find the pear tree that is farthest from any apple tree. Help him by computing the maximum distance between a pear tree and an apple tree.
The first line contains an integer n (2≤n≤106), the number of trees in the orchard. The second line contains n integers a1,a2,…,an separated by spaces. Each ai gives the type of the i-th tree: 0 means a pear tree and 1 means an apple tree. You may assume the orchard contains at least one pear tree and at least one apple tree.
Print a single integer: the maximum distance between a pear tree and an apple tree. Because adjacent trees are 1 meter apart, the distance between the i-th and j-th trees is ∣i−j∣ meters.