An array holds many values under one name, reached by index (0-based, like strings).
Almost every array problem uses the same input shape: first an integer N (how many
numbers), then the N numbers themselves. The starter reads both and hands your solve
the count and the list.
def solve(n, a):
# n is the count; a is the list of n numbers
return a[0] # e.g. the first element
static long solve(int n, long[] a) {
return a[0];
}
Because you get n and a together, you rarely need n separately — the list already knows
its own length — but it tells you how many to expect. Valid indices run 0 to n - 1; index
n is off the end. This is the same zero-based rule as strings, which is no accident: a string
is essentially an array of characters, so every array pattern you learn here transfers back to
text.