A linear search checks elements one by one. When the function must say where a value is, it returns the index, and a value that cannot be an index, usually -1, for "not found". Returning 0 for "not found" would be a bug, because 0 is a valid index.
Return as soon as you find the first match if the task asks for the first one. If it asks for the last, keep going and remember the latest match. Ties matter in trading data: two orders at the same price are ranked by arrival, so "the first one" is often the rule.
An empty array (n is 0) has no matches, and code that reads a[0] without checking n reads memory that is not there.
Return the first matching index, or -1 after the loop.