const MOD: usize = 1e9 as usize + 7; fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let mut a: Vec = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); while a.len() > 1 { let mut na = Vec::with_capacity(a.len()-1); for i in 1..a.len() { na.push((a[i-1] + a[i]) % MOD); } a = na; } println!("{}", a[0]); }