#include <bits/stdc++.h>
const double Pi = acos(-1.0);
using namespace std;
int digit, sum;
map<int, int> cnt;
string a;
int main(int argc, char **argv) {
  cin >> digit;
  cin >> a;
  for (int i = 0; i < a.size(); i++) cnt[a[i]]++, sum += (a[i] - '0');
  if (cnt['4'] + cnt['7'] == a.size()) {
    int sa = 0, len = a.size();
    for (int i = 0; i < len / 2; i++) sa += (a[i] - '0');
    if (2 * sa == sum)
      cout << "YES\n";
    else
      cout << "NO\n";
  } else
    cout << "NO\n";
  return 0;
}
