1. JAVA, Simon Baumgartner

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


/*
* ACM Programming Contest
* Problem: 507 Jill Rides Again
* Status: Runtime Error
* Runtime: -
* Date: 2009-05-30
* Author: Simon Baumgartner
*
*/

public class Main {

public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
// BufferedReader in = new BufferedReader(new FileReader("input.txt"));

int nrOfRoutes = Integer.parseInt(in.readLine());
for(int route = 1; route <= nrOfRoutes; route++){

int nrOfStations = Integer.parseInt(in.readLine());
int[] segments = new int[nrOfStations - 1];
for(int j = 0; j < nrOfStations - 1 ; j++)
segments[j] = Integer.parseInt(in.readLine().trim());

int[][] v = new int[segments.length][segments.length];
int from = 0;
int to = 0;
int max = Integer.MIN_VALUE;

for(int i = 0; i < segments.length; i++){
v[i][i] = segments[i];
if(max <= segments[i]){
max = segments[i];
from = i + 1;
to = i + 2;
}
}

for(int i = 0; i < segments.length; i++)
for(int j = i + 1; j < segments.length; j++){
v[i][j] = v[i][j-1] + segments[j];
if(max < v[i][j] || (max == v[i][j] && (to-from < (j+2)-(i+1)))){
max = v[i][j];
from = i + 1;
to = j + 2;
}
}

// for(int[] x : v)
// System.out.println(Arrays.toString(x));

if(max < 0)
System.out.println("Route " + route + " has no nice parts");
else
System.out.println("The nicest part for route " + route +" is between stops " + from + " and " + to);
}
}
}