#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(), x.end();
#define SIZE(x) ll(x.size())
#define CHMIN(x,y) x = min(x, (y))
#define CHMAX(x,y) x = max(x, (y))
#define YES(b) cout << ((b) ? "Yes" : "No") << endl

int n, i;

int main() {
    cin >> n;
    int a[n];
    REP(i, n) cin >> a[i];
    int cnt = 0;
    REP(i, n) {
        if (a[i] > 10) {
            cnt += a[i] - 10;
        }
    }
    cout << cnt << endl;
    return 0;
}
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    ll N;
    cin >> N;

    string S;
    cin >> S;
    queue<int> I;
    for (ll i = 0; i < N; ++i) {
        if (S[i] == '1') {
            I.emplace(i);
        }
    }

    string T;
    cin >> T;
    vector<int> E;
    for (ll i = 0; i < N; ++i) {
        if (T[i] == '1') {
            E.emplace_back(i);
        }
    }

    ll E_size = E.size();
    ll I_size = I.size();
    if ((E_size - I_size) % 2 == 1) {
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;
    ll I_first;
    ll I_second;
    for (auto E_num : E) {
        if (I.empty()) {
            cout << -1 << endl;
            return 0;
        }
        I_first = I.front();
        I.pop();
        while (I_first < E_num) {
            if (I.empty()) {
                cout << -1 << endl;
                return 0;
            }
            I_second = I.front();
            I.pop();
            ans += I_second - I_first;

            if (I.empty()) {
                cout << -1 << endl;
                return 0;
            }
            I_first = I.front();
            I.pop();
        }
        ans += I_first - E_num;
    }

    while (!I.empty()) {
        I_first = I.front();
        I.pop();
        I_second = I.front();
        I.pop();
        ans += I_second - I_first;
    }

    cout << ans << endl;
}