#include <bits/stdc++.h>
using namespace std;
long long int vowel(char a) {
  a = toupper(a);
  if ((a == 'A') || (a == 'E') || (a == 'I') || (a == 'O') || (a == 'U')) {
    return 1;
  }
  return 0;
}
vector<long long int> v;
map<long long int, long long int> mp;
int main() {
  long long int n;
  string s;
  cin >> n;
  getchar();
  getline(cin, s);
  long long int s1 = 0, flg = 0, s2 = 0, i;
  for (i = 0; i < n; i++) {
    if (s[i] != '4' && s[i] != '7') {
      printf("NO\n");
      return 0;
    } else {
      if (i < n / 2) {
        s1 += s[i] - '0';
      } else {
        s2 += s[i] - '0';
      }
    }
  }
  if (s1 == s2)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
