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

int main() {
    int a[200010];
    int n;
    int w[11];
    int num[11];
    cin>>n;
    for(int i = 0; i < n; ++i)
        cin>>w[i];
    for(int i = 0; i < n; ++i)
        cin>>num[i];
    int max = 0;
    for(int i = 0; i < n; ++i){
        max += w[i] * num[i];
    }
    for(int i = 0; i < max; ++i){
        a[i] = 0;
    }
    for(int i = 0; i < n; ++i){
        queue <int> temp;
        for(int j = 1; j <= num[i]; ++j){
            for(int k = 0; k < max; ++k){
                if(a[k]){
                    // cout<<k + j * w[i]<<" ";
                    temp.push(k + j * w[i]);
                }else if(k + 1 == j * w[i]){
                    // cout<<k<<" ";
                    temp.push(k);
                } 
            }
        }
        while(!temp.empty()){
            int t = temp.front();
            // cout<<t<<" ";
            a[t] = 1;
            temp.pop();
        }
        // cout<<endl;
    }
    int count = 0;
    for(int i = 0; i < max; ++i){
        if(a[i])
            count++;
    }
    cout<<count + 1;
}
// 64 位输出请用 printf("%lld")