#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long ll;

int main() {
    int prime[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71};
    //rep(i, 20) cout << i << " " << prime[i] << "\n";
    ll A, B;
    cin >> A >> B;
    vector<vector<ll>> dp(B - A + 2, vector<ll>(1LL << 20, 0));
    dp[0][0] = 1;
    rep(i, B - A + 1) {
        //cout << "i=" << i << "\n";
        ll x = A + i;
        //cout << "x=" << x << "\n";
        int d = 0;
        rep(j, 20) {
            //cout << "j=" << j << "\n";
            d *= 2;
            if (x % prime[19 - j] == 0) d++;
        }
        //cout << "d=" << d << "\n";
        rep(j, 1LL << 20) {
            dp[i + 1][j] = dp[i][j];
        }
        rep(j, 1LL << 20) {
            if (j & d) continue;
            dp[i + 1][j | d] += dp[i][j];
        }
    }
    ll ans = 0;
    rep(i, 1LL << 20) ans += dp[B - A + 1][i];
    cout << ans << "\n";
    /*
    rep(i, B - A + 2) {
        rep(j, 10) {
            cout << dp[i][j] << " ";
        }
        cout << "\n";
    }
    */
}
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint A[N];
  REP(i,N)cin>>A[i];
  lint ans=0;
  lint dmax=0;
  lint s=0;
  lint p=0;
  REP(i,N){
    s+=A[i];
    dmax=max(dmax,s);
    ans=max(ans,p+s);
    ans=max(ans,p+dmax);
    p+=s;
  }
  cout<<ans<<endl;
  return 0;
}
