#include <bits/stdc++.h>
using namespace std;
int n, m, a[10000], sum1, sum2;
string s;
int main() {
  cin >> n;
  cin >> s;
  for (int i = 0; i < s.length(); i++)
    if (s[i] != '4' && s[i] != '7') {
      cout << "NO";
      return 0;
    }
  for (int i = 0; i < n / 2; i++) {
    sum1 += (int)s[i] - '0';
    sum2 += (int)s[s.length() - 1 - i] - '0';
  }
  if (sum1 == sum2) {
    cout << "YES";
    return 0;
  } else {
    cout << "NO";
  }
}
