I am trying to solve a problem which requires finding the maximum value in an array. The array cannot be brute force searched as it is very large (over 100,000,000 elements) so I am attempting to create a modified version of binary search to find the maximum.
The specific attributes of the array are:
- The array is circular
 - Starting from the index of minimum value in the array all values past this index will either increase or remain constant until the index of the maximum value. From here the values will either remain constant or decrease
 - The index of the minimum value is opposite the index of the maximum value
 
Examples of some arrays are (All equivalent arrays):
{1, 2, 3, 4, 5, 5, 4, 3, 2, 1}{5, 4, 3, 2, 1, 1, 2, 3, 4, 5}{3, 4, 5, 5, 4, 3, 2, 1, 1, 2}
Does anyone have any ideas as to solve this problem in approximately O(logN) time?
How array values are calculated:
unsigned long long calculateArrayValue(unsigned long long location, unsigned long long n, unsigned long long arrayLength, unsigned long long* arrayIndices, unsigned long long* locationMagnitude) {
    unsigned long long value = 0;
    unsigned long long halfArrayLength = arrayLength/ 2;
    unsigned long long difference;
    for (unsigned long long i = 0; i < n; i++) {
        if (arrayIndices[i] > location) {
            difference = arrayIndices[i] - location;
        } else {
            difference = location - houseLocations[i];
        }
        if (difference > halfArrayLength ) {
            difference = arrayLength - difference;
        }
        value += difference * locationMagnitude[i];
    }
    return value;
}