use std::collections::VecDeque; fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let mut a: VecDeque = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); while a.len() > 1 { let lim = a.len() - 1; for _ in 0..lim { let mut temp = a.pop_front().unwrap(); temp += a.front().unwrap(); a.push_back(temp); } a.pop_front(); } println!("{}", a[0] % 1_000_000_007); }