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