import random
import time
#http://www.maths.nuigalway.ie/
#~gettrick/teach/cs102/
p=[]
for i in range(600):
  p=p+[random.randrange(-50,50)]
print p
n=range(len(p))
buy=[]
prof=0
start=time.clock()
for i in n:
#i is the LEFT MOST POINT of the block
  for j in n[i:]:
#j is the RIGHT MOST POINT
    m=n[i:j+1]
    block=0
    for k in m:
      block=block+p[k]
#    print m
#    print 'profit',block
    if block>prof:
      prof=block
      buy=m
print time.clock()-start, 'seconds'
print prof
print buy

