#include <bits/stdc++.h>
using namespace std;
int poww(int a, int b) {
  if (b == 1) return a;
  int temp = pow(a, b / 2);
  return (b & 1) ? temp * temp * a : temp * temp;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  int cnt1 = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '4' and s[i] != '7') {
      cout << "NO";
      return 0;
    }
    if (s[i] == '4' and i < n / 2) cnt += 1;
    if (s[i] == '7' and i < n / 2) cnt += 2;
    if (s[i] == '4' and i >= n / 2) cnt1 += 1;
    if (s[i] == '7' and i >= n / 2) cnt1 += 2;
  }
  cout << (cnt == cnt1 ? "YES" : "NO");
  return 0;
}
