Why it is returning segmentation fault?

#include
#include<bits/stdc++.h>
using namespace std;

int solve(int i,int a,vector coins){

if(a==0) return 1;

if(i==coins.size()) return 0;

int take=solve(i,a-coins[i],coins);

int nottake=solve(i+1,a,coins);

return take+nottake;

}

int main() {
int a,n;

cin >> a >>n ;
vector<int> coins(n);
for(int i=0;i<n;i++){
	cin >> coins[i];
}
cout << solve(0,a,coins);
return 0;

}