use std::io::{Read};

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_line(&mut buf).unwrap();
    let n: i64 = buf.trim_end().parse().unwrap();
    buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let a: Vec<i64> = (0..n)
        .map(|_| {
            let a: i64 = iter.next().unwrap().parse().unwrap();
            a
        }).collect();

    let total = a.iter().fold(0, |t, a| t+a);
    let d = a.iter().map(|a| i64::abs(a*n-total)).fold(i64::max_value(), |a, b| std::cmp::min(a, b));
    for i in 0..n {
        if i64::abs(a[i as usize]*n-total) == d {
            print!("{}", i);
            break;
        }
    }
}
