Iahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The selection will be made with the help of a single problem. Blatnatalag, a friend of Iahub, managed to get hold of the problem before the contest. Because he wants to make sure Iahub will be the one qualified, he tells Iahub the following task.

You're given an (1-based) array *a* with *n* elements. Let's define function *f*(*i*, *j*) (1 ≤ *i*, *j* ≤ *n*) as (*i* - *j*)<sup class="upper-index">2</sup> + *g*(*i*, *j*)<sup class="upper-index">2</sup>. Function g is calculated by the following pseudo-code:

Find a value *min*<sub class="lower-index">*i* ≠ *j*</sub>  *f*(*i*, *j*).

Probably by now Iahub already figured out the solution to this problem. Can you?
The first line of input contains a single integer *n* (2 ≤ *n* ≤ 100000). Next line contains *n* integers *a*[1], *a*[2], ..., *a*[*n*] ( - 10<sup class="upper-index">4</sup> ≤ *a*[*i*] ≤ 10<sup class="upper-index">4</sup>).
from math import *
def get_int():
    return int(input())
def get_nums():
    return list(map(int, input().split()))
def closest(points):
    dist = float('inf')
    for index, (x1, y1) in enumerate(points):
        for x2, y2 in points[index + 1:]:
            dist = min(dist, (x1-x2)**2 + (y1 - y2)**2)
    return sqrt(dist)

def distance(x1, y1, x2, y2):
    return sqrt((x1-x2)**2 + (y1-y2)**2)

def solve(y_sorted, x_sorted):
    if len(x_sorted) <= 4:
        return closest(x_sorted)
    n = len(x_sorted)
    x, y = x_sorted[n//2]
    left_points = x_sorted[:n//2]
    right_points = x_sorted[n//2 + 1:]
    
    left = solve(y_sorted,  left_points)
    right = solve(y_sorted, right_points)
    dist = min(left, right)
    comp = ceil(dist/2)
    middle = []
    for x2, y2 in y_sorted:
        cur_dist = distance(x, y, x2, y2)
        if cur_dist <= comp:    
            middle.append([x2, y2])
            
    for index in range(len(middle)):
        for next in range(index + 1, min(len(middle), index + 8)):
            cur_dist = distance(middle[index][0], middle[index][1], middle[next][0], middle[next][1])
            dist = min(dist, cur_dist)
    return dist 

    
def main():
    
    n = get_int()
    x_sorted = []
    points = []
    nums = get_nums()
    cur_sum = 0
    for index in range(n):
        cur_sum += nums[index]
        points.append((index, cur_sum))
        
    x_sorted = sorted(points, key = lambda point:point[0])
    y_sorted = sorted(points, key = lambda point:point[1])
    res = solve(y_sorted, x_sorted)
    print(ceil(res))
        
main()
