#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int n, diff(0);
  cin >> n;
  string s;
  cin >> s;
  n = n / 2;
  bool lucky = true;
  for (long long i = 0; i < n; i++) {
    if ((s[i] != '4' && s[i] != '7') || (s[n + i] != '4' && s[n + i] != '7')) {
      lucky = false;
      break;
    }
    diff = diff + (s[i] - s[n + i]);
  }
  lucky = lucky && (diff == 0);
  cout << (lucky ? "YES" : "NO") << endl;
}
