// Java版本
import java.awt.im.InputContext;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
public class Main {
/*
2
0 0
0 3
1.000 1.000 5.000
*/
static HashSet<Integer> fibSet=new HashSet<Integer>();
static HashMap<Integer, Integer> fibMap=new HashMap<Integer, Integer>();
static HashMap<Integer, Integer> fibMap2=new HashMap<Integer, Integer>();
public static void fib(){
fibMap.put(1, (int) 1);
fibMap.put(2, (int) 1);
fibSet.add((int) 1);
fibMap2.put((int) 1, 1);
for(int i=3; i<50; i++){
fibMap.put(i, fibMap.get(i-1)+fibMap.get(i-2));
fibMap2.put(fibMap.get(i-1)+fibMap.get(i-2), i);
fibSet.add(fibMap.get(i-1)+fibMap.get(i-2));
}
//System.out.println("fibmap");
}
//如果有a之前的所有
public static boolean hasPre(int a, HashMap<Integer, Integer> nums){
int k=fibMap2.get(a);
boolean result=true;
for(int i=k-1;i>2; i--){
if(nums.get(fibMap.get(i)) !=null &&nums.get(fibMap.get(i)) >0){
continue;
}else{
result=false;
break;
}
}
if(result&& nums.get(1)!=null &&nums.get(1)>1 ){
result= true;
}else{
result= false;
}
return result;
}
public static int precount(int a, HashMap<Integer, Integer> nums){
long count=1;
int k=fibMap2.get(a);
for(int i=k-1;i>2; i--){
count=count*nums.get(fibMap.get(i));
}
count*=(nums.get(1)*(nums.get(1)-1)/2);
return (int) (count%1000000007);
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n=scanner.nextInt();
int a[] = new int[n];
for(int i=0; i<n; i++){
a[i]=scanner.nextInt();
}
fib();
//fib计数
HashMap<Integer, Integer> nums=new HashMap<Integer, Integer>();
boolean has1=false;
long count=0;
for(int i=0; i<n; ++i){
//如果等于1,那就好弄
//System.out.println(a[i]+""+fibSet.contains((long)a[i]) );
if(a[i]==1){
if(nums.containsKey(1)){
count=count+nums.get(1)+1;
nums.put(1, nums.get(1)+1);
}else{
nums.put(1, 1);
count+=1;
}
has1=true;
}else if(has1&& nums.get(1)>1&& fibSet.contains(a[i]) && hasPre(a[i],nums)){
count=(count+precount(a[i],nums))%1000000007;
if(nums.containsKey(a[i])){
nums.put(a[i], nums.get(a[i])+1);
}else{
nums.put(a[i], 1);
}
}
//System.out.println(nums);
}
System.out.println(count);
scanner.close();
}
}