#include <bits/stdc++.h>
using namespace std;
void init_code() {}
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int s1 = 0, s2 = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != '4' && s[i] != '7') {
      cout << "NO" << endl;
      return;
    }
  }
  for (int i = 0; i < n / 2; i++) {
    s1 += s[i] - '0';
  }
  for (int i = n / 2; i < n; i++) {
    s2 += s[i] - '0';
  }
  if (s1 == s2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
int main() {
  init_code();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
